Problem sound-image?

1 次查看(过去 30 天)
LuS
LuS 2015-10-19
评论: LuS 2015-10-19
Hi All,
I am struggling a bit with a script that I would like to create for my experiment:
a sound is played and 1 sec after the end of the sound an image is displayed on the screen for 3 secs.
Does anybody have the solution to my problem?
Please :)
Many thanks!!
%Open the screen
[wPtr,rect]=Screen('OpenWindow',max(Screen('Screens')),[], [0 0 900 900]);
xCenter=rect(3)/2;
yCenter=rect(4)/2;
%Create textures
srcFiles = dir('c:/Users/LuS/Desktop/Project1/Images/*.jpg'); % the folder in which the images exists
for i = 1 : length(srcFiles)
Images = strcat('c:/Users/LuS/Desktop/Project1/Images/*.jpg',srcFiles(i).name);
I = imread(Images);
figure, imshow(I);
Screen('DrawTexture',wPtr,[], Images);
Screen('Flip',wPtr,[], Images);
[imageHeight, imageWidth,colorChannels]=size(Images);
gap=100; %distance of pics from center
leftRect=[xCenter-gap-imageWidth, yCenter-imageHeight/2, xCenter+imageHeight/2];
rightRect=[xCenter+gap, yCenter-imageHeight/2, xCenter+gap+imageWidth, yCenter+imageHeight/2];
textures=[filelist];
textureNames={filelist};
end
%Read sounds
filelist=dir('c:/Users/LuS/Desktop/Project1/Sounds/*.wav'); % the folder in which the sounds exists
for K=1:numel(filelist)
[data,Fs]=wavread(filelist(i).name);
result(i)=your_action(data,Fs);
end
  1 个评论
Walter Roberson
Walter Roberson 2015-10-19
You appear to be using the third party psychometric toolbox. The methods for displaying images in it are beyond our scope. Someone might happen to know, but it might take a while before anyone who knows happens to read the question.
My understanding is that the third party toolbox has an active mailing list.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2015-10-19
Are you asking how to clip your sounds to a maximum of 1 second? And how to play them with sound() or soundsc()?
And I'd guess that you'd need to put your sound playing code inside your loop over all images (rather than a separate loop after it), along with a pause(3) after you've displayed the image.
  1 个评论
LuS
LuS 2015-10-19
Hi,
Thank you for your reply. I would like to play the sound while the screen is grey and 1 second after the end of the sound, an image appears on the screen for 3 seconds.

请先登录,再进行评论。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by