Home > Back-end >  Java collection the microphone audio
Java collection the microphone audio

Time:03-13


I when doing the collection and the microphone audio problems, raise the abnormal in the open here, big endian prompt I don't support, but I also will change little endian suggest little endian does not support, please give solutions, thank you, there wasn't enough points, sorry

 
Try {
AudioFormat format=new AudioFormat (8000, 16, 1, true, true);
TargetDataLine TargetDataLine=AudioSystem. GetTargetDataLine (format);
TargetDataLine. Open (the format);
TargetDataLine. Start ();
System. The out. Println (" recording ");
//direct broadcast out
SourceDataLine SourceDataLine=AudioSystem. GetSourceDataLine (format);
sourceDataLine. Open (the format);
SourceDataLine. Start ();
System. The out. Println (" play ");
//the child thread to play
Byte [] b=new byte [1024].//cache audio data
New Thread (new Runnable () {
Public void the run () {
Int a=0;
While (a!=1) {
System. The out. Println (" recorded in ");
A=targetDataLine. Read (b, 0, b.l ength);//capture recording data
If (a!=1) {
SourceDataLine. Write (b, 0, a);//play recorded voice
}
}
}
}).start();
} the catch (LineUnavailableException e) {
e.printStackTrace();
}

 
Javax.mail. Sound. The javax.media.sound.sampled. LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, big endian - not supported.
At com. Sun. Media. Sound. DirectAudioDevice $DirectDL. ImplOpen (DirectAudioDevice. Java: 513)
At com. Sun. Media. Sound. AbstractDataLine. Open (121) AbstractDataLine. Java:
At com. Sun. Media. Sound. AbstractDataLine. Open (153) AbstractDataLine. Java:
At com. MWN. Audio. AudioDemo. GetAudio_A (42 AudioDemo. Java:)
At com. MWN. Audio. AudioDemo. Main (AudioDemo. Java: 14)

 
Javax.mail. Sound. The javax.media.sound.sampled. LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little endian - not supported.
At com. Sun. Media. Sound. DirectAudioDevice $DirectDL. ImplOpen (DirectAudioDevice. Java: 513)
At com. Sun. Media. Sound. AbstractDataLine. Open (121) AbstractDataLine. Java:
At com. Sun. Media. Sound. AbstractDataLine. Open (153) AbstractDataLine. Java:
At com. MWN. Audio. AudioDemo. GetAudio_A (42 AudioDemo. Java:)
At com. MWN. Audio. AudioDemo. Main (AudioDemo. Java: 14)
  • Related