Pitch MP3

Pitching MP3 (Not PitchShift!) is possible since Flash10s new Sound API. Today I saw Lee Brimelow’s post about doing so, providing some source code. Cause we spend a lot of time to keep things running more smoothly in the AudioTool, I created another version which has some advantages.

  • 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

{source code}

Get Adobe Flash player

(no preloader – music by basic channel) – Thanks Lee for pointing me!

93 thoughts on “Pitch MP3”

  1. Pingback: MP3 Wave Display 2
  2. Hi Andre
    Thanks for these wonderful posts – very helpful for a noob like me. I am actually trying some very basic stuff to protect an MP3 that I stream from being recorded. One approach was to simply XOR the content frames in a MP3 with a key and XOR is back in the player actionscript. But once I use sound.extract() , XORing does not recover the original mp3. Is it because sound.extract actually uncompresses the data into raw sound? Anyway I can manipulate the mp3 as it loads.

  3. Hi, I would like to know is it possible to perform a loop back sound?

    I try to use soundchannel but it won’t works

  4. Hello! Do you guys know if there’s a way to change a MP3 header information directly from flash? I’m trying to figure out a way to prevent the MP3 file be executed (e.g. Windows M Player).

    Thanks

  5. Pingback: Anonymous
  6. This is really good, but it doesn’t work with a low quality mp3, because you will hear some “pops” every few milliseconds.

  7. Very nice work !

    The question has already been asked but, how can you pitch a loop wav loaded in the library ?

    For a car game i would like to play pitch the engine sound.

    Tanks !

  8. Hello,

    Can you please post all the source files of this example.
    I need to see how you calculate the position that you show on the progress bar depending on the speed.

    Thanks,
    Andrei

  9. Thanks for this great work.
    Unfortunately I have as well the problem of “clicks” and “pops” during playback, even if I provide 8192 samples.
    Have you maybe some idea to improve or fix this lack on the audio quality?

  10. well, I’m trying on some not powerful pc and netbook… so probably it’s for this reason but I was really interested to understand if is possible to use some tips to improve a problem like this.

  11. Very nice script. Just awesome and works perfect.

    If you want to loop the sound then write two lines of code:
    _position = 0.0;
    return;

    at the end right after where it says:
    if( i < BLOCK_SIZE )
    {

    so it'll look like:
    if( i < BLOCK_SIZE )
    {
    _position = 0.0;
    return;
    while( i < BLOCK_SIZE )
    {
    data.writeFloat( 0.0 );
    data.writeFloat( 0.0 );
    trace("zero");
    ++i;
    }
    }

    cheers!

    Now I gotta figure out how to set the volume for the audio.

  12. any body help me about pitch shifting in actionscript2.0 version.is it possible through as2.0 version.if it is possible please help me on this

    thanks & regards
    G.Ravi kumar

  13. Nice example, however, this is inapplicable in a game, a 3072 loop per frame every time you play a sound will kill your performance.

  14. Schön gemacht, aber ich frage mich WARUM zur HÖLLE muss jedes Flash 100% audiolautstärke haben? Das kann man doch runter regeln zu Beginn.
    Man geht auf diese Seite und einem fliegen erst mal die Ohren davon… ich versteh es nicht.

  15. No documentation? No help? I have no idea how to use it.

    var pitch:MP3Pitch = new MP3Pitch();
    pitch.MP3Pitch(“car_tyre.mp3”);

    And now what ?

  16. Hi there !!!

    I wanted to ask how I can change the pitch of whole ByteArray at once ? Then I want to save it locally, but that part is not the problem…:)
    I need to change a lot of files to different pitches so that’s why I need this ..
    Thanks !

  17. I,

    Works fine with 44100Hz, but with a 22050Hz I have interference, a regulary noise.
    How adapte algorithm for various bitrate ?

Comments are closed.