cwbusacker
cwbusacker

Reputation: 517

MediaPlayer/MediaRecorder Sound Quality Awful?

I'm trying to develop a recording device, but when I play it back it sounds awful. It's all gargled and sounds like I'm really far away.

Here is the code. I've looked at trying to change the Encoder, bit rate, and sampling rate, but nothing seems to fix the gargle. I've looked around for other posts on this problem, but haven't found anything. Anyone help?

Also, I realize this is two different objects, but I'm not sure how to check if it's the recorder or the player that's the issue. Ideas on that would be nice too!

MediaRecorder mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
mRecorder.setAudioEncodingBitRate(1280);
mRecorder.setAudioSamplingRate(4400);
mRecorder.setOutputFile(_audioFilename);


MediaPlayer media = new MediaPlayer();
try {
        media.setDataSource(task.getAudio());
    } catch (IOException e) {
        e.printStackTrace();
    }
try {
        media.prepare();
    } catch (IOException e) {
        e.printStackTrace();
    }
    media.start();

EDIT: Download of File https://sites.google.com/site/chasebusackersfilecabinet/home/ProxiVoiceOver3.mp4?attredirects=0&d=1

Or Here is it on Youtube (might not work): https://www.youtube.com/watch?v=va0wlupsuPA&feature=youtu.be

Could it just be the emulator?

Upvotes: 1

Views: 149

Answers (2)

user924
user924

Reputation: 12293

very low bitrate was mentioned already but not audio codec:

MediaRecorder.AudioEncoder.HE_AAC - works only with audio + video recording

You should use MediaRecorder.AudioEncoder.AAC if you record only audio

Upvotes: 0

lelloman
lelloman

Reputation: 14183

I think your problem is here

mRecorder.setAudioEncodingBitRate(1280);
mRecorder.setAudioSamplingRate(4400);

The bit rate is the amount of bits per second you would like the audio to be encoded to. For instance, if you wanted your recorded audio file to be ~1MB per second, you should set it to 133333 (1000000 bytes per minute * 8 bits per byte / 60 seconds per minute). This should be a target value for the encoding algorithm, I think that with AAC if you have some room to change that according to your needs and desired quality.

Sampling rate is the amount of frames per second of the playback, usually you want to set it to 44100. That's a default value because humans are able to perceive frequencies up to 20KHz, if you sample the sound at slightly more than 40KHz you would be able to reproduce all the audible frequencies, for humans.

Upvotes: 1

Related Questions