0

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 code at least for voice recording.

abc
  • 101
  • 1
  • 6

2 Answers2

2

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();
}
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
  • AudioRecord Class is more suited for the tasks which envolve RAW data processing..... – Amit Feb 23 '12 at 12:41
1

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

Yin Zhu
  • 16,980
  • 13
  • 75
  • 117