Question about digital filter in legacy application

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

I am supporting a legacy application written in C++. The application includes source code for a digital filter. I am trying to understand what type of digital filter this is and what its characteristics are. I am functionally illiterate when it comes to digital filters and the math involved.

I have the original source code (i.e. C++ class) used as a proof of concept. There are only 139 lines of code in the class and the Wide Open License (WOL) copyright is credited to Grant R. Griffin (2000). If this might be of any assistance, I have found a number of blog posts by Grant Griffin. The only information about the filter in the source code is the following comment:
The digital filter used in this application is a FIR (Finite Impulse Response) filter.
The filter is designed using windowing method. Using Hamming window, the minimum stop
band attenuation of the filter is 54 dB and its transition bandwidth is 6.64FN/ N,
where FN is the maximum system frequency and where N is the filter order.
My question is as follows. Can anyone recommend a forum or newsgroup where I can post the source code for the purposes of determining what type of filter this is and its characteristics (e.g. roll-off and slope)?

Note that I have cross posted this question in a DSPRelated.COM forum and will close both of my posts (here and there) as soon as I am able to move forward on this issue.

thanks,

John

Post

Chances are high it's just this http://www.dspguide.com/CH17.PDF

Also described here if you prefer more theoretical content: https://ccrma.stanford.edu/~jos/sasp/Wi ... ilter.html
~stratum~

Post

Given the code in the reference you provided, only line 330 is similar. The following appears in the proof of concept code I have:
oCoef[n] = oCoef[n] * (0.54 - 0.46*cos(2 * PI*n / (iNumCoef - 1)));

Unfortunately, I am not able to make much sense of chapter you referenced.

I have attached the proof of concept code to this post. I created the Visual Studio solution/project files while the original code is contained in the file 'main.cpp', 'digitalfilter.cpp' and 'digitalfilter.h'. In the C++ file 'digitalfilter.cpp', line number 51 resembles line Basic source code in line 330 of Table 17-1 in the ch17.pdf reference you provided.

Would you be able to take a look at the function 'CDigitalFilter::initFilter()' in the file 'digitalfilter.cpp' and tell me if this is in fact a custom filter?

Thanks,

John
You do not have the required permissions to view the files attached to this post.

Post

Isn't most of the info you need right there in the header file?

Code: Select all

/*
The digital filter used in this application is a FIR (Finite Impulse Response) filter. 
The filter is designed using windowing method. Using Hamming window, the minimum stop 
band attenuation of the filter is 54 dB and its transition bandwidth is 6.64FN/ N, 
where FN is the maximum system frequency and where N is the filter order. [1]

	Comparing to IIR (Infinite Impulse Response) filters, the FIR filters have the property 
	of being ìlinear phaseî which means that the input signal is delayed but not distorted 
	in phase. [2] Also, the FIR filters are less intensive computationally, and they have 
	many desirable numerical properties which allow the FIR filters to be implemented using 
	fewer bits than IIR filters. [2]

	References:

	[1]	http://www.dsptutor.freeuk.com/FIRFilterDesign/firfdes.htm
	[2]	http://www.dspguru.com/info/faqs/fir/basics.htm
*/
Confucamus.

Post

If the information is in the header file then I do not know how to translate that into the information I need. For example, does this filter have a name (e.g. Butterworth or Elliptic) and, if so, what is it? What is it's slope, it's half-amplitude cutoff, etc.? In other words, how would I describe this filter to someone else so they would know exactly what the filter is and how it works.

Post

[deleted]

(need to look at this again, it's two windowed sinc filters like sinc(high_f*x)-sinc(low_f*x), but I'm not sure what the purpose of subtracting the results from two lowpass filters might be).
~stratum~

Post

John1234567890 wrote: Mon Feb 11, 2019 5:09 am does this filter have a name (e.g. Butterworth or Elliptic) and, if so, what is it?
The author named it already: FIR with double window.
What is it's slope, it's half-amplitude cutoff, etc.?
You should be able to measure this. Feed it a sine sweep and analyse the output.
In other words, how would I describe this filter to someone else so they would know exactly what the filter is and how it works.
Do you really need to? Can't you get away with treating it as a black box? If it works as designed (or fit to the purpose) you do not need to dive into its inner workings. Right? Or is there a need to change / tweak it?
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

If phase responses from two lowpass filters are close enough in the frequency band [0..low_f], the frequency band [0..low_f] would be cancelled out leaving a bandpass filter for [low_f..high_f].

That's a guess. you can figure out what it really is by processing a single sample with that filter (that gives its impulse response) and take FFT of the result (and that gives its frequency and phase responses).
~stratum~

Post

For example, does this filter have a name (e.g. Butterworth or Elliptic) and, if so, what is it?
yes - it's called "windowed-sinc" filter. see here for more details:
http://www.dspguide.com/ch16/1.htm
What is it's slope, it's half-amplitude cutoff, etc.?
these types of filters are not typically described in these terms. the frequency response will look like the ideal lowpass brickwall filter convolved with the spectrum of the chosen window, which is a Hamming window in this case:

https://en.wikipedia.org/wiki/File:Wind ... 53836).svg

instead of slope, it makes more sense to talk about transition width, passband ripple and stopband rejection - which are precisely the parameters that the author has already given you in the documentation. well, it will have a cutoff frequency of course - but i'm not sure if that's supposed to be measured at the half-amplitude point in this case. sometimes, it may be defined as the frequency, at which the passband ripple passed through its minimum ripply value the last time before it goes downward into the stopband. (normally, you measure the cutoff actually at the half-power point anyway - which the square-root of the half amplitude...so, the cutoff is typically defined to be the freq where the amplitude is 1/sqrt(2))
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Hello KVRAF,

First, a chuckle! My reaction to your response was comparable to a deer in a head light...say what???? I am grappling with a topic I've know nothing about.

1) As per your earlier response, I have been asked for a description of this filter. Unfortunately, it is not enough that "it just works".

2) I'll try reading your reference chapter 16 and see if I can make any sense of it.

3) You wrote, "it makes more sense to talk about ..."

3a) Given the sampling rate in the sample code is 256Hz, does this mean the "maximum system frequency" is 128Hz?

3b) Given the number of coefficients in the sample code is 101 does this mean the "filter order" is 101 (or is it 50)?

3c) If the formula for the transition bandwidth is 6.64FN/N then, for the sample provided, does the transition bandwidth compute to to 8.42 (i.e. 6.64 * 128 / 101)?

3d) If the transition bandwidth is 8.42 then does this mean the digital filter transitions from the passband range to the stopband range in 8.42 data samples? Or, does this refer to the frequency response graph where the transition from passband to stopband range occurs in 8.42Hz?

A big thanks for helping out.

Post

This thread can be closed as I have obtained all the information I require. I would like to again thank all of you that took the time to response to my request of assistance.

Best regards,

John

Post Reply

Return to “DSP and Plugin Development”