Clipping a sound wave
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 21 Feb 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 Commenti
Vedere anche
Categorie
Scopri di più su Simulation, Tuning, and Visualization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!