I created an MFCC extraction portion of my code based on this example on Stack Overflow, which created two AudioProcessor
instances. However, using the debugger on Android studio, I found that the code quickly enters the processingFinished
function while it skipped the process function for both. The mfcc
variable in the instance was left null during the processingFinished
function of the second AudioProcessor function. Why does the data never process? Is this the right way to get the MFCC?
My source code: (I changed theAudioDispatcher to pipe from file)
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();
}
Is there is a possibility that an error because of the pipe AudioDispatcher had to do with this?
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
Any help will be appreciated. Thank you so much!
EDIT: I tried calling the process function independently by adding this line to the end of the method:
mfcc.process(new AudioEvent(new TarsosDSPAudioFormat(sampleRate, bufferSize, 1, true, true)));
However, this gave me a NullPointerException.
- 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?