Skip to content

Instantly share code, notes, and snippets.

@ofZach
Created March 21, 2014 17:34
Show Gist options
  • Save ofZach/9691433 to your computer and use it in GitHub Desktop.
Save ofZach/9691433 to your computer and use it in GitHub Desktop.
small snippet for using DSP filters collection...
// usage for DSP
// https://github.com/vinniefalco/DSPFilters
#include "Dsp.h"
// variables... these filters want a float ** array, so I allocate it like this:
Dsp::Filter* f;
float* audioData[1];
// 4th order, 50 samples to smooth params, 1 channel
audioData[0] = new float[bufferSize];
f = new Dsp::SmoothedFilterDesign<Dsp::Butterworth::Design::BandPass <4>, 1, Dsp::DirectFormII> (50);
Dsp::Params params;
params[0] = 44100; // sample rate
params[1] = 4; // order
params[2] = 440; // center
params[3] = 100; // band width
f->setParams(params);
// assume single channel output, you might have to interleave this if you are doing multichannel output.
void testApp::audioOut(float * output, int bufferSize, int nChannels){
memset(audioData[0], 0,bufferSize*sizeof(float));
// add something to audioData
f->process(bufferSize, audioData);
memcpy(output, audioData[0], bufferSize*sizeof(float));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment