javaandroidtarsosdsp

TarsosDSP Android applying lowpass filter and saving to wav gives choppy results


I am using TarsosDSP library to apply a low pass filter on a wav file. Here is the code.

private void eq2(File file) throws FileNotFoundException {
    new AndroidFFMPEGLocator(this);

    InputStream inputStream = new FileInputStream(file);
    TarsosDSPAudioFormat format =  new TarsosDSPAudioFormat(16000,16,2,true,false);
    AudioDispatcher adp = new AudioDispatcher(new UniversalAudioInputStream(inputStream,format),2048,0);

    adp.addAudioProcessor(new LowPassFS(100,16000));
    RandomAccessFile raf = null;
    raf = new RandomAccessFile(Environment.getExternalStorageDirectory()+ "/cibiodLogs/audioFiltered1.wav", "rw");
    adp.addAudioProcessor(new WriterProcessor(format,raf));
    adp.run();

    Thread audioThread = new Thread(adp, "Audio Thread");
    audioThread.start();
}

It gives output but the output is choppy and not even filtered. Here take a look at the original wav file and the output wav file.

Original

Filtered

I have tried different buffer sizes from 2 - 4096 but every time either the output is choppy or the audio is not filtered. Can someone point me what might be going wrong here.


Solution

  • This issue is solved now! The TarsosDSP does not support dual-channel audio processing so the algorithm was getting confused with two channels of audio and thus giving the choppy results.