Real-time pitch shifting (without change of duration)
After reading Lee Brimelow’s post about Adjusting audio pitch in Flash Player 10, I’ve thinked about a real pitch shifting solution (adjusting pitch without change of duration).
Then I found a great algorithm here: http://www.dspdimension.com/admin/pitch-shifting-using-the-ft/ and its C# port here http://sites.google.com/site/mikescoderama/pitch-shifting
I’ve ported the code to AS3 then heavily optimized it to get it running under 100% cpu use (of 1 cpu core). I get 45% cpu use with the default parameters on my 2.4GHz PC.
See it in action here (Flash Player 10 required):
You can download the source code here: http://iq12.com/files/pitch_shift/pitch_shift.zip
Music: More Frightened by CandyCash (with permission)


Running at 32% (default values) on my MacPro 2×2.8 GHz Quad Core Intel Xeon. Good job!! If I may make a recommendation – you should really add the 4096 frame size as it sounds so much better for complex signals like music. Thanks for sharing this! Cheers, –smb
Nice dude!
Very nice, I wish Flash had support for microphone recording already. I wonder how fast it would run in PixelBender – I might try that, the C++ code seems to be portable and it might be even easier to port it to PB than AS3
I’ve looked into PB and as far as I know there’s no way to get this working because it would require too much loop unrolling. Correct me if I’m wrong.
Nice work. The volume gradually decreases and increases back, how can we fix this?
Hi there,
I searched the whole internet and here is the only as3 pitchshift code in the world.
thank you so much for this. its fantastic work I read all the stuff on the dsp dimension in hope that I could make my own but my brain isnt big.
thank god for people like you , now im just using your code.
a couple of questions if you get the time :
Why do you create two pitch shifters ? (one for left and one for right) why dont you reuse the one pitch shifter ?
in other words
can I use the one pitchshift object to shift in turn left then right.
I cant see any reason why not but i thought I should i ask you.
also im having a strange problem after I implemented the pitchshift object the output is really wrong. if i pitch shift at 1 I hear nothing but if I pitch shift at 2 all i can hear is a faint tin like sound almost in audible.
I checked the outputted floats and it looks really wrong its like this:
0
0
0
0
4.023402340
3.230403249023
0.0000324234324
0.0003423423423
0.0023432423423
0.0034234234324
I am pitch shifting a sound of only 9 milliseconds I thought that may be the problem
so i tried a longer sound but it still causes the problem.
thank-you again
Luke
actually I made the sound longer and it worked
but i need to pitch shift a small sound
I geuss im asking how can i pitch shift a 9 millisecond sound ?
i mean 90ms
actually it was 9.
i discovered that this isnt what i need to pitch a sound whilst retaining the formants
http://www.surroundsfx.com/forum/viewtopic.php?f=11&t=638