Home > Back-end >  Questions about Java TargetDataLine recording
Questions about Java TargetDataLine recording

Time:12-06

I now have a microphone, it has two channels, I need to make the two channels can be simultaneously recording, how to write
 
AudioFormat audioFormat1=new AudioFormat (AudioFormat. Encoding. PCM_SIGNED, 16000, 1, 2, 16000, false);
AudioFormat audioFormat2=new AudioFormat (AudioFormat. Encoding. PCM_SIGNED, 16000, 8, 2, 2, 16000, true);

TargetDataLine d1=AudioSystem. GetTargetDataLine (audioFormat1);
D1. The open ();
D1. Start ();

TargetDataLine d2=AudioSystem. GetTargetDataLine (audioFormat1);
D2. The open ();
D2. Start ();


So write, on the microphone in d1, to get d2, d2 throws an exception, don't get resources,

 
AudioFormat audioFormat1=new AudioFormat (AudioFormat. Encoding. PCM_SIGNED, 16000, 1, 2, 16000, false);
AudioFormat audioFormat2=new AudioFormat (AudioFormat. Encoding. PCM_SIGNED, 16000, 8, 2, 2, 16000, true);

DataLine. Info Info=new DataLine. Info (TargetDataLine. Class, new AudioFormat [] {
AudioFormat1 audioFormat2, audioFormat1
}, AudioSystem NOT_SPECIFIED, AudioSystem NOT_SPECIFIED);

TargetDataLine targetDataLine1=(TargetDataLine) AudioSystem. GetLine (info);


So I write, however, finally only AudioFormat list at the end of the channel of an object can use the


Have a great god know why this is, to solve
  • Related