Hi ,

Try to do recorder.stopRecording() at the end of record.

Regards,
Sandeep
On 5/8/12, ron simon <beachboy2...@googlemail.com> wrote:
> Hi,
> I want to create an recorder and take the buffer to play the sound but it
> doesn't work. I have no idea for my misstake and hope for your help ;)
>
>
>
> public class input {
> private static final String TAG = "Aufnahme";
> private AudioRecord recorder = null;
> private boolean isRecording = false;
> private int SAMPLERATE = 8000;
> private int CHANNELS = AudioFormat.CHANNEL_CONFIGURATION_MONO;
> private int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
> private int bufferSize = AudioRecord.getMinBufferSize(SAMPLERATE, CHANNELS,
> AUDIO_FORMAT);
> private Thread recordingThread = null;
>
> public void startRecording() {
> recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, SAMPLERATE,
> CHANNELS, AUDIO_FORMAT, bufferSize);
>
> recorder.startRecording();
> isRecording = true;
>
> recordingThread = new Thread(new Runnable()
>
> {
> public void run() {
> writeAudioData();
> }
>
> });
> recordingThread.start();
>
> }
>
> public void stopRecording() {
> isRecording = false;
> recorder.stop();
> recorder.release();
> recorder = null;
> recordingThread = null;
> }
>
> private void writeAudioData() {
>
> byte data[] = new byte[bufferSize];
>
> while (isRecording) {
>
> recorder.read(data, 0, bufferSize);
> send(data);
>
> }
> }
>
> private void send(byte[] data) {
>
> int minBufferSize = AudioTrack.getMinBufferSize(8000,
> AudioFormat.CHANNEL_CONFIGURATION_MONO,
> AudioFormat.ENCODING_PCM_16BIT);
>
> AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 8000,
> AudioFormat.CHANNEL_CONFIGURATION_MONO,
> AudioFormat.ENCODING_PCM_16BIT, minBufferSize,
> AudioTrack.MODE_STREAM);
>
> at.play();
> at.write(data, 0, bufferSize);
> at.stop();
> at.release();
>
> }
>
> }
>
> --
> 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

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