Reputation: 210
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
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
Upvotes: 0
Views: 823
Reputation: 210
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
Upvotes: 0
Reputation: 210
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,:)];
Upvotes: 0
Reputation: 1473
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?
Upvotes: 1