0

I have a device that is like 3 headphones in one ( so 6 earplugs) . My goal is to play one diferent song on each earplug ( 6 songs). So I starded by playing one song on an earplug. For me one channel means one earplug (but maybe I am wrong) .I am using Psychtoolbox:

function BasicSoundOutputDemo( wavfilename)

AssertOpenGL;

% Read WAV file from filesystem:
[y, freq] = psychwavread(wavfilename);

aux = y' ;
wavedata = aux(1,:);


InitializePsychSound;
devices = PsychPortAudio('GetDevices' );

pahandle = PsychPortAudio('Open', [], [], 0, freq, 1);// nr channels = 1

PsychPortAudio('FillBuffer', pahandle, wavedata);

t1 = PsychPortAudio('Start', pahandle, 1, 0);


KbReleaseWait;


while ~KbCheck
  % Wait a seconds...
  WaitSecs(1);

end


PsychPortAudio('Stop', pahandle);


PsychPortAudio('Close', pahandle);


fprintf('Demo finished, bye!\n');

But it didn’t worked. Instead of playing the sound on just one earplug, it was playing on 2 earplugs.

I get this warnings

PTB-INFO: Using specially modified PortAudio engine, based on offical version: PortAudio V19-devel WITH-DIM

Will use ASIO enhanced Portaudio driver DLL. See Psychtoolbox/PsychSound/PortAudioLICENSE.txt for the exact terms of use for this dll.

Disclaimer: "ASIO is a trademark and software of Steinberg Media Technologies GmbH."

PTB-Warning: Although using the ASIO enabled Psychtoolbox sound driver,

PTB-Warning: could not find any ASIO capable soundcard in your system.

PTB-Warning: If you think you should have an ASIO card, please check your

PTB-Warning: system for properly installed and configured drivers and retry.

PTB-Warning: Read "help InitializePsychSound" for more info about ASIO et al.

PTB-INFO: New audio device with handle 0 opened as PortAudio stream:

PTB-INFO: For 1 channels Playback: Audio subsystem is MME, Audio device name is Microsoft Sound Mapper - Output

PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000 msecs, Output latency 464.399093 msecs.




Then I decided to try another aproch. Lets play the song on other 2 earplugs

I used PsychPortAudio('GetDevices') to find the id of the earplugs pair. Strange is that instead of 3 devices with 2 channels I found 4. And I used PsychPortAudio('Open' for id 7,9,18 and 20 but every time the song was played on the same earplug pair, the same pair from when I tried to play on just one earplug.
This is a picture with the 4 devices

enter image description here

function BasicSoundOutputDemo( wavfilename)

AssertOpenGL;

% Read WAV file from filesystem:
[y, freq] = psychwavread(wavfilename);

wavedata = y' ;
nrchannels = size(wavedata,1); % Number of rows == number of channels.

InitializePsychSound;
devices = PsychPortAudio('GetDevices' );

pahandle = PsychPortAudio('Open', 18, [], 0, freq, nrchannels);

PsychPortAudio('FillBuffer', pahandle, wavedata);

t1 = PsychPortAudio('Start', pahandle, 1, 0);


KbReleaseWait;


while ~KbCheck
  % Wait a seconds...
  WaitSecs(1);

end


PsychPortAudio('Stop', pahandle);


PsychPortAudio('Close', pahandle);


fprintf('Demo finished, bye!\n');

Now the only thing that is different at warnigs it this

PTB-INFO: For 2 channels Playback: Audio subsystem is Windows DirectSound, Audio device name is Speakers (USB Multi-Channel Audio Device)

Sorry for this long post but i wanted to give you all the informations.

Can you tell were I am wrong. How can I play one song on a specific earplug. I think if I know that then I just copy the code and put another song and so I will play one song on each earplug

3 Answers3

1

1) You likely don't want to run AssertOpenGL every time you present a sound.

2) Your code looks correct, though interestingly on my Apple laptop and built-in sound, sending a single channel signal is also playing from both headphone channels.

3) What audio device are you using? From your device listing, it looks like the 4 you have listed might be different interfaces to the same devices (2 outputs (one digital, one analog) X two APIs (one MME, one DirectSound). Are there any other entries in your device list?

DMR
  • 1,479
  • 1
  • 8
  • 11
  • i have 22 entries when i run getDevices. I can make a picture of ever one, but on Monday. Shame that I can't send you private messages – Beniamin Ionut Dobre Aug 21 '16 at 00:07
  • I added all the 22 devices [here](https://postimg.org/gallery/1bkjzynng/379f1185/) The device I m using doesn't have a name because is made by a friend, it isn't bought from a store. maybe the device is not good. [here](https://postimg.org/gallery/3ctnfq8we/c1447e0f/) are 2 picture with the device – Beniamin Ionut Dobre Aug 22 '16 at 09:15
  • unfortunatly i can't edit my previous post. the friend who made the device told me that i have to uninstal logiLink . I uninstal it now i have 18 devices but i still cant play a song on the pair/channels/devices I want it's always play on the same pair or on my computer speakers. [here](https://postimg.org/gallery/1in3ssny4/9954a8ff/) are the new pictures with the 18 devices. if I go to [speaker setup](https://postimg.org/image/71f8ckg2z/87b94c71/) i can play a sound on every earplug, so I think I just don't know how to acces the earplugs right in matlab – Beniamin Ionut Dobre Aug 22 '16 at 09:46
  • so from what i noticed deviceid 5,6,14,15 are the FRONT speakers i pluged in logilink, 7 and 16 are my computer speakers, at 8 and 17 i don't get an error but the songs are not played, all the other ids give me an error. As you can see there is no id for the SURROUND and CENTER/BASS – Beniamin Ionut Dobre Aug 22 '16 at 09:56
  • it might be hard to debug remotely. Does your sound device support ASIO? I'm not sure if it cause the devices to appear differently, but it may, and would be useful to obtain low latency sound presentation as well. – DMR Aug 22 '16 at 18:17
  • does [this](http://www.logilink.com/showproduct/UA0099.htm?seticlanguage=en) supports ASIO? – Beniamin Ionut Dobre Aug 25 '16 at 11:07
  • so as a warning it said i don't have a asio device. so i instaled ASIO4ALL and now i have an asio device. and instead of 18 devices i have 19. [this](https://postimg.org/image/x7juoiboz/701ff482/) is the 19th – Beniamin Ionut Dobre Aug 25 '16 at 11:43
  • Are you using 1 LogiLink device, or several? For comparison sake, here is the output of a Windows computer with an M-Audio Delta1010 installed, which had 10 outputs: ans = DeviceIndex: 34 HostAudioAPIId: 3 HostAudioAPIName: 'ASIO' DeviceName: 'M-Audio Delta ASIO' NrInputChannels: 12 NrOutputChannels: 10 LowInputLatency: 0.0058 HighInputLatency: 0.0174 LowOutputLatency: 0.0058 HighOutputLatency: 0.0174 DefaultSampleRate: 44100 – DMR Aug 25 '16 at 17:31
  • Another question is whether you kept the headphones plugged in to the device when you were trying to play from the other channels in MATLAB. It is possible that the firmware of your device disconnects the speaker channels and routes everything throught the headphone port when headphones are plugged in. – DMR Aug 25 '16 at 17:33
0

a partial answer to my question. I found how to play a song in an earplug and another in the other. psychwavread gives me a 2 rows array. so i put in an array the first row of one song and the first row of the other song. so now i have a 2 row array simillar to the one from when i play one song, but now i play 2 songs [y, freq] = psychwavread(wavfilename1); [y1, freq1] = psychwavread(wavfilename2); aux = y'; aux1 = y1'; wavedata = [aux1(1,:) ; aux(1,:)];

  • This will work for two channels on the same device, you're essentially created a single matrix of stereo data from two mono data vectors. – DMR Aug 22 '16 at 18:05
0

so i manage to play on 4 channels i am sure that i can play on 6 and 8. I installed ASIO4ALL and I choose the ASIO4ALL device id when open. when ASIO4all opens I can choose my 6 channels device and after that I just choose in the open function on which channels to play the sounds