stream from microphone, add effect and save to wav file using tarsos android library

萝らか妹 提交于 2019-12-04 17:02:48

Solved, you need to use the writer function, and not bother with any of the methods needed to save a wav file from the android.media import functions, this is the working code segment from the startRecording method I changed:

if (running == 4) {//start recording from mic, apply bandpass filter and save as wave file using TARSOS library
        dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(RECORDER_SAMPLERATE, bufferSize, 0);
        AudioProcessor p = new BandPass(freqChange, tollerance, RECORDER_SAMPLERATE);
        dispatcher.addAudioProcessor(p);
        isRecording = true;
        // Output
        RandomAccessFile outputFile = new RandomAccessFile(getFilename(), "rw");
        TarsosDSPAudioFormat outputFormat = new TarsosDSPAudioFormat(44100, 16, 1, true, false);
        WriterProcessor writer = new WriterProcessor(outputFormat, outputFile);
        dispatcher.addAudioProcessor(writer);
        recordingThread = new Thread(new Runnable() {
            @Override
            public void run() {
                dispatcher.run();
            }
        }, "Crowd_Speech Thread");
        recordingThread.start();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!