Question

so I've been struggling with this for a while. I am supposed to make a sequence of tones play with only one soundsc(wave,fs) call, but when I try to put the tone waves in an array, it just plays them at the same time instead of consecutively. For example:

pitch1 =  sin(2*pi*freq1*t); 
pitch2 =  sin(2*pi*freq2*t);
pitch3 =  sin(2*pi*freq3*t);

concat_pitch = [pitch1; pitch2; pitch3]; % I want them to play in order, not together

soundsc(concat_pitch, fs); % this just plays them all together

Can anyone help me out? Thanks.

Was it helpful?

Solution

Change your concatenation to form a single row vector:

concat_pitch = [pitch1, pitch2, pitch3];

Or if the concatenation you specified is important and has to stay as is, then you can loop through the rows of the 2-d matrix:

for ind=1:length(concat_pitch)
    soundsc(concat_pitch(ind,:), fs);
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top