Tone Distortion

Hello,

We are performing an experiment that involves synchronized audio/visual stimuli. We originally had latency issues, so upgraded to a M-Audio Delta 1010LT card (on a Dell GX620 with Windows XP SP3). Upon installing, the latency issues are much better, but strangely the tones we used (sine waves generated in the code) are played back with distortion (as described by other forum users, a kind of "brrr" sound). We have tested various modes/arguments for PsychPortAudio('Open'), InitializePsychSound, etc, and found that inserting a wait period AFTER the sound seems to fix the distortion. Here is a brief sample of our code:

InitializePsychSound(1);
pahandle = PsychPortAudio('Open', [], [], 1, freq, 2);
PsychPortAudio('RunMode', pahandle, 1);
t=[0:1/Fsys:leng];
wavedata = amp*sin(freq*2*pi*t);
PsychPortAudio('FillBuffer', pahandle, [wavedata;wavedata]);
PsychPortAudio('Start', pahandle, 1, 0, 1);
PsychPortAudio('Stop', pahandle, 1);
WaitSecs(0.009);

The last line shows the step we added that got it to work. For some reason, a WaitSecs >= 9ms allowed the tone to be played back properly with no distortion. We've tried deleting the buffer between sounds, closing/reopening/etc, all to no avail.

Do you have any ideas of how we can fix the distortion without the WaitSecs() function? We are very concerned with minimizing latency, and even 9ms may be a problem.

When troubleshooting, we tried isolating the tone part of the code, and made a sample:

freq = 44100;
leng = 0.025;
InitializePsychSound(1);
pahandle = PsychPortAudio('Open', [], [], 1, freq, 2);
t=[0:1/freq:leng];
amp = 0.5;
wavedata = amp*sin(330*2*pi*t);
PsychPortAudio('FillBuffer', pahandle, [wavedata;wavedata]);
t1 = PsychPortAudio('Start', pahandle, 1, 0, 1);
PsychPortAudio('Stop', pahandle, 1);
wavedata = amp*sin(990*2*pi*t);
PsychPortAudio('FillBuffer', pahandle, [wavedata;wavedata]);
t1 = PsychPortAudio('Start', pahandle, 1, 0, 1);
PsychPortAudio('Stop', pahandle, 1);
PsychPortAudio('Close', pahandle);

When this is played alone, it works no problem, without any wait period before or after the sounds. Do you have any insight regarding this matter?

Thanks,


--
Hannah Fletcher
Undergraduate Student
School of Psychology
Georgia Institute of Technology