Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Chapter 6 - IIR filters
No permission to create posts
May 29, 2018
8:21 am
Avatar
Malcolm rest
Member
Members
Forum Posts: 9
Member Since:
April 2, 2018
sp_UserOfflineSmall Offline

Seems to me I'm missing something very essnetial with these basic single pole filters.

I've implemnted the LPF example on p.164-5 and recevied a satisfactory result, i.e. zero (db) gain at low frequencies and (-6 db) attenuation slope at higher than cutoff frequencies.

However, when I implement the HPF example, I get a high-frequency attenuation which is not the expected with some energy loss at low frequncies.

When dialing in the HPF values, I was expecting a zero (dB) gain at high frequencies and -6 db attenuation slope at sub-cutoff frequencies. That' s not what I receive on the FR graph. What am I doing wrong ?

Here is the code:

//Design equation calculation (Fc = 100, Fs = 44100, Pi = 3.14159 approx.)

float Theta = 2 * 3.14159 * 100 / 44100;
float T = 2 - cos(Theta);
float b1 = sqrt(T*T - 1) - T;
float a0 = 1 + b1;

 

//Turn stereo to mono (just for convinience and simplicity)

float x = 0.5 * (pInputBuffer[1] + pInputBuffer[0]);

 

//Difference equation

float y = a0 * x - b1 * yn;

 

//Iterate

yn = y;

 

//Output

pOutputBuffer[0] = y;
pOutputBuffer[1] = y;

return true;

=====================

Yn is declared as float in the *.h file and zero'd on 'prepare to play' function. It does work for LPF...

May 29, 2018
8:33 am
Avatar
Malcolm rest
Member
Members
Forum Posts: 9
Member Since:
April 2, 2018
sp_UserOfflineSmall Offline

<img alt="" src="https://image.ibb.co/n4KScd/HPF_FR.pngImage Enlarger" />

May 29, 2018
11:31 am
Avatar
W Pirkle
Admin
Forum Posts: 261
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

Yes this is actually the correct result. The one-pole filter works fine to implement a low-pass variety and produces a finite gain at Nyquist. 

A 1st order HPF, analog or digital, necessarily requires a zero at DC to pull the DC response all the way down to nothing at 0Hz. The one-pole HPF does not have this zero and therefore will never be able to do much more than make a bit of a LF shelf. 

I should note that Figure 6.2 is erroneous. It was not supposed to go along with the one-pole LPF. It was supposed to go with the 1st order BZT LPF instead (I'm working on a new edition that fixes this). The one-pole LPF does not have a zero at Nyquist so its response is actually closer to that of an analog filter. Likewise, the one-pole HPF does not have a zero at DC that it requires. Both of those are actually very early audio filter designs and in my new edition I am actually omitting the HPF version as it doesn't have that required zero.

- Will

May 29, 2018
8:09 pm
Avatar
Malcolm rest
Member
Members
Forum Posts: 9
Member Since:
April 2, 2018
sp_UserOfflineSmall Offline

Thanks Will. Well explained.

 

So, I could achieve the desired HPF by implementing an LPF and subtracting its output from the original signal. Something like:

 

Yout = Xin - Ylpf

 

Could there be a simpler solution to the desired filter?

Forum Timezone: America/New_York

Most Users Ever Online: 55

Currently Online:
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 48

Derek: 46

Frodson: 43

Peter: 41

clau_ste: 39

Gwen: 32

JimmyM: 30

TheSmile: 28

EZB: 24

lppier: 23

Member Stats:

Guest Posters: 1

Members: 527

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 31

Topics: 552

Posts: 2168

Newest Members:

Steve Duell, Cal, LamebrainEddy, SteveThackery, rawbirdtoe, Bill, hill william, NAUN_SONAR, sufy, Diane

Moderators: W Pirkle: 261

Administrators: Tom: 67, JD Young: 80, Will Pirkle: 0, W Pirkle: 261