Ok disregard that last one. I see you have "Size" set to 320. And you are using that to write to AudioTrack. Like I said, AudioTrack write will block until it's buffer is full, you have declared it as 4096.
-niko On Nov 3, 8:24 am, niko20 <[email protected]> wrote: > Also noticed in your code you are doing SizeSoFar +=. That is not > good. You will overrun the buffer eventually I think... > > On Nov 3, 6:46 am, raghu <[email protected]> wrote: > > > Hi, > > i am using android SDK 1.5, below is the code where i am recording > > voice from mic and playing it. > > > problems i am facing are : > > voice quality is not good, > > some background voice is there, > > write is getting blocked. > > > i have set the permission in .xml file also like : > > android.permission.INTERNET, > > android.permission.MODIFY_AUDIO_SETTINGS, > > android.permission.RECORD_AUDIO, > > android.permission.WRITE_SETTINGS > > > help required > > > below is the code : > > to record the audio i am using read() and to play write() is being > > called. > > is my code correct ? > > > public void onCreate(Bundle savedInstanceState) > > { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > > byte[] Buffer = new byte [80000] ; > > > int Size = 320 ; > > int BuffLen = 1 ; > > int SizeSoFar = 0 ; > > int MinBuffSize ; > > int Written = 0 ; > > int temp = 0 ; > > > AudioRecord audioRecord = new AudioRecord > > (MediaRecorder.AudioSource.MIC, 8000, > > > AudioFormat.CHANNEL_CONFIGURATION_MONO, > > AudioFormat.ENCODING_PCM_16BIT, 4096) ; > > audioRecord.startRecording () ; > > > MinBuffSize = AudioRecord.getMinBufferSize(8000,2,2); > > > AudioTrack track = new AudioTrack (AudioManager.STREAM_MUSIC, > > 8000, > > > AudioFormat.CHANNEL_CONFIGURATION_MONO , > > AudioFormat.ENCODING_PCM_16BIT, > > 4096, AudioTrack.MODE_STREAM) ; > > > track.play() ; > > > while (BuffLen != 0) > > { > > SizeSoFar += audioRecord.read (Buffer, 0, Size) ; > > > Written = track.write (Buffer, 0, Size) ; > > try > > { > > Thread.sleep (5) ; > > } > > catch (InterruptedException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace() ; > > } > > } > > audioRecord.stop() ; > > track.stop() ; > > } > > > help required . > > > logcat message are : > > > D/AudioHardware( 556): AudioStreamInGeneric::set(0xad68, 7, 1, 1, > > 8000) > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408180, 320) > > from fd 7 > > D/AudioHardware( 556): AudioStreamInGeneric::read(0x40408040, 320) > > from fd 7 > > W/AudioFlinger( 556): AudioRecordThread: buffer overflow -- You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en

