Search Unity

Get Volume of AudioClip

Discussion in 'Audio & Video' started by ExbowFTW, Mar 13, 2017.

  1. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    How do I get the volume of the AudioClip (in C#)? NOTE: I do NOT mean the volume of the AudioSource.

    I am trying to get an array of float values that could then simulate an audio graph like this:
    AudioGraph.png

    Any help would be greatly appreciated!
     
  2. wsy19940107

    wsy19940107

    Joined:
    Mar 21, 2017
    Posts:
    1
    Code (CSharp):
    1. AudioClip audioClip = GetComponent<AudioClip>();
    2. // the samples is an float array, -1.0f ~ 1.0f .
    3. float[] samples = new float[audioClip.samples * audioClip.channels];