Code for reproducing archives of sound and images in Psychtoolbox

Hello everybody,

I'm having a lot of trouble with my codings in Psychtoolbox. I'm making two programs for my thesis in Psychophysics:

In the first one, I need to present and image in the screen for a certain time (for example: 800 miliseconds) but I can't find a way to make the image stay the time I need. The codes for this part that I'm using are:

Screen('FillRect',w,white);
vbl=Screen(w, 'Flip');


Screen('PutImage', w, tiempo,rect); %Presents the stimulus
vbl=Screen(w, 'Flip');
WaitSecs(.8); %I supposed this will work, but it doesn't.

% blank the Screen and wait a second
Screen('FillRect',w,white);
vbl=Screen(w, 'Flip', vbl+(flipSpd*monitorFlipInterval));
tic
while toc<1
end


Does anybody know which code I can use for having my image presented for a specific duration?


For my second program, I need to reproduce an archive of sound in Psychtoolbox again, but I can't find the way for doing that. I have tried with: BasicSoundOutputDemo([repetitions=0][, wavfilename]), and I can reproduce the sound, but when it finishes, the program just became jammed and it doesn't continue.

I've tried already with "SND" or "Snd", but it doesn't work because my program uses a window opened with Psychtoolbox, and Snd is an instruction that only functions in the command window of Matlab.

Nowadays, the code I'm trying is this:



Screen('FillRect',w,white);
vbl=Screen(w, 'Flip');

InitializePsychSound;
PsychPortAudio('Open' , pahandle);


BasicSoundOutputDemo(0, 'ritmo 1-3.wav');


PsychPortAudio('Stop' , pahandle);
PsychPortAudio('Close' , pahandle);


Does anybody know what I am doing wrong?


Thank you so much!
Have a nice day :)