Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BiQuad lowpass filter problem #20

Closed
DigitalPilgrim opened this issue Jul 13, 2020 · 4 comments
Closed

BiQuad lowpass filter problem #20

DigitalPilgrim opened this issue Jul 13, 2020 · 4 comments

Comments

@DigitalPilgrim
Copy link

I have problem with BiQuad lowpass filter.

When I have filter in class for example

class Something
{
public:
     Something();
     q::lowpass filter1;
     q::lowpass filter2;
     void process(float *in, float *out);
}
Something::Something() : filter1(1500.0, 44000), filter2(800.0, 44000, 2.5) {}

it is working as expected, but under same code, when I add another filter in process, filter is not working

void process(float * in, float *out)
{
    // filter created here are not working, they output is not audible
     auto frL = q::lowpass( q::frequency(1500.0), 44000 ); 
     auto frR = q::lowpass{ q::frequency(900.0), (uint32_t)m_sampleRate };

     float L = frL(in[0]); // not audible
     float R = frR(in[1]); // not audible
     L = filter1(in[0]); // working
     R = filter2(in[1]); // working
}
@djowel
Copy link
Member

djowel commented Jul 13, 2020

The filter objects should not be instantiated inside process. Make them member variables. The filters are stateful. Your first code is correct. They should all be a class members.

@djowel
Copy link
Member

djowel commented Jul 13, 2020

BTW, I suggest using c++ literals. E.g. filter1(1500.0_Hz, 44000)

@DigitalPilgrim
Copy link
Author

DigitalPilgrim commented Jul 13, 2020

Aha, thanks.

BTW, I suggest using c++ literals. E.g. filter1(1500.0_Hz, 44000)

Yes, I know, but I am working on realtime application and want change the filter in realtime.

@djowel
Copy link
Member

djowel commented Jul 14, 2020

Aha, thanks.

BTW, I suggest using c++ literals. E.g. filter1(1500.0_Hz, 44000)

Yes, I know, but I am working on realtime application and want change the filter in realtime.

Of course :-)

@djowel djowel closed this as completed Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants