hi all
I want use AudioRecord class to record audio in PCM formate.
after create class and set setRecordPositionUpdateListener, then start
recording.
I can't get any notification from system.
why? please help me, thanks

public class Recorder {
        private static final int AUDIO_SAMPLE_FREQ = 8000;
        private static final int AUDIO_BUFFER_SIZE = 800000;

        private AudioRecord recorder;

        public Recorder()
        {
                try
                {
                        // init recorder
                        recorder = new 
AudioRecord(MediaRecorder.AudioSource.MIC,
                                        AUDIO_SAMPLE_FREQ,
                                        AudioFormat.CHANNEL_CONFIGURATION_MONO,
                                        AudioFormat.ENCODING_PCM_16BIT,
                                        AUDIO_BUFFER_SIZE);
                }
                catch (IllegalArgumentException e)
                {
                        e.printStackTrace();
                }

                recorder.setRecordPositionUpdateListener(mNotification);
                recorder.setPositionNotificationPeriod(50);
                recorder.setNotificationMarkerPosition(AUDIO_SAMPLE_FREQ);
        }

        public OnRecordPositionUpdateListener mNotification = new
                OnRecordPositionUpdateListener(){
                public void onMarkerReached(AudioRecord arg0) {
                        // read PCM buffer
                        byte[] audioBuffer = new byte[AUDIO_SAMPLE_FREQ];
                        arg0.read(audioBuffer, 0, AUDIO_SAMPLE_FREQ);
                }

                public void onPeriodicNotification(AudioRecord arg0) {
                        // read PCM buffer
                        byte[] audioBuffer = new byte[AUDIO_SAMPLE_FREQ];
                        arg0.read(audioBuffer, 0, AUDIO_SAMPLE_FREQ);
                }
        };

        public void StartRecord()
        {
                recorder.startRecording();
        }

        public void StopRecord()
        {
                recorder.stop();
        }

        public void ReleaseRecord()
        {
                recorder.release();
        }
}


--~--~---------~--~----~------------~-------~--~----~
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