- Your low pass should be higher - probably 40 or so.
- Your high pass can be higher - around thirty
- Your gain should be variable else you will amplify it into distortion - what you want is called normalisation. You will need to find the maximum volume of your signal and calculate a scaling factor that will bring this up to full scale. (Say full scale is 1.0 and your maximum value is 0.01 then multiply all samples by 100.)
When I experiment with heart sounds, I find the beat itself to be around 34Hz - I usually do a band pass from 30 to 40 in order to isolate just the beat.
If you do this, you will have a clean recording of ONLY the heartbeat. If all you want is to count heartbeats or listen to them you will be fine. If you need to listen for heart defects or other things, then you will need to change the parameters. You will need higher frequencies and a wider bandwidth for those types of things.
One other thing you need to consider: 30 to 40 Hz doesn't really come through headphones and ears all that well. Even when you isolate the hearbeat and amplify it to full scale, it is still hard to hear. Earphones will attenuate it some, and your ears even more so.
As to actually doing the filtering:
- You can use IIR filters at higher orders to isolate the heart sounds. Avoid using chebyshev filters, though. The "ring" badly and can make one beat "smear" into the next.
- If you use an FIR, you may want to downsample first. It depends on your sampling rate. If your sampling rate is high (say the typical 44100) then an FIR than can bandpass something around 30Hz will have to be VERY long. If you downsample to 1000 Hz, then shorter filters can be used. You could get away with maybe 100 taps at 1000Hz. Downsampling consists of doing a low pass filter to remove everything above half of your new sampling rate, then "throwing away" a lot of your samples - downsampling by two would throw away every second sample, downsampling by 4 keeps one out of four samples.
When I do audio in Java, I usually import libpd, and use pd to develop the actually processing stuff. Then the same pd "patch" can be used with libpd in the java programm.
pd libpd
The order in which you apply the filters (for your bandpass) shouldn't matter.