I am developing application which records voice from mic, currently I am storing recorded audio in wave file but size of wave is becoming an issue.
I came to know that android do not have mp3 decoder is it true? What would I do to store recorded audio in compressed form?
I am using AudioRecord class for recording and don't want to use MediaRecorder.
Using AudioRecord does not give you many options. It stores audio in PCM format only. You can lower size only by setting channel config to CHANNEL_IN_MONO and audio format to ENCODING_PCM_8BIT. Additionally, you can try to extend AudioRecord class and override read() method. Then you must convert audio yourself but that's not recommended.
I know you don't want this but the best option would be refactoring your code to use MediaRecorder. Here is example from reference documentation:
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(PATH_NAME);
recorder.prepare();
recorder.start(); // Recording is now started
...
recorder.stop();
recorder.reset(); // You can reuse the object by going back to setAudioSource() step
recorder.release(); // Now the object cannot be reused
On this site http://developer.android.com/guide/appendix/media-formats.html#core you have nice table presenting all supported formats taking into considerations Android versions. Try these AAC LC, AMR-NB, AMR-WB. Except sizes check the quality.
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