When I use Androids AudioRecord to record from the microphone, I get this annoying artifact
Is there a way to avoid or remove this? What is it? Or do I get that because I did something wrong in the configuration (but everything else works fine).
Here is my AudioRecord configuration:
sampleRateInHz = 44100;
channelConfigRec = AudioFormat.CHANNEL_IN_MONO;
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
bufferSizeInBytesRec = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfigRec, audioFormat);
audioSource = AudioSource.MIC;
I am pretty sure that my code is right, because I can record everything fine, but there is this click at the beginning.
Try setting your audioSource to AudioSource.VOICE_RECOGNITION. On some devices, particularly HTC devices, I have found that there is less filtering going on with that source. And with ICS and after that's the official way things are supposed to be.In the Android 4.0 device compatibility document this is formalized:
When an application has started recording an audio stream using the android.media.MediaRecorder.AudioSource.VOICE_RECOGNITION audio source:
I think that the artifact shown is side effect of a digital filter that is being used to process recorded audio. Every digital filter has a certain delay. For example, if filter has N coefficients, it's delay is N/2. Essentially, that means that filter is going to start behaving normal after first N/2 samples of audio signal have passed through it. This should be the reason for the artifact you are having. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With