Create a signal from concatenating signals with pauses inbetween.
8 views (last 30 days)
Show older comments
Greetings! I'm trying to create use sound on a signal creating by a random number of signals which should have pauses in between. The signals all have the same size so I was able to do it like this:
if true
Y = 0;
for ()
sig = x();
sigY = Y;
Y = [sig sigY];
end
end
Then I tried adding a signal with 0 value that lasts for as long as I want (pauses aren't fixed length) and concatenated this also like:
if true
Y = 0;
for ()
sig = x();
pauseSig = z();
sigY = Y;
Y = [sig pauseSig sigY];
end
end
However when I run this there's no pause. I think that sound() skips the 0 value signal completely, instead of being "paused" for that duration. Am I doing something wrong, or is there another way to do this? Thanks a lot!
0 Comments
Answers (1)
Aditya Salveru
on 23 May 2018
Hi,
You can concatenate the signals with zeros of desired length to get a pause in the sound.
I have taken a sounds of three frequencies i.e 100,200,500 Hz and concatenated them along with a pause for a second. This actually works as intended.
You can find the code for the same below
fs=2000; %sampling rate.
t=0:1/fs:2-1/fs; %time values.
x1=2*sin(2*pi*100*t); %first sound.
x2=2*sin(2*pi*200*t); %second sound.
x3=2*sin(2*pi*500*t); %third sound.
pause=zeros(1,1*(fs)); %pause of length 2 seconds.
y=[x1 pause x2 pause x3]; %concatenation of sounds along with pause.
sound(y,fs); %playing the sound.
Hope this helps.
Thanks ,
Aditya.
0 Comments
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!