更改调音台输出声音在Java [英] Change Mixer to output sound to in java
问题描述
我试图发挥WAV / MP3到我的虚拟音频线,我一直在寻找了几个小时,但似乎无法找到如何实现这一目标。我已经能够在这两种格式的播放声音,但我不能得到它输出到线路1,而不是扬声器
I am trying to play a wav/mp3 to my virtual audio cable, I have been searching for hours but can't seem to find how to achieve this. I have been able to play sound in both formats but I can't get it to output to 'Line-1' rather than 'Speakers'
任何有用的链接,或例如code将大大AP preciated。
Any helpful links or example code would be greatly appreciated.
推荐答案
要获得所有的数组的 混合
取值,你可以使用的 AudioSystem#getMixerInfo
一>:
To get an array of all Mixer
s on the current platform, you may use AudioSystem#getMixerInfo
:
static void printAllMixerNames() {
for(Mixer.Info info : AudioSystem.getMixerInfo()) {
System.out.println(info.getName());
}
}
如果你的虚拟电缆是可用的,这将是数组中为止。例如,在我的Mac下面印:
If your virtual cable is available, it will be in the array. For example, on my Mac the following is printed:
Java Sound Audio Engine
Built-in Input
Soundflower (2ch)
Soundflower (64ch)
Pro Tools Aggregate I/O
(Soundflower是虚拟设备。)
(Soundflower is a virtual device.)
要得到一些具体的混合
你不幸需要做字符串评估。所以,你需要什么,事先发现其名称,供应商,或给用户一个选项,选择一个从列表中。
To get some specific Mixer
you unfortunately need to do String evaluation. So you need to discover its name, vendor, whatever, beforehand or give the user an option to pick one from a list.
static Mixer getMixerByName(String toFind) {
for(Mixer.Info info : AudioSystem.getMixerInfo()) {
if(toFind.equals(info.getName())) {
return AudioSystem.getMixer(info);
}
}
return null;
}
一旦你有一个特别的混合
你可以获取行
或的AudioInputStream
从它。您可以通过它获得剪辑
AudioSystem#getClip(Mixer.Info)
。
Once you have a particular Mixer
you can obtain a Line
or AudioInputStream
from it. You can obtain a Clip
from it through AudioSystem#getClip(Mixer.Info)
.
我试图发挥WAV / MP3 ...
I am trying to play a wav/mp3...
的javax.sound.sampled
不支持 MP3
。 替代品可以在这里找到。
这篇关于更改调音台输出声音在Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!