With the java sound API I don't seem to be able to access all the multiple output (4 mono) channels available on my audio interface, a usb presonus studio 68c, running from Java 21 on both windows and a Mac m1, with the usb presonus studio plugged in.
Mixer: Port Studio 68c
MICROPHONE source port
SPEAKER target port
Mixer: Studio 68c
interface SourceDataLine supporting 20 audio formats, and buffers of at least 32 bytes
... (20 supported audio formats removed)
interface Clip supporting 20 audio formats, and buffers of at least 32 bytes
... (20 supported audio formats removed)
interface TargetDataLine supporting 20 audio formats, and buffers of at least 32 bytes
... (8 supported audio formats removed)
I can play a stereo clip on the default master channels 1+2 (with interface Clip), but channels 3+4 (e.g. for headphone qué) on the same audio interface remain elusive.
Is this a limitation of the Java Sound API?
Ok, so although you cannot access the individual output channels in source data lines, you can access all the channels at once by writing a 6 channel format audio data to your 6 mono channel capable audio interface. So if you offset the 2 channel stereo audio data by 2 channels on byte array that you are using to write to the 6 channel device, you can play sound on channels 3 and 4. All the other channels get 0 (if you want nothing to play on them).
so here is some code that plays a wav file on channels 3-4.
The AudioSystemInfo class is exists to help me find the 6 channel mixer (Audio Interface)
The AudioChannelBuffer class deals with creating the byte array of audio data in the 6 channel 'shape' and copying the 2 channel audio data into it, at a channel offset.