For the game I am making, I needed a class to change the duration and frequency of a sound, as there is the possibility to slow down time.
My first solution was to use this code: http://www.mcfunkypants.com/2011/as3-pitch-shift-mp3/. But it came out being extremely hard to read and modify. I expended all my day (I think almost 9 hours) trying to simply add the capability of playing not-looping sounds, wich this class didn’t include. That was because of how unclear the code was to me: it has almost no comments at all, and the loop inside the onSampleData event is just unreadable.
I must add that, althought the code was supposed to play sound effects in a game, it’s very poor in performance, so when you play more than one FrequencyChangeSound at the same time, your game could get some low FPSs. I’ll program a sound player class to do one single onSampleData event (instead of one for each sound), and get better performance.
So here’s the code: