briankendall / proxy-audio-device

A virtual audio driver for macOS to sends all audio to another output
The Unlicense
603 stars 35 forks source link

Channel Mapping #50

Open Torinth opened 20 hours ago

Torinth commented 20 hours ago

Hi there, wondering if its possible to change which channels are mapped to the proxied device. For example i have a 16 channel audio interface and channel 16 is my generic audio output. when i use apps like spotify i cant choose which channels it uses so it would be great to say map virtual channel 1 to proxied device 16 (i would just mute channel 2 or leave it unmapped and configure spotify to output mono) so that i can choose the virtual output device and it get routed to channel 16 on my audio interface

Torinth commented 20 hours ago

If i were to build this myself is it this line i would change to 16 and the next to 15 (then i would mute channel 2 of the virtual device or could i change it somehow to not route channel 2 to anything)?

https://github.com/briankendall/proxy-audio-device/blob/13cbdb8055232c68ffd28900c4d28182b5ecafe2/proxyAudioDevice/ProxyAudioDevice.cpp#L3056

briankendall commented 19 hours ago

That line wouldn't do it, and you'd want to keep that as is. What you do want to do is change the contents of this loop starting here: https://github.com/briankendall/proxy-audio-device/blob/13cbdb8055232c68ffd28900c4d28182b5ecafe2/proxyAudioDevice/ProxyAudioDevice.cpp#L5420

You can see it's copying audio data from the proxy device to the proxied device, and it's only doing it for at most the first two channels.

I think if you change these lines:

5421:         UInt32 numChannelsToProcess = std::min(outputChannelCount, currentInputDeviceChannelCount);

5426:            Float32 *out = (Float32 *)outOutputData->mBuffers[bufferIndex].mData + channelIndex;

To this:

5421:         UInt32 numChannelsToProcess = 1;

5426:            Float32 *out = (Float32 *)outOutputData->mBuffers[bufferIndex].mData + 15;

that would map proxy device channel 1 to your audio interface's channel 16. But of course I haven't tested this, and given we're dealing with pointer arithmetic getting this wrong could easily cause the audio server to crash. But I think this or something like it should get what you want without too much trouble.

Torinth commented 19 hours ago

ok awesome i will give it a try! thank you