Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 11-03-2009, 05:49 AM   #1
Junior Member
 
Join Date: Nov 2009
Posts: 1
Friends: 0
View rag13's Profile   View rag13's Photo Album   View rag13's Blog   View Social Groups
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 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting issue while access contacts of android rishabh Android Games And Applications 0 09-22-2009 05:43 AM
Error uploading audio Files vikram.patil Android Development, Answers, Tutorials, and Code Snippets 0 06-29-2009 09:55 PM
3.5mm stereo audio connector gaborg Android Hardware 7 02-09-2009 02:13 AM
Bluetooth audio pft573 Android Hardware 1 12-24-2008 11:13 PM
Streaming Audio/a challenge wbexpress Android Development, Answers, Tutorials, and Code Snippets 2 11-20-2008 04:16 PM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 04:39 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2012 TalkAndroid.com. All rights reserved.