- Home /
AudioMixer output volume
Is it somehow possible to access an AudioMixer's output level via Script?
Hey! I'm searching the same thing. Did you found how? The only way I know is getting the outputData from audioSource...
Answer by OndrejP · Jun 13, 2020 at 11:17 AM
1. In editor
Call this method by reflection:
// UnityEditor.Audio.AudioMixerController
internal sealed class AudioMixerController : AudioMixer
{
public int GetGroupVUInfo(GUID group, bool fader, float[] vuLevel, float[] vuPeak);
}
vuLevel and vuPeak are 9-element arrays which get these values - one element per channel
2. At runtime by OnAudioFilterRead
Works only on the level of AudioListener (all sounds) or AudioSource (single sound), no support for mixers or groups
This is better method than 3., because it's called directly from Audio thread and gives you data at appropriate time
public class AudioFilterMeasureVolume : MonoBehaviour
{
private void OnAudioFilterRead(float[] data, int channels)
{
// Process data
}
}
Process the data like this:
https://answers.unity.com/questions/165729/editing-height-relative-to-audio-levels.html
3. At runtime by AudioListener
Works only for master output data, cannot get data for individual mixers or groups
Call AudioListener.GetOutputData and process the data like this: https://answers.unity.com/questions/165729/editing-height-relative-to-audio-levels.html
4. At runtime by Native Audio Plugin SDK
It's possible to write native audio plugin, which will extract this information: https://docs.unity3d.com/Manual/AudioMixerNativeAudioPlugin.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613191747im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Audio Output Data 0 Answers
How can I set the audio on a Virtual Reality game? 0 Answers
Change AudioSource output via Script 1 Answer
AudioSource.GetOutputData obsolete 2 Answers