Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad sound quality when recording/playing sounds - Android SDK

I have a problem, when I try to record and then play the file that was just recorded. I can both record and play the sound but the quality stinks. Its not just bad is really hard to listen to and sound a bit like its a computer generated voice. I use the andriod SDK-emulator. The code that sets up the recording looks like this;

MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();

And the code playing the file later looks like this;

MediaPlayer mp = new MediaPlayer();
mp.reset();
mp.setDataSource(path);
mp.prepare();
mp.start();

I don't know what part that makes the audio file sound really bad or if its just the emulator that makes it bad and that it would work on a real phone.

like image 973
Nick3 Avatar asked Oct 16 '10 19:10

Nick3


People also ask

How can I improve the sound quality of a recorded android?

Over on Android, Titanium Recorder (Android only, free with ads) provides one of the most complete solutions for sound capture. Tap the menu button (three dots) on the top right and go to Settings. Here, you can adjust the sample rate, bit rate, and gain to capture as much detail as possible for your recorded audio.

What factors affect audio quality?

The sound quality of a reproduction or recording depends on a number of factors, including the equipment used to make it, processing and mastering done to the recording, the equipment used to reproduce it, as well as the listening environment used to reproduce it.


1 Answers

Try these

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);   
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);     
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);   
recorder.setAudioChannels(2);
recorder.setAudioEncodingBitRate(128);
recorder.setAudioSamplingRate(44100);

Incase if you find this code crash on low end android devices then try removing setAudioChannels and setAudioSamplingRate.

like image 151
Mohit marwal Avatar answered Oct 02 '22 18:10

Mohit marwal