I am trying to filter specific frequencies from android stereo audio (recorded using AudioRecord) using TarsosDSP library(and also minim Android library but code for that is not included here).
There are 2 problems I want suggestions for.
- When I apply only bandpass filter on the float buffer data from microphones then the otuput contains 2 undesired frequencies only and not the one specified in bandpass. For example, when the center frequency of bandpass is 12000Hz and bandwidth is 20Hz, then the output contains frequencies centered at 5000Hz and 16000Hz. No other frequencies are present. Any ideas on what is happening here?
- When I apply either low-pass or high-pass filters from TarsosDSP library, then the output data is not filtered at all. Looks like the filter is not working at all.
Below is the code for both the problems.
float bandPassCentreFreq = 10000,
bandPassWidth = 20;
BandPass bandPass=new BandPass(bandPassCentreFreq, bandPassWidth, (float) RECORDER_SAMPLERATE);
TarsosDSPAudioFormat audioFormat = new TarsosDSPAudioFormat((float)RECORDER_SAMPLERATE,16,2,true,false);
AudioEvent audioEvent = new AudioEvent(audioFormat);
//readings shorts data and splitting to 2 channels from the mic of the smartphone (I am using a stereo recording)
recorder.read(sData, 0, BufferElements2Rec);
for (int i = 0; i < BufferElements2Rec; i++) {
if (i % 2 == 0)
camcorderData[i / 2] = sData[i];
else
micData[(i - 1) / 2] = sData[i];
}
//apply the bandpass filter to the recorded data
float[] camFloat = Utils.short2Float(camcorderData);
float[] micFloat = Utils.short2Float(micData);
//Apply filter to first channel data
audioEvent.setFloatBuffer(camFloat);
bandPass.process(audioEvent);
camFloat=audioEvent.getFloatBuffer();
//Apply filter to second channel data
audioEvent.setFloatBuffer(micFloat);
bandPass.process(audioEvent);
micFloat=audioEvent.getFloatBuffer();
//convert data back to the shorts form
camcorderData = Utils.float2Short(camFloat);
micData = Utils.float2Short(micFloat);
The output of the above bandpass filter looks like as following .
I was hoping to see only the specified bandpass frequency but it shows 2 totally undesired frequencies. Any idea about what's going on here?
P.S. - I am new to Signal Processing thing.