Hi,
I'm trying to create a few filters in Flowcode. I assumed that I could simply use the DSP filter component for this but the problem seems to be that using this component, I can only specify the centre and cut-off frequencies. I have an exact gain value in mind and I'm wondering if I need to use any other components instead to create this filter. For example, one of the filters I want to create needs to attenuate by 20dB whereas I have another filter for which I wish to amplify the frequencies by 15dB. I was perhaps thinking about performing a FFT and then multiplying the appropriate frequencies by the magnitude of my desired gain values although using the DSP filter components seems much easier than this! How can I go about doing this?
Thanks, any help would be appreciated.
Specifying gain of a filter
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Specifying gain of a filter
Hello,
The Scale component might be more applicable than the filter component. Some help on the DSP components available from here: http://www.matrixtsl.com//wiki/index.php?title=DSP
The Scale component might be more applicable than the filter component. Some help on the DSP components available from here: http://www.matrixtsl.com//wiki/index.php?title=DSP
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Specifying gain of a filter
Hi,
I've had a look over that but how would I apply it to just a narrow set of frequencies like a filter would?
Would it help to say I want to implement biquadratic filters?
I've had a look over that but how would I apply it to just a narrow set of frequencies like a filter would?
Would it help to say I want to implement biquadratic filters?
Re: Specifying gain of a filter
Or it help if I knew the default attenuation of the filter object, is there any way to find this out?
Re: Specifying gain of a filter
Hi there, Jarro,
If you open the DSP filter component properties, and set "Type" to "IIR", and "order" to 2, you will have a biquad! The other properties will change to show you a list of the filter coefficients. You can find a handy biquad coefficent calculator HERE - that will take your desired frequency response and convert to the correct coefficients for the sample rate that
you are using.
If you open the DSP filter component properties, and set "Type" to "IIR", and "order" to 2, you will have a biquad! The other properties will change to show you a list of the filter coefficients. You can find a handy biquad coefficent calculator HERE - that will take your desired frequency response and convert to the correct coefficients for the sample rate that
you are using.
Re: Specifying gain of a filter
Hi,
Thanks for the reply! I'm still confused as to what the gain will be of the filter though. The coefficients are separate values to the gain are they not? This is because like I said I am trying to design one filter with -15dB and another with +20dB.
I should mention as well that I am designing band-pass and band-stop filters.
Update:
I used the coefficient calculator above and put them into a 2 pole IIR filter component in flowcode. I've taken a print screen and attached it to this post of the scope output of the filter. The waveform is really bad. I'm completely stuck here and have tried everything.
Thanks for the reply! I'm still confused as to what the gain will be of the filter though. The coefficients are separate values to the gain are they not? This is because like I said I am trying to design one filter with -15dB and another with +20dB.
I should mention as well that I am designing band-pass and band-stop filters.
Update:
I used the coefficient calculator above and put them into a 2 pole IIR filter component in flowcode. I've taken a print screen and attached it to this post of the scope output of the filter. The waveform is really bad. I'm completely stuck here and have tried everything.
- Attachments
-
- Untitled.png
- (15.48 KiB) Downloaded 3002 times
Re: Specifying gain of a filter
Hi again,
Ouch - that looks nasty! Leave it with me - I've had a quick look at the code behind the component, and something looks a little off to me (some coefficents not used!). I'll check over it with Ben and get back to you - if my hunch is right, we should be able to get this fixed pretty quickly.
Ouch - that looks nasty! Leave it with me - I've had a quick look at the code behind the component, and something looks a little off to me (some coefficents not used!). I'll check over it with Ben and get back to you - if my hunch is right, we should be able to get this fixed pretty quickly.
Re: Specifying gain of a filter
Bingo! My hunch was right - looks like some code was copy/pasted without updating the variable names. (You'd never catch me doing a thing like that, honest!
)
Here's an updated version of the filter component definition... Just copy the file to the "C:\Program Files (x86)\Flowcode 6\components" folder, overwriting the old version. I've not had much time to test this, so please let us know how you get on with it - if the fix is good, we'll make sure it goes into the next official FC6 release.


Here's an updated version of the filter component definition... Just copy the file to the "C:\Program Files (x86)\Flowcode 6\components" folder, overwriting the old version. I've not had much time to test this, so please let us know how you get on with it - if the fix is good, we'll make sure it goes into the next official FC6 release.
Re: Specifying gain of a filter
I've still got a strange waveform but now I think that's down to me! I've replaced the component but I'm still getting a similar waveform. The coefficients are in the screen shot just in case its my bad design that's causing this.
- Attachments
-
- Untitled2.png
- (31.14 KiB) Downloaded 925 times