Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio Why is audio source pitch clamped to 3?

Discussion in 'Audio & Video' started by ArachnidAnimal, Sep 10, 2019.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,760
    I'm using some third part vehicle assets that adjust the adjust the audio source pitch based on RPM. Unity clamps the audio source pitch to 3, it cannot go any higher.
    Does anyone know why this is? Is this some limitation of audio engine?
    I need the pitch to go higher to sound more realistic.
     
  2. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    You can go higher than a pitch of 3 via script.

    Code (csharp):
    1. audioSource.pitch = 7.0f
    That code works.

    It's the editor GUI slider for the pitch that restricts the pitch between -3 and 3
    That can be seen here:
    https://github.com/Unity-Technologi...Editor/Mono/Inspector/AudioSourceInspector.cs
    Code (csharp):
    1. EditorGUILayout.Slider(m_Pitch, -3.0f, 3.0f, Styles.pitchLabel);
    This wouldn't matter though, the asset is setting the pitch via script, not via the audiosource GUI. Perhaps it has these pitch range settings as public variables available in the inspector somewhere so that you can change them. If those public variables are also restricted to -3 / 3, or they are private variables, you can dig into the script and change the values of the range.

    Search the scripts for the words Pitch/Min/Max
    It probably has them for each gear
     
    ArachnidAnimal likes this.