Problem sound-image?
1 次查看(过去 30 天)
显示 更早的评论
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
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!