Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
9
Question by Uriel_96 · Aug 16, 2010 at 06:03 PM · audiosoundspeedchange

How I can change the speed of a song or sound?

I'm trying to change the speed of the audio but I could not find a way to do it.

Could someone please help me.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unity_z0alEICRb6AVAw · Jul 12, 2018 at 02:02 PM 0
Share

did you find any answer?

5 Replies

· Add your reply
  • Sort: 
avatar image
20
Best Answer

Answer by Wolfram · Aug 16, 2010 at 10:27 PM

Unity can only change the speed of an AudioSource. It calls this parameter "Pitch". However, changing it will always change both pitch and tempo, since this is just a matterl of changin the playback sampling rate and can be done in realtime at almost no cost and with (almost) no sound distortion.

Unity cannot change just the pitch (and keep the tempo constant) or just the tempo (and keep the pitch constant). What you are looking for is the latter.

Up until recently I would have answered this is a very expensive process since you actually need to resample your audio clip by splitting it into very short segments and then overlap or copy&extend them, so you would have a hard time doing this in realtime during your game.

However, as the videoplayer vlc has shown in recent versions (>=1.0 I think), there is an algorithm that can be evaluated in realtime to do just that (When increasing/decreasing the video playback speed in vlc, the audio can still be heard, with matching speed, astonishingly few distortions, and most importantly unchanged and constant pitch.) So I'd suggest to put it on the Unity wish list.

EDIT: If you are not interested in dynamically changing the tempo, but instead just change it once and then keep that new tempo, I'd suggest to use some audio software to modify your audio sample. ("Audacity" is a frelly available tool to do that and other stuff)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image skylem · Aug 02, 2014 at 08:52 PM 1
Share

its always good to find answers without needing to ask any questions, thanks.

avatar image
26

Answer by RayRay26 · Oct 31, 2018 at 12:32 AM

I know this question is old, but this thread appears near the top of most Google results about music speed, and times have changed over the last 8 years. I did find a solution, but it requires learning Audio Mixers. It's not perfect; you'll hear imperfections in the sped up audio, but it's better than constantly setting AudioSource.time or creating your own audio buffers.

Press Ctrl+8 to open the Audio Mixer tab (or find it in the Window menu at the top), then add a mixer. I put my mixer in the Resources folder so I can fetch it with var pitchBendGroup = Resources.Load("Pitch Bend Mixer"); audioSource.outputAudioMixerGroup = pitchBendGroup;. Once you made one, add the Pitch Shifter effect to the Master slider. You should see this in your Inspector (not the Audio Mixer tab): Pitch Bend Master inspector The bottom slider that says Pitch is the one you want. If you right click the word "Pitch" you can expose it in your mixer so you can change the value by code (that makes the arrow appear next to it). So if you want to keep the song pitch the same but speed up the tempo by 50%, you do: audioSource.pitch = 1.5f; pitchBendGroup.audioMixer.SetFloat("pitchBend", 1f / 1.5f); It seems pretty lightweight on DSP CPU, so I don't think there's a need to create your own audio buffers or crazy stuff like that, just use a mixer. If you want to save CPU while the tempo is at 100%, set outputAudioMixerGroup to null. Also I recommend lowering the volume by 3 dB because that tends to be how much louder it gets with 4.00 overlap.

EDIT: I realized there is an extra step for newer versions. Once you make the arrow appear next to Pitch you have to go back to Audio Mixer and open up Exposed Parameters at the top-right of the panel. It's recommended to right-click and rename the 'MyExposedParam' entry (I named it 'pitchBend').


pitchbendmaster.png (13.6 kB)
Comment
Add comment · Show 11 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kevwills · Sep 19, 2019 at 02:32 PM 0
Share

I tried this method it does not work.

changing the audio pitch by =1.5 and then changing its mixer's pitch by =1/1.5 makes the pitch equal to what it was previously (1.5/1.5 = 1). There is a small sound distortion because it has been processed, but the overall pitch and tempo are both unchanged.

Had not heard of mixers before this, so was pleased to find something valuable out of this post, but again this is not the solution.

avatar image RayRay26 kevwills · Sep 20, 2019 at 09:48 AM 0
Share

A note that there are two $$anonymous$$ch sliders. The bottom one is the one you want, because if you change the top one you effectively cancel out the AudioSource pitch with the mixer's. The bottom one generates an actual pitch bend. I also updated the post for an extra step about what to do after exposing the bottom pitch in the code (as it has the default name $$anonymous$$yExposedParam).

avatar image Sylvanas RayRay26 · Aug 18, 2020 at 08:01 AM 0
Share

Aaha, I had the same issue before because of exposing the wrong pitch parameter! Thanks for your update!

avatar image Kamyker · Jan 03, 2020 at 12:31 AM 0
Share

legendary post, thanks!

avatar image calurin · Feb 16, 2020 at 04:20 AM 0
Share

Just wanted to say thanks RayRay26 and this is still working in 2019.3. For future users just be sure to pay attention to the part rena$$anonymous$$g the exposed parameter in the Audio $$anonymous$$ixer - edited hint at the bottom of the answer. :)

avatar image Achoo · Feb 27, 2020 at 10:07 PM 0
Share

alt text

I would say this master pitch works much better. It displays max value as 1000, but should be assigned max as 10.

audioSource.outputAudio$$anonymous$$ixerGroup.audio$$anonymous$$ixer.SetFloat("$$anonymous$$ain$$anonymous$$ch", 10f);

pitch.png (7.2 kB)
avatar image pihels Achoo · Apr 02, 2020 at 09:15 PM 0
Share

@Achoo doesn't the master pitch change the speed also so it negates the effect?

The other slider seems to keep speed the same and just changes pitch. It doesn't give a perfect result, but better than nothing.

avatar image pihels · Apr 02, 2020 at 09:17 PM 0
Share

This solution seems to work, not perfect but noticeable difference. Thanks a lot! I was almost about to give up and this seems to be the best way currently.

Show more comments
avatar image
2

Answer by KnightChatX · Apr 30, 2011 at 05:33 PM

You can use an audio editor such as Audacity here to edit the sound file and change it's speed: http://audacity.sourceforge.net

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Uriel_96 · May 01, 2011 at 02:14 PM 1
Share

thanks, I was asking this inside of unity but seems like that's another good way.

avatar image
0

Answer by Maltus · Aug 16, 2010 at 06:39 PM

The AudioSource Pitch handles the speed of playback. Value of 1 is normal playback.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Uriel_96 · Aug 16, 2010 at 07:15 PM 0
Share

and how I can do to not change the pitch, just change the speed to sound like the song but faster or slower

avatar image Maltus · Aug 16, 2010 at 08:55 PM 0
Share

The $$anonymous$$ch is the speed. Put ypor song in an Audio Source Component set it to play on awake put the pitch to 2 and press play on your game and voila chipmunks will be singing.

avatar image Ares · Aug 16, 2010 at 08:55 PM 0
Share

I take it you are looking at just changing the tempo of audio and not doing a cassette-fast-forward/lp-on-wrong-speed-setting. I haven't seen anything like that in Unity where you can strictly change the tempo.

avatar image Ares · Aug 16, 2010 at 08:57 PM 0
Share

$$anonymous$$altus replied while I was typing...I agree with $$anonymous$$altus that the pitch and tempo go hand-in-hand.

avatar image Uriel_96 · Aug 18, 2010 at 01:15 AM 0
Share

so change the speed of the song is to difficult but in that case its there a way to change the speed of the game, I mean to be all slow including the speed of the song???????????

avatar image
0

Answer by adom86 · Nov 12, 2012 at 05:07 PM

Hey guys

I have an FBX animation that was animated to a specific audio file.. this was done at 30FPS in 3ds max. After importing to unity and plying the audio along with the animation it is some what off... is there a workflow to fix this?

Many Thanks

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ocimum · Jul 15, 2015 at 10:38 AM 1
Share

Please create a new post for your question

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sounds are shaky at high speed. 0 Answers

how to change pitch of sound without changing speed? wav file 1 Answer

audio is distorted at speed 1 Answer

How can I speed up getSpectrumData for visualization of audio on mobile? 1 Answer

Different sound the higher I go on the surface 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges