in Actionscript 3

Adjusting audio pitch in Flash Player 10

Update: Andre Michelle wrote some much better code to adjust the pitch of an external sound. I was secretly hoping he would. Check it out at Thanks Andre!

Here is another sound example that shows how to adjust the pitch of an external sound. This is an extension of the example that can be found in the documentation for the Sound.extract method. Now this example does adjust the pitch but it also speeds the song up as well. This is because you need to skip some samples in order to increase the pitch. Now there are ways to increase the pitch of sounds without speeding them up but I have no idea how to do it. Do you?

Click on the image below to see the example. It uses my throw slider which you can toss back and forth. It may take a minute for the song to load so please be patient. You can download the FLA file if you want to see how it was done.


Write a Comment



  1. Well, time-stretching can be done by splitting the sample into small parts and moving those parts closer or further away, filling the gap (if any) by repeating the part.

    High-Quality example:


    can be stretched to


    Implementing this can be relatively simple (just drop or duplicate every X sample), but the sound quality may not be the best (tho it creates an interesting effect).

  2. Great tutorial, Lee.

    Sorry for a slightly irrelevant question.

    Does anyone know how to find BPM (Beats Per Minute) information from external MP3 file(s)?

    I don’t want to play them all straightaway. Its a bit like iTunes – show a play list of all the mp3 from a specified file structure and BPM next to it. This is for an AIR application I am currently working on.

    Any help is appreciated. Thanks.

  3. This is great, I have been looking into how to manipulate sound in Flash lately and had almost come to the conclusion that I was wasting my time. Great choice of song too!

  4. Looks like Andre Michelle wrote a post in response to this one pretty quickly.

    He improves the example in these ways:
    * No objects are created in runtime (memory usage)
    * The SampleDataEvent is receiving a static blocksize (steady latency)
    * Linear interpolation (sound quality)
    * Speed can go down to zero

    Personally I find this stuff really exciting and I’m looking forward to learning something new today.

  5. Basically, the pitch or tone depends on the sampling frequency, and the sampling frequency depends on the time of the wave.
    That’s why if we modify our sampling frequency, we modify our time.
    The only way is by skipping samples from X time to time in the time domain, so the frequency wave form wouldn’t be affected. If we just rise the sampling frequency without modifying our samples, the result is that the Fourier transform domain (frequency) is not the same, so that the sound changes its velocity.

    The way to rise the pitch without rising the velocity is not by skipping samples, you just have to copy such as samples as frequency-multiple you want to rise the pitch.
    (Such as: 100111010 –(rising pitch in a 3 ratio) –> 111000000111111111000111000), as you can see, 3 times every sample to solve the 3times rised freq.
    That’s what it does Soundbooth when you just rise the pitch ๐Ÿ˜‰

    I have just studied Digital Audio in Telecomunicatios, I got a 9 over 10.

    Keep on

  6. i find this sound, sampledata, writefloats etc stuff so freaking hard to understand, but yet it’s so cool ๐Ÿ˜€ So i’m going to lock myself up and see if i can get to understand it ๐Ÿ˜›
    Thanks for the tutorial Lee!

  7. Hi Lewis how are you.. I’m trying to do something similar to your project FlashDJ.. I’m wondering if you can share with me your source file (.fla)

    I’ll appreciate your help

    Thanks a lot…

    If you can contact me my e-mail address is

  8. How would this be done with a sound from the library and not an external MP3?

    I tried instanciating a sound from the lib called Buzz:

    ex = new Buzz()

    But this doesn’t work…

  9. any body help me about pitch shifting in as2.0(action script2.0),is it possible through actionscript2.0 ? if it is possible pls help me .

    Thanks & regards