我使用AudioRecord和AudioTrack播放从麦克风到扬声器的声音输出。但是实时播放会产生声音回声。我只需要播放MIC声音而不是播放的声音系统(在这种情况下是第二次播放的MIC AudioTrack)。
recorder = new AudioRecord(AudioSource.MIC, 44100,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT, N * 2);
track = new AudioTrack(AudioManager.STREAM_MUSIC, 44100,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, N * 2,
AudioTrack.MODE_STREAM);
如何在Android中隔离麦克风声音输出并播放它而不播放整个Android声音(在Android设备中播放的其他声音,例如音乐播放器播放的音乐,通知声音等)
PS:在对this stackoverflow qs's comment by hotpaw2 进行一些研究后发现了这条评论:
The latency on most Android devices between record and play is reported to be fairly high, such that the user would hear a delayed echo unless isolated from any sound going into the mic.