Recipe Recording Audio Files

Recording audio using MediaRecorder is similar to playback from the previous recipe, except a few more things need to be specified (note, default can also be used and is the same as the first choice in these lists):

■ MediaRecorder.AudioSource:

■ voice_uplink—Transmitted audio during voice call

■ voice_downlink—Received audio during voice call

■ V0ICE_CALL—Both uplink and downlink audio during voice call

■ camcorder—Microphone associated with camera if available

■ voice_recognition—Microphone tuned for voice recognition if available

■ MediaRecorder.OutputFormat:

■ three_GPP—3GPP media file format

■ amr_nb—Adaptive multirate narrowband file format

■ MediaRecorder.AudioEncoder:

■ amr_nb—Adaptive multirate narrowband vocoder The steps to record audio are

1. Create an instance of the MediaRecorder: MediaRecorder m_Recorder = new MediaRecorder();

2. Specify the source of media, for example the microphone: m_Recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

3. Set the output file format and encoding, such as: m_Recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); m_Recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

4. Set the path for the file to be saved: m_Recorder.setOutputFile(path);

5. Prepare and start the recording: m_Recorder.prepare(); m_Recorder.start();

These steps for audio recording can be used just as they were in the previous recipe for playback.

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook

Post a comment