audio record and play problem

All your problems with Audio, Video and Images.

audio record and play problem

Postby rag13 » Tue Nov 03, 2009 1:43 pm

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
rag13
Freshman
Freshman
 
Posts: 5
Joined: Wed Oct 07, 2009 4:44 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 8 guests