본문 바로가기
Android

[Android] 오디오 녹음하는 3가지 방법

by CodeDiver 2013. 10. 25.
THE THREE MUSKETEERS OF AUDIO RECORDING FROM ANDROID

Let me introduce you to the three musketeers of audio recording from android os. They are the three ways for recording audio in android. They are


1) Mediarecorder 

Mediarecorder does what it says. It records media. It can be used to record audio from Mic to a file on the sdcard. The recorded audio would be in MPEG4, RAW AMR or 3GP. 

Please note : The example provided along with the documentation does not work. However, there are lots of help on the internet to get the mediarecorder running.

pros :
  • easy to use
  • records audio in compressed format
  • can be used to record voice calls - both uplink and downlink
  • can be used to record speech recognition

cons
  • can not access the audio buffers
  • difficult to process the recorded audio as it would be compresses format.        
  • can not change the sampling rate
  • very little or no control of how the recording happens

2) Audiorecord


Audiorecord API is google's official solution to overcome the limitations of mediarecorder.Audio can be recorded into buffers for post processing. Audiorecord is a java way to record audio and process audio.

pros:
  • records audio as MONO or STEREO
  • various properties for audiorecording like sample size, sample rate, buffersize can be set.
  • the recorded audio is provided in buffers.                

cons:
  • difficult to handle buffers.Unless you know what you are doing. you will lose samples.

3) Audiorecord :- native interface

USAGE :- ( Coming soon... how to build using NDK, sample code and how to use this API )
There is also a native interface - audiorecord that can be used for recording audio. The native interface provides API that can be invoked from c/c++ libraries. These librarires can then be called from Java activity via JNI. Programs using the interface can be compiled with the NDK and used in android applications via JNI.

pros:
  • provides a c/c++ interface to recording
  • the processing is more efficient when done in c/c++ using this API

cos:
  • no documentation is available for this interface
  • google does not official support this interface. 
  • This interface could be removed from future releases without further notification. But has remained for over an year now.

 

[출처] http://mobware4u.com/tutorials/android-audio-recording