title: How do you extract MFCC data from file using TarsosDSP?
body: <p>I created an MFCC extraction portion of my code based on this <a href="https://stackoverflow.com/questions/40436075/how-to-get-mfcc-with-tarsosdsp">example</a> on Stack Overflow, which created two <code>AudioProcessor</code> instances. However, using the debugger on Android studio, I found that the code quickly enters the <code>processingFinished</code> function while it skipped the process function for both. The <code>mfcc</code> variable in the instance was left null during the <code>processingFinished</code> function of the second AudioProcessor function. Why does the data never process? Is this the right way to get the MFCC?</p>
  
  <p>My source code: (I changed theAudioDispatcher to pipe from file)</p>
  
  <pre><code>private void onMFCC() {
  
      int sampleRate = 44100;
      int bufferSize = 1024;
      int bufferOverlap = 128;
      //final AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050,1024,512);
      String path = getExternalCacheDir().getAbsolutePath() + "/saytest.mp4";
      new AndroidFFMPEGLocator(this);
      final AudioDispatcher dispatcher = AudioDispatcherFactory.fromPipe(path, sampleRate, bufferSize, bufferOverlap);
      final MFCC mfcc = new MFCC(bufferSize, sampleRate, 40, 50, 300, 3000);
  
      dispatcher.addAudioProcessor(mfcc);
      dispatcher.addAudioProcessor(new AudioProcessor() {
  
          @Override
          public void processingFinished() {
  
              //vvv error b/c mfcc instance variable is null
              //float[] mfccArr = mfcc.getMFCC();  
              System.out.println("DONE");
          }
  
          @Override
          public boolean process(AudioEvent audioEvent) {
              // breakpoint or logging to console doesn't enter function
              return true;
          }
      });
      dispatcher.run();
  
  }
  </code></pre>
  
  <p>Is there is a possibility that an error because of the pipe AudioDispatcher had to do with this?</p>
  
  <pre><code>Starting piped decoding process for /storage/emulated/0/Android/data/com.example.audiorecorder/cache/saytest.mp4
  I/PipeDecoder:  with command: "/data/user/0/com.example.audiorecorder/cache/ffmpeg" -ss 0.0   -i "/storage/emulated/0/Android/data/com.example.audiorecorder/cache/saytest.mp4" -vn -ar 44100 -ac 1 -sample_fmt s16 -f s16le pipe:1
  I/PipeDecoder: CANNOT LINK EXECUTABLE "/data/user/0/com.example.audiorecorder/cache/ffmpeg": /data/data/com.example.audiorecorder/cache/ffmpeg: has text relocations
  I/PipeDecoder: Aborted 
  I/PipeDecoder: Finished piped decoding process
  </code></pre>
  
  <p>Any help will be appreciated. Thank you so much!</p>
  
  <p><strong>EDIT:</strong>
  I tried calling the process function independently by adding this line to the end of the method:</p>
  
  <pre><code>mfcc.process(new AudioEvent(new TarsosDSPAudioFormat(sampleRate, bufferSize, 1, true, true)));
  </code></pre>
  
  <p>However, this gave me a NullPointerException.</p>
  
  <ul>
  <li>I also compared the mfcc instances using two different audio files but I found that they had the exact same data, so they had no results from processing. When I changed the dispatcher back to the microphone, the mfcc had a value and the program went through the process function! Why doesn't it work for the dispatcher accessing an audio file?</li>
  </ul>