Thanks for the response.  I'm still foggy on the API usage though.  I
basically want to listen to the mic and continually process the
incoming audio.  Should I be using the OnRecordPositionUpdateListener
at all?

Or should it look something like:
recorder.startRecording()
while(recorder.read(buffer) > 0) {
  doSomething(buffer)
}

When I've done the latter I get buffer overflow exceptions.


On May 15, 3:51 pm, Dave Sparks <[email protected]> wrote:
> You need to call the read() method.
>
> On May 15, 3:15 pm, benmccann <[email protected]> wrote:
>
> > Any ideas?
>
> > Thanks,
> > Ben
>
> > On May 15, 1:02 am, benmccann <[email protected]> wrote:
>
> > > Hi,
> > > I'm trying to figure out how to use theAudioRecordclass.  I created
> > > a callback with a logging message, but don't ever see it called.  Do
> > > you see anything wrong with what I'm doing?  Do you have an example of
> > > how to use the API?
>
> > > 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 finalAudioRecordrecorder;
>
> > >   public AudioListener() {
> > >     this(DEFAULT_SAMPLE_RATE);
> > >   }
>
> > >   private AudioListener(int sampleRate) {
> > >     recorder = newAudioRecord(MediaRecorder.AudioSource.DEFAULT,
> > >         sampleRate, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT,
> > >         AudioFormat.ENCODING_DEFAULT, DEFAULT_BUFFER_SIZE);
> > >   }
>
> > >   public void start() {
> > >     recorder.setPositionNotificationPeriod(CALLBACK_PERIOD);
> > >     
> > > recorder.setRecordPositionUpdateListener(newAudioRecord.OnRecordPositionUpdateListener()
> > >  {
> > >       @Override
> > >       public void onMarkerReached(AudioRecordrecorder) {
> > >         Log.e(this.getClass().getSimpleName(), "onMarkerReached
> > > Called");
> > >       }
>
> > >       @Override
> > >       public void onPeriodicNotification(AudioRecordrecorder) {
> > >         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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to