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 Comments

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.

Sign in to comment.

 Accepted Answer

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.

More Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!