开发者

audio recording in android

I have and android emulator and microphone connected to my pc. I want to capture pcm pulses from microphone (i.e. record voice) and then send to udp socket. please anybody help me in source cod开发者_运维百科e at least for voice recording.


You can use this code for your audio recording:

MediaRecorder recorder;

void startRecording() throws IOException 
{
SimpleDateFormat timeStampFormat = new SimpleDateFormat(
    "yyyy-MM-dd-HH.mm.ss");
String fileName = "audio_" + timeStampFormat.format(new Date())
    + ".mp4";
recorder = new MediaRecorder();  
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
recorder.setOutputFile("/sdcard/"+fileName);
recorder.prepare(); 
recorder.start();
}

protected void stopRecording() {
recorder.stop();
recorder.release();
}


Check Audalyzer, a sample application showing you how to read the raw audio stream from the microphone on real time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜