Skip to content

Commit

Permalink
Update audio capture parameters
Browse files Browse the repository at this point in the history
Do not require stereo audio input when setting up audio capture.
  • Loading branch information
AnonymousHacker1279 committed Jan 11, 2025
1 parent 7c536cf commit e913c4b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void openTargetLine(Mixer mixer) throws LineUnavailableException {
if (targetLineInfo instanceof DataLine.Info dataLineInfo) {
AudioFormat[] formats = dataLineInfo.getFormats();
for (AudioFormat format : formats) {
if (format.getChannels() == 2 && format.getSampleSizeInBits() == 16) {
if (format.getSampleSizeInBits() == 16) {
AudioFormat specifiedFormat = new AudioFormat(
format.getEncoding(),
48000,
Expand All @@ -58,9 +58,11 @@ private void openTargetLine(Mixer mixer) throws LineUnavailableException {
2500,
format.isBigEndian()
);

targetLine = (TargetDataLine) mixer.getLine(dataLineInfo);
targetLine.open(specifiedFormat);
targetLine.start();

return;
}
}
Expand All @@ -82,6 +84,7 @@ public byte[] readAudioData() {
if (bytesRead > 0) {
return buffer;
}

return null;
}

Expand Down

0 comments on commit e913c4b

Please sign in to comment.