Audio Compressor
"Renato S. Yamane" <[email protected]>
| Newsgroups | gmane.comp.gnu.octave.general |
|---|---|
| Message-ID | <CANJjkzuvpYN6AhoSYeYMq9pzw4F4tJrpv4ejqs4FA=DLky1sLA@mail.gmail.com> |
Hi,
Is there an Audio Compressor available in Octave?
https://www.mathworks.com/help/audio/ref/compressor-system-object.html
I'm compressing my noises in the worst way, as you can see in the "while"
condition on the example below.
In my way, the peaks will be "clipped", and I would like to avoid my stupid
workaround:
====================
crest_factor = 6;
typenoise = noise(10*44100, 1, 'pink');
[z, p, k] = butter(4, [100/(44100/2), 500/(44100/2)]);
sos = zp2sos (z, p, k);
filtered = sosfilt(sos, typenoise);
normalized = filtered / (rms(filtered) / 10^(-crest_factor/20));
#{
Now I'm making an stupid workaround, as the audio file must be in
a range from -1 to +1:
#}
while (normalized(normalized > 1) || normalized(normalized < -1))
normalized(normalized > 1) = 1;
normalized(normalized < -1) = -1;
normalized = normalized / (rms(normalized) / 10^(-crest_factor/20));
endwhile
audiowrite ('AudioFile.wav', normalized, 44100);
====================
Thanks in advance,
Renato