我以为我可以在这个很棒的网站上找到任何东西,但是现在我似乎面对这个问题没有答案:)请帮助!
问题是,我需要播放多达6个不同的wav文件,每个文件有1个通道,进入系统混音器支持的6个通道(左,右,环绕左等)。
使用6种不同的SourceDataLines看起来很合逻辑,但是从我看来,Mixer无法对其进行每个样本的同步,因此我想出了将它们交织在单独的线程中并且仅使用一个SourceDataLine进行播放的方法。它适用于左右两个声道,但是对于更多的声道,我需要知道精确的声道布局(在差分系统和声卡上可能有所不同)。我认为系统混音器之一(我有两个:“线性输入”和“java声音系统混音器”)可能具有此元数据,但找不到。
有人知道如何获取此信息吗?
谢谢。
最佳答案
我和我的 friend 刚刚发现java7声音系统支持6个声道,并且它们使用的所有变体都带有不同的位,等等。
这是列出您的Java功能的代码:
Mixer.Info[] mi = AudioSystem.getMixerInfo();
for (Mixer.Info info : mi) {
System.out.println("info: " + info);
Mixer m = AudioSystem.getMixer(info);
System.out.println("mixer " + m);
Line.Info[] sl = m.getSourceLineInfo();
for (Line.Info info2 : sl) {
System.out.println(" info: " + info2);
Line line = AudioSystem.getLine(info2);
if (line instanceof SourceDataLine) {
SourceDataLine source = (SourceDataLine) line;
DataLine.Info i = (DataLine.Info) source.getLineInfo();
for (AudioFormat format : i.getFormats()) {
System.out.println(" format: " + format);
}
}
}
}
这是从我的Macbook Pro带有USB连接的外部声卡的输出:
info: Default Audio Device, version Unknown Version
mixer com.sun.media.sound.DirectAudioDevice@67310bf
info: interface SourceDataLine supporting 14 audio formats, and buffers of at least 32 bytes
format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian
format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian
format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian
info: interface Clip supporting 14 audio formats, and buffers of at least 32 bytes
info: Built-in Input, version Unknown Version
mixer com.sun.media.sound.DirectAudioDevice@2edf98c4
info: Built-in Output, version Unknown Version
mixer com.sun.media.sound.DirectAudioDevice@59a683e6
info: interface SourceDataLine supporting 14 audio formats, and buffers of at least 32 bytes
format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian
format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian
format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian
info: interface Clip supporting 14 audio formats, and buffers of at least 32 bytes
info: SB X-Fi Surround 5.1 Pro, version Unknown Version
mixer com.sun.media.sound.DirectAudioDevice@431d9f05
info: interface SourceDataLine supporting 20 audio formats, and buffers of at least 32 bytes
format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian
format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian
format: PCM_UNSIGNED unknown sample rate, 8 bit, 6 channels, 6 bytes/frame,
format: PCM_SIGNED unknown sample rate, 8 bit, 6 channels, 6 bytes/frame,
format: PCM_SIGNED unknown sample rate, 16 bit, 6 channels, 12 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 16 bit, 6 channels, 12 bytes/frame, big-endian
format: PCM_SIGNED unknown sample rate, 24 bit, 6 channels, 18 bytes/frame, little-endian
format: PCM_SIGNED unknown sample rate, 24 bit, 6 channels, 18 bytes/frame, big-endian
format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian
info: interface Clip supporting 20 audio formats, and buffers of at least 32 bytes
info: SB X-Fi Surround 5.1 Pro, version Unknown Version
mixer com.sun.media.sound.DirectAudioDevice@4db323af
info: Port Built-in Input, version Unknown Version
mixer com.sun.media.sound.PortMixer@4b743fba
info: Built-in Input source port
info: Port Built-in Output, version Unknown Version
mixer com.sun.media.sound.PortMixer@45d1edcc
info: Port SB X-Fi Surround 5.1 Pro, version Unknown Version
mixer com.sun.media.sound.PortMixer@59530fe3
info: Port SB X-Fi Surround 5.1 Pro, version Unknown Version
mixer com.sun.media.sound.PortMixer@5c382de5
info: SB X-Fi Surround 5.1 Pro source port
关于java - 如何在Java中获得混音器 channel 布局,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12863081/