Implement converting from FLAC to PCM

This commit is contained in:
Bartek Wreczycki
2023-03-08 23:28:43 +00:00
committed by GitHub
parent 0fa1487bd9
commit 3f956f4649

View File

@@ -121,6 +121,12 @@ public class PlayerManager {
AudioInputStream convertedInputStream = new MpegFormatConversionProvider().getAudioInputStream(decodedFormat, inputStream);
finalInputStream = AudioSystem.getAudioInputStream(audioFormat, convertedInputStream);
} else if (getFileExtension(file.toFile().toString()).equals("flac")) {
AudioInputStream inputStream = new FlacAudioFileReader().getAudioInputStream(file.toFile());
AudioFormat baseFormat = inputStream.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getFrameRate(), false);
AudioInputStream convertedInputStream = new Flac2PcmAudioInputStream(inputStream, decodedFormat, inputStream.getFrameLength());
finalInputStream = AudioSystem.getAudioInputStream(audioFormat, convertedInputStream);
}
assert finalInputStream != null;