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'
Any helpful links or example code would be greatly appreciated.
To get an array of all
Mixer
s on the current platform, you may useAudioSystem#getMixerInfo
:If your virtual cable is available, it will be in the array. For example, on my Mac the following is printed:
(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.Once you have a particular
Mixer
you can obtain aLine
orAudioInputStream
from it. You can obtain aClip
from it throughAudioSystem#getClip(Mixer.Info)
.javax.sound.sampled
does not supportmp3
. Alternatives can be found here.