PsychPort

So I would like to play a sound during experimentatation.


The code snippet so far:


-------------------------------------------------

InitializePsychSound(1); 

pahandle = PsychPortAudio('Open', [], [], 3, Fsc, nrchannels, [], [], [], []); %'4' and '16' for max speed

PsychPortAudio('Fillbuffer', pahandle, probetone);

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

--------------------------------------------------


Now for timing purposes I wish to add a GetSecs command right after the playback has finished. However, in the current script, the tone is still playing while the Matlab script is running along.


So the regular Matlab function 


-----------------------------------------

playblocking(probe);

-----------------------------------------


...blocks further activity until playback is finished. is there an alternative in PTB-3 for this function?





---In PSYCHTOOLBOX@yahoogroups.com, <hcstronks.jhmi.edu@...> wrote :

So I would like to play a sound during experimentatation.


The code snippet so far:


-------------------------------------------------

InitializePsychSound(1); 

pahandle = PsychPortAudio('Open', [], [], 3, Fsc, nrchannels, [], [], [], []); %'4' and '16' for max speed

PsychPortAudio('Fillbuffer', pahandle, probetone);

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

--------------------------------------------------


Now for timing purposes I wish to add a GetSecs command right after the playback has finished. However, in the current script, the tone is still playing while the Matlab script is running along.


So the regular Matlab function 


-----------------------------------------

playblocking(probe);

-----------------------------------------


...blocks further activity until playback is finished. is there an alternative in PTB-3 for this function?


-> Look at PsychPortAudio('Stop',...), and use its returned timestamps. Your GetSecs wouldn't be reliable/accurate, neither would be use of playblocking(). Also we have multiple demos about precise timing etc. and info in the ECVP slide decks in the PsychDocumentation/ folder.


-mario


Dear Mario,

That was a great help thanks.

A last question - using the standard Matlab function I would do the following:

player = audioplayer(signal, Fs, 16, audioDevID) 
 
The '16' there would be the bits/sample. Is this an important parameter in PTB-3's PsychPortaudio? I couldn't find any reference on it. It seems to work without, but I'm in an audiology setting, so I'd rather be sure of this.

Thanks so much,
Chris
Hi Mario,

Thanks for you ongoing support.

Would it be advisable to use a higher end external USB sound card then, given that we are using a laptop for experimentation?

That would add the USB polling time, but would probably result in better behavior.

Thanks heaps,
Chris