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.

1 件のコメント

imran
imran 2011 年 7 月 5 日
Thanks a lot, It works great.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAudio I/O and Waveform Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by