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 个评论

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?
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.

请先登录,再进行评论。

 采纳的回答

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 个)

类别

帮助中心File Exchange 中查找有关 Audio 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