Andre Michelle has an excellent article on Pitch control with actionscript 3.0
For reference, here is a sample Andre code:
package components { import flash.events.Event; import flash.events.SampleDataEvent; import flash.media.Sound; import flash.net.URLRequest; import flash.utils.ByteArray; public class MP3Pitch { private const BLOCK_SIZE: int = 3072; private var _mp3: Sound; private var _sound: Sound; private var _target: ByteArray; private var _position: Number; private var _rate: Number; public function MP3Pitch( url: String ) { _target = new ByteArray(); _mp3 = new Sound(); _mp3.addEventListener( Event.COMPLETE, complete ); _mp3.load( new URLRequest( url ) ); _position = 0.0; _rate = 1.0; _sound = new Sound(); _sound.addEventListener( SampleDataEvent.SAMPLE_DATA, sampleData ); } public function get rate(): Number { return _rate; } public function set rate( value: Number ): void { if( value < 0.0 ) value = 0; _rate = value; } private function complete( event: Event ): void { _sound.play(); } private function sampleData( event: SampleDataEvent ): void {
The main use would look something like this:
//create an MP3Pitch instance and load a sound var mp3:MP3Pitch = new MP3Pitch("/path/to/your/file.mp3"); //change the pitch via rate setter mp3.rate += 0.5
source share