I can't write a file when using WriterProcessor provided by Tarsos. The file exists, and no error is shown. But the file is empty, when I play it, there is no sound.
final Float srf = 44100.0F;
dispatcher = AudioDispatcherFactory.fromPipe(mRecordFile.getPath(), srf.intValue(), bufferSize, 0);
mOutputLowFile = new File(v.getContext().getFilesDir(), mOutputLowFileName);
RandomAccessFile outputFile = null;
try {
outputFile = new RandomAccessFile( mOutputLowFile, "rw");
} catch (FileNotFoundException e) {
Log.i(TAG, "onFFT: FileNotFoundException: " + e);
e.printStackTrace();
}
TarsosDSPAudioFormat outputFormat = new TarsosDSPAudioFormat(44100, 16, 1, true, false);
WriterProcessor writer = new WriterProcessor(outputFormat, outputFile);
dispatcher.addAudioProcessor(writer);
final AudioDispatcher finalDispatcher1 = dispatcher;
Thread recordingThread = new Thread(new Runnable() {
@Override
public void run() {
finalDispatcher1.run();
}
}, "recordingThread Thread");
recordingThread.start();
The outputFile is 1Ko big, whereas the original is 3 Ko.