help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sosfit in filter function


From: Renato S. Yamane
Subject: Re: sosfit in filter function
Date: Thu, 10 May 2018 15:46:45 +0200

2018-05-09 20:19 GMT+02:00 Renato S. Yamane <address@hidden>:
> 2018-05-09 19:31 GMT+02:00 Mike Miller <address@hidden>:
>> Instead of this
>>
>>     [b, a] = butter (...
>>     output = filter (b, a, input);
>>
>> you would use this
>>
>>     [z, p, k] = butter (...
>>     sos = zp2sos (z, p, k);
>>     output = sosfilt (sos, input);
>
> Thank you so much for your support!
> Now, as it´s not possible see the response frequency of the filter
> using freqz, I opened the output file in Audacity.
>
> When the audio is very compressed (6dB Crest Factor), the response
> frequency don´t keep attenuating in LOW frequencies.
> See here: https://ibb.co/iQD8Ty
>
> ++++++++++++++++++++++++++++
> sampling_rate = 44100;
> length = 120;
> hpf = 40;
> lpf = 400;
> filter_order = 4;
> crest_factor = 6;
>
> typenoise = noise((length)*sampling_rate, 1, 'pink');
>
> [z, p, k] = butter(filter_order, [hpf/(sampling_rate/2),
> lpf/(sampling_rate/2)]);
> sos = zp2sos (z, p, k);
> filtered = sosfilt(sos, typenoise);
> normalized = filtered / (rms(filtered) / 10^(-crest_factor/20));
>
> 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 ('output.wav', normalized, sampling_rate);
> ----------------------------------------------------

As an workaround, I tried use pwelch:
pwelch(normalized,hanning(8192), 'loglog');

The "shape" of the graphic looks OK, but the axis are a little bit strangers.
Can someone give me a help, again? :-)

Thank you,
Renato



reply via email to

[Prev in Thread] Current Thread [Next in Thread]