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):

pitch_shift.gif
click to open

You can download the source code here: http://iq12.com/files/pitch_shift/pitch_shift.zip

Music: More Frightened by CandyCash (with permission)

Comments (5)

Stephan BernseeAugust 25th, 2009 at 17:21

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

Lee BrimelowAugust 25th, 2009 at 19:27

Nice dude!

Og2tAugust 25th, 2009 at 20:01

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 ;-)

fuAugust 25th, 2009 at 21:32

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.

UmitSeptember 5th, 2009 at 12:44

Nice work. The volume gradually decreases and increases back, how can we fix this?

Leave a comment

Your comment