Hello Unity friends!
I am working on a Spatializer plugin and my plugin DSP code and I understand that Unity passes audio to my plugin as stereo, regardless of whether the underlying audio Clip is mono, stereo or multi-channel, by up or down-mixing as necessary.
So given that my plugin will always "see" audio as stereo, how can I access per instance (i.e. per audio source) info on e.g. channel count of the source. The documentation on spatializer instance data includes the following:
struct UnityAudioSpatializerData
{
float listenermatrix[16]; // Matrix that transforms sourcepos into the local space of the listener
float sourcematrix[16]; // Transform matrix of audio source
float spatialblend; // Distance-controlled spatial blend
float reverbzonemix; // Reverb zone mix level parameter (and curve) on audio source
float spread; // Spread parameter of the audio source (0..360 degrees)
float stereopan; // Stereo panning parameter of the audio source (-1: fully left, 1: fully right)
// The spatializer plugin may override the distance attenuation in order to
// influence the voice prioritization (leave this callback as NULL to use the
// built-in audio source attenuation curve)
UnityAudioEffect_DistanceAttenuationCallback distanceattenuationcallback;
};
I would have thought that a channel count in this struct would be useful. So is there a way to infer the mono/stereo/multi channel nature of the audio source from the above? (e.g. maybe stereopan is set to a specific value for mono sources?) It seems I must be missing something here because it's clear that a spatializer would want to spatialize an audio source differently depending on its number of channels.
Thanks!
↧