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

Add audio processing examples using Biquad and Biquad Chain #2

Open
ruohoruotsi opened this issue Jul 13, 2013 · 9 comments
Open

Add audio processing examples using Biquad and Biquad Chain #2

ruohoruotsi opened this issue Jul 13, 2013 · 9 comments
Assignees

Comments

@ruohoruotsi
Copy link
Owner

Add audio processing examples using Biquad and Biquad Chain, to make it explicit how to integrate the toolkit into an external signal processing chain.

A fully working pd or Max/MSP external would be ideal.

@ruohoruotsi ruohoruotsi self-assigned this Aug 22, 2015
@JoaCHIP
Copy link

JoaCHIP commented Jul 30, 2017

I agree. The example on how to initialize a lowpass filter is great, but - as a novice C++ coder - I'm having serious trouble figuring out how to apply the filter. Obviously I have to call either BiquadChain::processBiquad or BiquadChain::processFourthOrderSections (which one?) but I cannot figure out the syntax to do so.

@ruohoruotsi
Copy link
Owner Author

Ok let me get some examples posted for you, with real audio flowing through, gimme a couple of days!

@yihe1003
Copy link

Would you please kindlly post me some examples of audio processing examples using Biquad and Biquad Chain? i want to implement a equalizer using BiquadChain, Thank you so much!

@ruohoruotsi
Copy link
Owner Author

Hi there, yes I need to get an example going, I haven't been working on this in a while, but I do have some example code, let me test it out and push a PR for you to look at. thanks for your interest!

@Xueqc
Copy link

Xueqc commented Oct 14, 2022

Would you please kindlly post me some examples of audio processing examples also?

@Xueqc
Copy link

Xueqc commented Oct 14, 2022

Could you point out where am I wrong in following code:

#define BUFFER_LEN 1024
#define MAX_CHANNELS 6

vector <Biquad> coeffs;
BiquadChain biquad_chan;

static void process_data (double *data, int count, int channels)
{
biquad_chan.processBiquad(data, data, 1, count, &coeffs[0]);
return ;
}

static void read_write_file (const char *infilename, const char *outfilename)
{
static double data [BUFFER_LEN] ;
SNDFILE *infile, *outfile ;
SF_INFO sfinfo ;
int readcount ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;

if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
{
    printf ("Not able to open input file %s.\n", infilename) ;
    puts (sf_strerror (NULL)) ;
    return;
}

if (sfinfo.channels > MAX_CHANNELS)
{	printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ;
    return;
}
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
{	printf ("Not able to open output file %s.\n", outfilename) ;
    puts (sf_strerror (NULL)) ;
    return;
}

int filterOrder = 8;
double overallGain = 1.0;

Butterworth butterworth;

bool designedCorrectly = butterworth.loPass(44100,  // fs
    500,
    0,
    filterOrder,
    coeffs,
    overallGain);

biquad_chan.resize(coeffs.size());

while \((readcount = sf_read_double (infile, data, BUFFER_LEN))\)
{	process_data (data, readcount, sfinfo.channels) ;
    sf_write_double (outfile, data, readcount) ;
}
sf_close (infile); sf_close (outfile) ;
return;

}

@Xueqc
Copy link

Xueqc commented Oct 14, 2022

The result wav is noise.

@ruohoruotsi
Copy link
Owner Author

Okay, this is an old issue that I previously promised to fix. Let me make an example to share w/ you. I'll also have a look at your code to see what possibly went wrong.

What is the test file that you are using?

@Xueqc
Copy link

Xueqc commented Oct 15, 2022

The test file is your sweep_0_20K.wav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants