Search Unity

Audio Lower pitch but keep volume ?

Discussion in 'Audio & Video' started by radiantboy, Jan 4, 2020.

  1. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Anyone know how u can lower pitch on an audiosource without reducing the overall perceivable volume ? Music seems to go silent at very low pitches.
     
  2. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    That's just a consequence of adjusting the waveforms. The perceivable sound is lower because the noise is slower and perhaps your brain processes it as softer, but that's just a guess. If you're concerned then just raise the volume of the audio source slightly at the same rate you slow it down. There's no other way to adjust the pitch on an individual audio source outside of the .pitch variable, so you'll just have to work around that limitation and manually curate the volume.
     
  3. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Thanks, well unfortunately even at max volume (1) on say 0.25 timescale most music seems to be inaudible :-(
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,793
    Inaudible? That doesn't sound right, 0.25 pitch is two octaves down, which while a lot, it should still be fairly audible (unless you started with something very bassy in the first place and that pushes it down to sub-bass range)
     
    Last edited: Feb 23, 2020
  5. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    I agree with AcidArrow, it doesn't seem right that just the pitch alone adjusts it that much, unless you have louder sounds which are playing that overpower it, which is a common mixing concern.

    Sadly Unity's volume slider on the AudioSource does not go above 1. So the first way you can make it louder is to actually just increase the raw volume of your file, so that playing it "normally" actually means the AudioSource must start at .5 volume. Then when you need to increase it for pitch you have the space to raise it to 1.

    But I realize that's not always possible, especially if you are already hitting the clipping range in your audio file. So another solution would be to take advantage of AudioMixer. When you make an AudioMixer, you can make different "groups" which have different effects applied to them. Then your AudioSource can be assigned to a specific group using outputAudioMixerGroup. One of the unique features of AudioMixer groups is that their volumes can be adjusted individually. And in fact, this volume slider actually lets you raise volume by 20db, which should be more than enough. If it's not enough, you can add effects such as Compressor which can be used to increase volume, or you can nest groups in each other, each raising volume by up to 20db, as many times as you want.

    The AudioMixer group volume parameters can be exposed using the AudioMixer window, and those exposed variables can now be edited through code with SetFloat(). See here for details.
     
    radiantboy likes this.
  6. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Wow, cool idea. Thanks guys will look into it.. also the music is very backgroundy in the first place which may be the issue.. gunshots etc are still as loud as you would expect really.