Adding a beep cue before a specific location

Hi all, I have generated 5 different sounds in each block/trial I now need a pure tone cue to be generated in each block before the 5th sound is generated. How can i do that ? Please help.
{function out = makeTrain(in)
%in would be a list eg: [1 2 3 4 5;3 4 5 1 2; 2 3 4 1 5;...]
wavdir = 'C:\sounds';
out = [];
% isi = 500ms
isi = 500/1000 * 44100;
isi = zeros(isi,1);
cueTone = mktone(2500, 300,10,1000/44.1,1);
% this function generates a pure tone of f=2500 Hz, t=300 ms,
fs=44100 Hz
cueTone = cueTone/max(cueTone);
for idx = 1:length(in)
switch in(idx)
case 1
wavfile = [wavdir 'ka.wav'];
case 2
wavfile = [wavdir 'pa.wav'];
case 3
wavfile = [wavdir 'ga.wav'];
case 4
wavfile = [wavdir 'ba.wav'];
case 5
wavfile = [wavdir 'da.wav'];
end
snd = wavread(wavfile);
if idx == 1
out = snd;
else
out = [out;isi;snd];
end
end
out = [??]
end
}

댓글 수: 2

Jan
Jan 2011년 7월 4일
1. Please format your your code using the "{} Code" button on top of the edit box. More about formatting: see the "Markup" link on this page.
2. Do you have a question?
imran
imran 2011년 7월 4일
Hi,
1) Sorry I am relatively new to this forum. I hope the formatting looks alright now.
2) Yes, I need help to generate the cue tone in each block before the fifth sound is played.

댓글을 달려면 로그인하십시오.

 채택된 답변

Daniel Shub
Daniel Shub 2011년 7월 5일

0 개 추천

You have cueTone defined so all you need to do is add it to your snd array ...
if idx == 1
out = snd;
elseif idx == 5
out = [out;isi(1:(length(isi)/2), :);cueTone;isi(((length(isi)/2)+1):end, :);snd];
else
out = [out;isi;snd];
end
I added it before the 5th sound halfway in between the isi, but you should be able to put it where ever you want.

추가 답변 (0개)

카테고리

태그

질문:

2011년 7월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by