Hi,
I'm programming an experiment which includes audio and visual stimuli.
I've programmed the visual aspect - randomised pictures displayed for
90 ms each. Now I have to find a way to encorporate the audio. I need
to play the audio stimuli asynchronously, but the beginning of such
stimuli must correspond to the beginning of a picture. I've tried
using the Snd mex file, but I'm having problems - it makes a loud
sound and then doesn't play for a while. I've also tried using the
Matlab audioplayer, which works quite well, but I find that after a
about a minute, I get a delay in the pictures display (misses a
refresh), ever 10 pictures or so (every 900 ms).
Timing is of utmost importance to me - delays above 5 ms are very
problematic, especially so often.
I'm not sure if the problem lies in the functions, or in the driver,
or the OS. I'm working on Matlab 7 on Windows XP, and my sound card is
a RealTeck AC'97 Audio.
Here is the bit of code which displays the stimuli. This is just a
test - which is why I used one of Window's wav files to play around with.
% configure sound
[y, f, nbits] = wavread('C:\WINDOWS\Media\Windows XP Menu Command.wav');
player = audioplayer(y,f,nbits);
playblocking(player);
%%%%%%%%% DISPLAY OF PICTURES %%%%%%%%%%%%%%%%%%%%
%Priority(2);
% display distractors and targets
for j = 1:length(trial)
play(player);
Screen('CopyWindow',winarray(trial(j)),window); %copy buffer
window to screen
t1(j,1) = time; %get timing
wait(ontime); %wait ontime
t2(j,1) = time;%get timing
if(offtime ~= 0)
Screen(window,'FillRect',white, rect); %fill window with empty
white block
t3(j,1) = time; %get timing
wait(offtime); %wait offtime
t4 (j,1) = time; %get timing
end
end
%Priority(0);
I'd appreciate any insight on the matter, since I'm not very familiar
with programming realtime audio.
Thanks very much,
Galit
I'm programming an experiment which includes audio and visual stimuli.
I've programmed the visual aspect - randomised pictures displayed for
90 ms each. Now I have to find a way to encorporate the audio. I need
to play the audio stimuli asynchronously, but the beginning of such
stimuli must correspond to the beginning of a picture. I've tried
using the Snd mex file, but I'm having problems - it makes a loud
sound and then doesn't play for a while. I've also tried using the
Matlab audioplayer, which works quite well, but I find that after a
about a minute, I get a delay in the pictures display (misses a
refresh), ever 10 pictures or so (every 900 ms).
Timing is of utmost importance to me - delays above 5 ms are very
problematic, especially so often.
I'm not sure if the problem lies in the functions, or in the driver,
or the OS. I'm working on Matlab 7 on Windows XP, and my sound card is
a RealTeck AC'97 Audio.
Here is the bit of code which displays the stimuli. This is just a
test - which is why I used one of Window's wav files to play around with.
% configure sound
[y, f, nbits] = wavread('C:\WINDOWS\Media\Windows XP Menu Command.wav');
player = audioplayer(y,f,nbits);
playblocking(player);
%%%%%%%%% DISPLAY OF PICTURES %%%%%%%%%%%%%%%%%%%%
%Priority(2);
% display distractors and targets
for j = 1:length(trial)
play(player);
Screen('CopyWindow',winarray(trial(j)),window); %copy buffer
window to screen
t1(j,1) = time; %get timing
wait(ontime); %wait ontime
t2(j,1) = time;%get timing
if(offtime ~= 0)
Screen(window,'FillRect',white, rect); %fill window with empty
white block
t3(j,1) = time; %get timing
wait(offtime); %wait offtime
t4 (j,1) = time; %get timing
end
end
%Priority(0);
I'd appreciate any insight on the matter, since I'm not very familiar
with programming realtime audio.
Thanks very much,
Galit