Hi, I’m wanting to use a multi-channel audio files for a game in Unity. The file would contain multiple channels, which would be pairs of L/R combiniations of adaptive music. For example, channels 1 & 2 would be L/R track 1, channels 3 & 4 would be L/R track 2.
You can create these tracks in FMOD, and Unity uses FMOD for its audio, however, for the life of me, I can’t find how to turn certain channels on and turn other channels off, to get the desired effect.
I’ve done something similar with swapping between 2 channels, [and this link was very helpful][1].
To change the volume between 2 channels I used the code:
for (var i = 0; i < data.Length; i = i + channels)
{
data <em>= (float)(data _* vol);_</em>
data[i + 1] = (float)(data[i + 1] * (1-vol));
}
“vol” is a public variable between 0 and 1 that you can set with a script.
My guess for how it would work for 4 channels is:
for (var i = 0; i < data.Length; i = i + 4)
{
data = (float)(data * vol);
data[i + 1] = (float)(data[i + 1] * vol);
data[i + 2] = (float)(data[i + 2] * (1-vol));
data[i + 3] = (float)(data[i + 3] * (1-vol));
}
_*[1]: http://www.mclimatiano.com/audio-filters-in-unity3d/*_