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
Any ideas about how Alchemy would work in this case?
that’s pure speculation but I think a x4 performance boost could be achieved
I might give it a try.
Great got a project with a some facetrackign aswell where this will come in handy, thanks! gimme a shout lator this month if you wanne see the result
Hi,
any body help me about pitch shifting in actionscript2.0
Great work.
I would like to use something like this to correct pitch of mp4 video played at 1/2 and maybe 1/x speeds in Flash 10 player. Any help would be appreciated. Also would need to improve quality and CPU performance.
Thanks,
[...] PitchShifter - Real-time pitch shifting (without change of duration) http://iq12.com/blog/2009/08/25/real-time-pitch-shifting/ [...]
Hello there, great job on the code.
I’ve been trying to adapt something of sorts for microphone input in realtime for the last few days with no such luck. Though I can get it to pitch and keep the duration, the sound comes out choppy and really unusable. I think I might be handling the mic sampling unproperly, or iterating over the sample data without the correct “overlap factor”, as you call it in your example.
Do you know of anyway I can achieve this? A realtime microphone pitch without change in duration and quality results? Any help at all would be much apreciated.
Any one know of a good objective C example of this source code?
You can check thé dspdimension source link to get their pure C code. Should be easy enough to use no?
[...] PitchShifter - Real-time pitch shifting (without change of duration) http://iq12.com/blog/2009/08/25/real-time-pitch-shifting/ [...]
What percent do you think is one complete pitch up or complete pitch down? And half pitch?
Thanks for all!
Best regards,
J.R. Leon
[...] изменение скорости звука в реальном времени (КРУТО!!!). PitchShifter — изменение тональности звука, черз pitch-shifting (я думаю, [...]