Re: Audio Compressor

Doug Stewart <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Message-ID <CAAohRsbd-yOv1q_a6TQ0=BiEw6SDOJ_mD9dJePv3r9d-ERTguA@mail.gmail.com>
On Tue, Aug 18, 2020 at 11:26 AM Renato S. Yamane <[email protected]>
wrote:

> Em ter., 18 de ago. de 2020 às 15:12, Doug Stewart <[email protected]>
> escreveu:
>
>> On Tue, Aug 18, 2020 at 9:41 AM Renato S. Yamane <[email protected]>
>> wrote:
>>
>>> 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);
>>>   ====================
>>>
>>>
>> There are many ways to do Audio Compression.
>> Tell us more about what you want to accomplish.
>>
>
> Hi, thanks for your feedback.
> I just need to the user define the crest factor (first line of the code
> above) and the script must generate the noise (wav file) with the
> respective crest factor without clipping.
> I'm expecting the user define the Crest Factor between -6 to -12dB.
>
> Many thanks,
> Renato
>
> But crest factor and clipping are 2 independent things. you can have a
crest factor of some value  and still have clipping or no clipping.


-- 
DAS[image: Certificate for 206392]

<https://linuxcounter.net/user/206392.html>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.