I am trying to develop an application similar to iRig for Android, so the first step is to capture the microphone input and play it at the same time.
I have it, but the problem is that I get some delay that makes it unusable, and if I start to process the buffer, I am afraid that it will become completely unusable.
I use audiorecord and audiotrack as follows:
new Thread(new Runnable() { public void run() { while(mRunning){ mRecorder.read(mBuffer, 0, mBufferSize);
And the tactics:
// ==================== INITIALIZE ========================= // public void initialize(){ mBufferSize = AudioRecord.getMinBufferSize(mHz, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); mBufferSize2 = AudioTrack.getMinBufferSize(mHz, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); mBuffer = new byte[mBufferSize]; Log.v("MY AMP","Buffer size:" + mBufferSize); mRecorder = new AudioRecord(MediaRecorder.AudioSource.MIC, mHz, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, mBufferSize); mPlayer = new AudioTrack(AudioManager.STREAM_MUSIC, mHz, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, mBufferSize2, AudioTrack.MODE_STREAM); }
Do you know how to get a faster response? Thanks!
Jordi Puigdellívol
source share