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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Pitch Shifting Audio Clip in Script with unity

Discussion in 'Audio & Video' started by zacharyaghaizu, Oct 7, 2022.

  1. zacharyaghaizu

    zacharyaghaizu

    Joined:
    Aug 14, 2020
    Posts:
    65
    Hi, I'm interested in pitch shifting individual audio sources instead of the whole scene with the mixer pitch shifting

    I tried with this script , but it isn't working at all when I try calling it.
    https://sites.google.com/site/mikescoderama/pitch-shifting

    It would be awesome if there was a pitch option to keep the speed easily accessible like audio source.pitch.

    I Appreciate your help in advance.
     
  2. AndreiTache

    AndreiTache

    Joined:
    Nov 8, 2014
    Posts:
    31
    You can set the pitch with
    audioSource.pitch = newPitch;


    If you want to change the pitch by specific semitones you can set the pitch to
    Mathf.Pow(2, n/12);

    (where n is the number of semitones you want to pitch up by.
     
  3. zacharyaghaizu

    zacharyaghaizu

    Joined:
    Aug 14, 2020
    Posts:
    65
    Hi, I'm asking about Pitch Shifting, which allows you to change pitch without changing the speed of the sound. The linked code was a script which should allow me to send samples in and change the pitch shift between 0.5 and 2. Is it possible to get it working? I tried with audioclip samples. The audio mixer has this feature but I want to apply it to an audio clip instead of pitch.
     
  4. AndreiTache

    AndreiTache

    Joined:
    Nov 8, 2014
    Posts:
    31
    Ah, my bad. I don't think I can help then, I don't fully understand how that code works. When you call it, did it give an error of some kind, or what was the issue?
     
  5. zacharyaghaizu

    zacharyaghaizu

    Joined:
    Aug 14, 2020
    Posts:
    65
    It didn't give any error which is confusing really.
     
  6. Ectoplastic

    Ectoplastic

    Joined:
    Mar 2, 2019
    Posts:
    1
    Hi! Did you make any progress on this topic? It seems like the same PitchShifting algorithm like Unity and FMOD are using.
     
    zacharyaghaizu likes this.
  7. zacharyaghaizu

    zacharyaghaizu

    Joined:
    Aug 14, 2020
    Posts:
    65
    Hi, Yes I managed to get the script integrated with unity. It works pretty nicely