I found some snippets of code on the internet that are really simple signal filters. Unfortunately there wasn't much info to back it up. Using Google I've found similar code, but none of it backed up by research or documentation. I've tried it and it works well enough for my situation.
The low pass filter looks like this:
float RC = 1.0/(CUTOFF*2*3.14);
float dt = 1.0/SAMPLE_RATE;
float alpha = dt/(RC+dt);
float out[numSamples];
out[0] = in[0];
for(i=1; i<numSamples; i++){
out[i] = out[i-1] + (alpha*(in[i] - out[i-1]));
}
And the high pass filter looks like this:
float RC = 1.0/(CUTOFF*2*3.14);
float dt = 1.0/SAMPLE_RATE;
float alpha = RC/(RC + dt);
float out[numSamples];
out[0] = in[0];
for (i = 1; i<numSamples; i++){
out[i] = alpha * (out[i-1] + in[i] - in[i-1]);
}
I'd like to know if there is a name for these algorithms or who invented them so I can find more information about them.