Friday, November 1, 2013

Can not capture audio the audio when i record it for the second time [android help]


Can not capture audio the audio when i record it for the second time



I am working on an application where, i need to record audio multiple times in a single run. I wrote a code which i got from internet, it capture audio but it is only working for the first time and then it give me error.



line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.



My code for capturing audio is



private void captureAudio() {
try {
//Get everything set up for
// capture
audioFormat = getAudioFormat();
DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);
targetDataLine = (TargetDataLine) AudioSystem.getLine(dataLineInfo);
targetDataLine.open(audioFormat);
targetDataLine.start();

//Create a thread to capture the
// microphone data and start it
// running. It will run until
// the Stop button is clicked.
Thread captureThread = new Thread(new CaptureThread());
captureThread.start();
} catch (Exception e) {
System.out.println(e.getMessage());
//System.exit(0);
}//end catch
}//end captureAudio method


The audio format i am using is :



private AudioFormat getAudioFormat() {
float sampleRate = 8000.0F;
//8000,11025,16000,22050,44100
int sampleSizeInBits = 16;
//8,16
int channels = 1;
//1,2
boolean signed = true;
//true,false
boolean bigEndian = false;
//true,false
return new AudioFormat(
sampleRate,
sampleSizeInBits,
channels,
signed,
bigEndian);
}


Please help me it's urgent. Thank you in advance.



Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...