Android AudioRecord artifact
Asked Answered
E

2

5

When I use Androids AudioRecord to record from the microphone, I get this annoying artifact

enter image description here

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.

Effectuate answered 2/10, 2012 at 15:40 Comment(3)
we need to see your code ??? but u can read this maybe help u [prev. answer][1] [1]: #4708494Mazur
This question belongs on SO since it is a developer question. Programming questions are off topic on Android.SE: android.stackexchange.com/…Decompose
@eldarerathis whoops, that's what I get for skimming :)Decompose
A
6

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:

  • Noise reduction processing, if present, MUST be disabled.
  • Automatic gain control, if present, MUST be disabled.
Asymptote answered 11/10, 2012 at 3:13 Comment(2)
For AudioRecord there is no VOICE_RECOGNITION audio source, but now I have an idea what to look for.Effectuate
VOICE_RECOGNITION +100, one option saves me a week.Assign
I
2

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.

Inherited answered 9/10, 2012 at 15:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.