I have an application that records audio, and the quality is poor when I compare it to the built in recorder application.
I tried downloading some other audio recorders, and they are indeed better audio quality than my app.
How can I get the highest quality audio for my application?
Assuming the recording environment is reasonable (i.e. no significant background noise) there are two main factors which will affect the quality of the audio:
For the recording format, if you want maximum quality use a non-lossy format, e.g. Linear PCM, rather than a lossy format, e.g. MP3. If you use
android.media.AudioRecord.AudioRecordthen you can specify the bit-depth and sample rate of the recorded sound data in the constructor:AudioRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)Generally speaking, the higher the sample rate the better the quality. Bit-depth is controlled by the
audioFormatparameter and you can specify eitherAudioFormat.ENCODING_PCM_8BITorAudioFormat.ENCODING_PCM_16BIT. 16bit will generally be higher quality and I imagine most devices will handle this. The maximum sampling rate will vary with the device but you should be able to get 44.1kHz (16bit @ 44.1kHz is standard CD format) as this sample rate is ‘guaranteed’ on all devices (see AudioRecord)In terms of post-processing, you can perform echo cancellation, noise reduction, audio compression, filtering etc on the digital audio samples obtained, but this shouldn’t be necessary to achieve reasonable quality audio.
If you are comparing your recorded audio quality with that of some other applications, you should first make sure you are recording/saving your audio in the same format as the applications you are comparing against. Then any difference is likely to be in the post-processing stage.