How to insert 5ms rise and fall to my signal (sound) ?
1 view (last 30 days)
Show older comments
Hello everyone i have a task for my collage, to generate white noise and i did it but i have a problem which is i hear a click sound at the beginning of the sound ( signal ).
so to solve this issue i have to insert a slope at the beginning and ending of the sound of 5ms, but how?
thank you.
0 Comments
Accepted Answer
Star Strider
on 9 Feb 2019
Try this:
Fs = 44100*2; % Sampling Frequency (Hz)
ms5 = fix(Fs * 0.005); % Samples/5ms
t = 0:5*Fs-1; % Time Vector
f = 500; % Frequency
s = sin(t*(2*pi)*f/Fs)'; % Signal
cos_slope = [(1-cos((0:ms5-1)*pi/ms5))/2 ones(1, size(s,1)-(2*ms5)) fliplr((1-cos((0:ms5-1)*pi/ms5))/2)]'; % ‘Slope’ Vector
cos_slope = repmat(cos_slope, 1, size(s,2)); % ‘Slope’ Matrix
s_with_slope = s.*cos_slope; % ‘Corrected’ Signal
figure
plot(t, s)
hold on
plot(t, s_with_slope)
hold off
grid
xlim([0 2*ms5])
pause('on')
sound(s, Fs)
pause(6)
sound(s_with_slope, Fs)
It creates a cosine-taper ‘slope’ at the beginning and the end, adjusting for the sampling frequency and signal length, as well as the signal having two columns (stereo).
2 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!