Does anyone know where I might find a function to do band pass filtering in software? I've been researching it, and a lot of the math is beyond me.
If I can't find something I'll probably try to figure out my own solution using what I know of how to implement low and high pass filters on images, but I'm nor sure how to directly apply that to sounds. Ie, I know how to low pass filter an image with a 64 pixel radius, but I don't know what frequency a low pass filter with a radius of 64 samples would be equivalent to.
Though my best guess is that based on nyquist's sampling theorem if I were playing a sound at 48000hz and I reduced the resolution by half by averaging with a moving window and a radius of 2, that would be equivalent to a low pass filter that filters out everything above 24000hz.
I guess based on that I should be able to calculate precisely how large my window would need to be to low pass filter to any specific frequency. And I guess I would need to do some kind of weighted average to calculate a window of only 1.8 samples for example.
And highpass = original - lowpass. So that's easy enough to calculate I guess...
Then for bandpass, I need to take the original, and pass it through a low pass filter, then a highpass filter.
But the highpass filter in this case would be set to a different frequency than the lowpass filter. So band pass would be something like:
Have a function lowpass() which does weighted windowed average on data based on input data and desired frequency, and returns new data.
Then do this:
tmp = lowpass(original, lowpassfrequency) ' Do lowpass filter on original data.
bandpass = tmp - lowpass(tmp, highpassfrequency) ' Do highpass filter on lowpassed data.
Maybe that would work. My research indicates there's lots of different kinds of lowpass filters though. I have no idea what this sort would be called, or if it will even sound right.