>dear rajeev
>Dear Profs. Brainard & Pelli,
>
>I have been using the PsychToolbox to present simple auditory-visual
>stimuli, with the visual coming before the auditory by some SOA. I do this
>by calling SND, to play an auditory vector with a delay's worth of zeros
>at the beginning.
>
>I find that when I repeat this process, the CopyWindow command that
>flashes up the visual stimulus also causes an audible click sound.
>
>This click disappears if I call "clear mex" on each repetition of the
>loop. I have no idea why!
>
>Here is the output of screentest, along with a program that makes the
>"click" bug on my Mac, and which is as minimal as I can make it.
>
>Many thanks in advance for any clues about the bug.
>If it remains a mystery, then it's not a big problem, because the
>"clear mex" workaround does work, even if it's not very pretty.
>
>Yours,
>
>Rajeev Raizada
>-----------------------------------------------------------
>****** Russell Poldrack's Power Mac G4/450, Mac OS 9.0.2, Using Virtual
>Memory. ******
>G4, 450 MHz, memory bus 100 MHz, 65.985 Mflop/s
>PsychToolbox 2.44, 7 August 2000, MATLAB 5.2.0.3084
>QuickTime 4.1
>FileSharing is on.
>Warning: VM is on.
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Sample minimal program
>
>samp = 22254.545454; % Default Mac sampling rate for SND command
>
>while 1; % So that we loop round forever until user hits Control-C
>
>%clear mex; % Bug workaround. With this line commented out,
> % there is an audible click when the visual stimulus is
> % flashed up, but *not* the first time the loop goes round.
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>% Open screen-window
>
>window=SCREEN(0,'OpenWindow',255,[],8); % Open full-screen window, black
>
>% If 8-bit pixels, black=255, white=0
>
>%%%%%%%%%%%%%% Make auditory file, delays etc.
>
>aud_dur = 0.1; % Auditory duration, in seconds.
>aud_stim = sin( 1: round(aud_dur*samp));
>aud_delay = zeros(1,round(samp));
>aud_vec = [ aud_delay aud_stim ]; % Vector fed into SND
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Wait for 2 secs
>waitsecs(2);
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>% Make off-screen window holding the visual stimulus
>
>imageRect = [0 0 100 100]; % This will hold the image
>destRect= [400 500 500 600];
>
>imagePtr = SCREEN(window,'OpenOffscreenWindow',[],imageRect,8);
>
>SCREEN(imagePtr,'PutImage',0*ones(100),imageRect);
> % Copy image of visual stimulus to offscreen window
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>% Now present the stimuli
>
>snd('play',aud_vec,samp); % Play the sound vector:
>
>SCREEN(window,'WaitBlanking');
>SCREEN('CopyWindow',imagePtr(1),window,imageRect,destRect,'srcCopyQuickly');
> % Copy the offscreen circle onto the onscreen window
>
>waitsecs(2); % Wait a bit before displaying message
>
>SCREEN(window,'TextSize',35);
>SCREEN(window,'TextFont','helvetica');
>screen(window,'drawtext','Click mouse to repeat',100,300,100);
>
>getclicks;
>
>end; %%%%%%%%%% Takes us back to "while" loop
>
thanks for including the minimal test program and screentest report.
i ran your program on my powerbook g3 series and replicate your findings.
i suspect that SCREEN has nothing to do with it. CLEAR MEX flushes all
mex files. Changing it to CLEAR SCREEN brings back the click (ie CLEAR
SCREEN has no effect on the click). Changing it to CLEAR SND makes the
click go away again.
The sound you're playing ends on a nonzero value, so one would expect a
click when you start playing your zero valued silence. CLEAR SND must
somehow flush the nonzero value out quietly.
if you add a zero value to the end of your sinewave, you'll find that
there's no click at the beginning of the zero-valued silence.
aud_vec = [ aud_delay aud_stim 0 ]; % Vector fed into SND
if you don't want a click at the beginning and end of the sine, you may
prefer to ramp up and down the sinewave amplitude.
nice puzzle
i'm cc-ing to the psychtoolbox forum to share this with other users.
best
denis