Clipping a sound wave
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone!
I have a soundwave (a 30000x2 vector) which I want to clip (cut off) at certain points. I calculated the maximum amplitude and now I want to cut off every value 60% above and below this value. So like if [value] > 0.6*maxamp or [value] < -0.6*maxamp, then set those values to [0.6*maxamp] and [-0.6*maxamp], respectively. I simply cannot figure out how to put this into a proper code/function. I'd be thankful for any suggestions on how to solve this!
Greetings
0 comentarios
Respuestas (1)
Star Strider
el 21 de Feb. de 2016
Something like this will work:
Fs = 44100;
L = 5;
t = linspace(0, Fs*L, Fs*L);
F0 = 440;
s = sin(2*pi*F0*t) + sin(2*pi*F0*3*t) + sin(2*pi*F0*5*t);
s_max = 0.6*max(abs(s));
pos_idx = (s > s_max);
neg_idx = (s < -s_max);
s_clipped(neg_idx) = -s_max;
s_clipped(pos_idx) = +s_max;
sound(s*10, Fs)
pause(L)
sound(s_clipped, Fs)
Make appropriate changes to work with your signal.
0 comentarios
Ver también
Categorías
Más información sobre Simulation, Tuning, and Visualization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!