Did you intend to put: return z[2]; ? Thanks.>>The DC gain = 1 however the response is entirely different from original>>filter. Looks like 2nd order filter with real poles. Is that what it is >>supposed to be? >> > >It was intended to be 3rd order. I just checked and it looks 3rd order to >me. So not sure what is wrong. But the response is not optimal. I madethe>code too complex, this one is better :) > >s32 LPF(s32 *z, s32 x) >{ > z[0] += (x - z[0]) >> 8; > z[1]+= z[2] >> 8; > x = z[0] - z[1] - z[2]; > z[2]+= x>>8; > return z[0]; >} > >Here are the responses >http://tinypic.com/r/1zganmd/5 >where the butterworth reference is fs/1400. (fs=48000 in plot). > >_____________________________ >Posted through www.DSPRelated.com >_____________________________ Posted through www.DSPRelated.com
Butterworth
Started by ●October 4, 2013
Reply by ●October 9, 20132013-10-09
Reply by ●October 10, 20132013-10-10
>Did you intend to put: > > return z[2]; > >? Thanks.No, sorry I messed that up and thanks for pointing it out. It should be z[1]. I can see that I also messed up the legend and colors in the plot. The green curve is the response of the filter posted by VLV and the black curve is the response of the other filter posted by me. If you want to verify for yourself then maybe you can use this (It generates the plot). clear all fs = 44100; fc = fs/1400; [Bref,Aref] = butter(3, 2*fc/fs); [Href,Fref] = freqz(Bref,Aref,10000,fs); figure; semilogx(Fref,20*log10(abs(Href))) hold on; N =5000; impulse = [1, zeros(1,4999)]; z2s = zeros(size(impulse)); z0 = 0; z1 = 0; z2 = 0; k = 1/256; for c=1:N z0 = z0 + (impulse(c)-z0)*k; t = z0 - 2*z2; z1 = z1 + (t - z1)*k; z2 = z2 + (z1-z2)*k; z2s(c) = z2; end [Hi,Fi] = freqz(z2s,1,10000,fs); semilogx(Fi,20*log10(abs(Hi)),'g--') z1s = zeros(1,5000); z1 = 0; z2 = 0; z0 = 0; for i = 1:length(impulse) z0 = z0 + (impulse(i)-z0)*k; z1 = z1 + z2*k; x = z0 - z1 - z2; z2 = x*k + z2; z1s(i) = z1; end [H,F] = freqz(z1s,1,10000,fs); semilogx(F,20*log10(abs(H)),'k') legend('Butter','VLV','Other one') xlim([10 1000]) ylim([-60 1]) xlabel('Frequency [Hz]') ylabel('Magnitude [dB]') title('Frequency response comparison') _____________________________ Posted through www.DSPRelated.com
Reply by ●October 17, 20132013-10-17
On 10/10/2013 1:07 AM, niarn wrote:> I can see that I also messed up the legend and colors in the plot. The > green curve is the response of the filter posted by VLV and the black curve > is the response of the other filter posted by me. If you want to verify for > yourself then maybe you can use this (It generates the plot).Better: s32 LPF(s32 *z, s32 x) { x = z[0] += (x - z[0]) >> 8; x -= z[2]; x <<= 1; z[1] += (x - z[1]) >> 8; return z[2] += (z[1] - z[2]) >> 8; } Besides frequency response, look at dynamic range of the filter in the passband and in the stopband. Vladimir Vassilevsky DSP and Mixed Signal Designs www.abvolt.com
Reply by ●October 21, 20132013-10-21
>Besides frequency response, look at dynamic range of the filter in the >passband and in the stopband. >Do you mean the level of the noise floor? How exactly do you measure the dynamic range?>Vladimir Vassilevsky >DSP and Mixed Signal Designs >www.abvolt.com > > >_____________________________ Posted through www.DSPRelated.com
Reply by ●October 21, 20132013-10-21
On 10/21/2013 3:26 AM, niarn wrote:>> Besides frequency response, look at dynamic range of the filter in the >> passband and in the stopband. >> > > Do you mean the level of the noise floor? > How exactly do you measure the dynamic range?Dynamic range at the frequency = level of clipping at the frequency vs noise density at the frequency. Vladimir Vassilevsky DSP and Mixed Signal Designs www.abvolt.com
Reply by ●October 22, 20132013-10-22
>Dynamic range at the frequency = level of clipping at the frequency vs >noise density at the frequency.I have measured (simulated) SNR. Look here: http://tinypic.com/r/2cxvijc/5 The SNR should be related to your dynamic range measure as there is used a fullscale input. There is a 6 dB difference independent of frequency, it seems. Cheers _____________________________ Posted through www.DSPRelated.com
Reply by ●October 23, 20132013-10-23
Hi all, Vlad's Filter has z-transfer function 1/( -16581375*(z^-3)+49938690*(z^-2)-50134528*(z^-1)+16777216) ans thus poles at 0.996078 +/- j*0.005513 and 0.996094 THX for all the fun! Cheers Detlef _____________________________ Posted through www.DSPRelated.com
Reply by ●October 24, 20132013-10-24
On 10/21/13 10:26 AM, Vladimir Vassilevsky wrote:> On 10/21/2013 3:26 AM, niarn wrote: >>> Besides frequency response, look at dynamic range of the filter in the >>> passband and in the stopband. >>> >> >> Do you mean the level of the noise floor? >> How exactly do you measure the dynamic range? > > Dynamic range at the frequency = level of clipping at the frequency vs > noise density at the frequency. >i like to define it as the dB of SNR plus the dB of headroom. these two quantities add roughly to a constant, at least for mid-level output. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●October 24, 20132013-10-24
On 10/23/13 8:56 AM, Detlef _A wrote:> > Vlad's Filter has z-transfer function > > 1/( -16581375*(z^-3)+49938690*(z^-2)-50134528*(z^-1)+16777216) > > ans thus poles at > > 0.996078 +/- j*0.005513 > and 0.996094 > > THX for all the fun! >boy, i wasn't gonna go through all that work. better you than me. thank you for your sacrifice. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●October 25, 20132013-10-25
> >i like to define it as the dB of SNR plus the dB of headroom.That makes sense to me because the headroom could just as well be used to gain up the input and thus increase SNR. One practical issue I can think of with this approach is that if some non-stationary input is used for the measurement it may be difficult to find or track what the headroom should be. I assume you mean the margin up to fullscale as being the headroom. What type of input would you use for your SNR measurement? sweep, sinusoidal, noise?> these two >quantities add roughly to a constant, at least for mid-level output.Do you mean that for mid-level output there is very little risk of internal wraparound or saturation that could impact the measurement?> > >-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > > >_____________________________ Posted through www.DSPRelated.com