Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Audio Is there a way to read the VU meter value from an audio mixer (not an audioSource) through code?

Discussion in 'Audio & Video' started by joechatfield, Jul 28, 2018.

  1. joechatfield

    joechatfield

    Joined:
    Jul 8, 2017
    Posts:
    2
    Hi, I've been looking everywhere but can't seem to find a solution to this and it seems particularly odd as the VU meters are clearly reading the data I'm after but we don't seem to have access through code.

    This question has been asked before here (in 2014) but was resolved with 'they're working on it':

    https://forum.unity.com/threads/audio-mixer-exposing-vu-levels.277216/

    Any progress since then?

    For context, I'm looking to make some VU meters that appear in-game but my audiosources are generating audio (no clips) so the levels there appear maxed out. This means I need to grab the values directly from the audio mixers in order for them to be accurate.

    Any help is greatly appreciated. Thanks in advance.
     
    Marc-Saubion likes this.
  2. Marald

    Marald

    Joined:
    Jan 16, 2015
    Posts:
    42
    I wish we could just access those values, I've asked many times, but somehow the audio mixer and subsystem does not seem essential to unity as even native audio plugin and other feature development has been quiet the last few years. (ever since Unity 5 release of the mixer)

    I developed a few workarounds, but for this purpose it would be too much. An easier way is what I used earlier.

    You could send the output of one of your mixer channels to an audio source component usign the native audio plugin (demo routing) after your effects and use onaudiofilterread to read this stream to that audio source and to grab the values to calculate and monitor your VU level.
     
    Marc-Saubion likes this.
  3. joechatfield

    joechatfield

    Joined:
    Jul 8, 2017
    Posts:
    2
    Thanks Marald, I wasn't aware that you can route the audio from an audioMixer back into an audioSource. It does seem like the 'long way round' (and necessitates me adding 17 more audioSources) but it sounds like it should at least offer a workaround for now.

    Shame about the lack of audio support recently; I really appreciate your help though :D
     
    Marald likes this.
  4. Docaroo

    Docaroo

    Joined:
    Nov 7, 2017
    Posts:
    82
    Can't you put a script directly on the audiosource to read the audio stream that they are sending?