Hi,
I'd like to use the AudioRecord API, but it's not clear to me how it
should be called.  I put a call to the logger in the listener
callback, but don't see an message logged anywhere.  Any pointers?

Thanks,
Ben


import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.util.Log;

public class AudioListener {

  public static final int DEFAULT_SAMPLE_RATE = 8000;
  private static final int DEFAULT_BUFFER_SIZE = 4096;
  private static final int CALLBACK_PERIOD = 4000;  // 500 msec
(sample rate / callback period)
  private final AudioRecord recorder;

  public AudioListener() {
    this(DEFAULT_SAMPLE_RATE);
  }

  private AudioListener(int sampleRate) {
    recorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT,
        sampleRate, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT,
        AudioFormat.ENCODING_DEFAULT, DEFAULT_BUFFER_SIZE);
  }

  public void start() {
    recorder.setPositionNotificationPeriod(CALLBACK_PERIOD);
    recorder.setRecordPositionUpdateListener(new
AudioRecord.OnRecordPositionUpdateListener() {
      @Override
      public void onMarkerReached(AudioRecord recorder) {
        Log.e(this.getClass().getSimpleName(), "onMarkerReached
Called");
      }

      @Override
      public void onPeriodicNotification(AudioRecord recorder) {
        Log.e(this.getClass().getSimpleName(), "onPeriodicNotification
Called");
      }
    });

    recorder.startRecording();
  }

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to