Reputation: 193
I am currently writing an app that shows how loud the user is. I currently have it recording the sound when they press record using MediaRecorder
and then allowing them to listen to that recording again by pressing play, this uses MediaPlayer
.
I now want to some how output how loud the noise was that they recorded. Due to using the MediaRecorder
I am trying to retrieve the loudness through.getMaxAplitude()
. Using this I am then trying to display it in a textview so the user can see their results.
Therefore in doing this I have the current code in the begin recording function is
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(OUTPUT_FILE);
recorder.prepare();
recorder.start();
int test = recorder.getMaxAmplitude();
txtView.setText(test);
As you would have already guessed this doesn't work, the recording the audio does work but acquiring or showing the amplitude to the user isn't
Any ideas?
Upvotes: 1
Views: 7089
Reputation: 2100
Probably you can take a view on the stackoverflow post here.
Also a similar kind of project is available in code.google.com
Upvotes: 3