DLiKS
DLiKS

Reputation: 1596

Lowering MP3 Pitch with ActionScript 3

I found this example of raising the pitch of an MP3 using ActionScript 3. How would I go about lowering the pitch instead of raising it?

Upvotes: 2

Views: 2415

Answers (1)

borisgolovnev
borisgolovnev

Reputation: 1800

You write the same samples more than once to the output buffer.

function downOctave(bytes:ByteArray):ByteArray
        {
            var returnBytes:ByteArray = new ByteArray();
            bytes.position = 0;
            while(bytes.bytesAvailable > 0)
            {
                returnBytes.writeFloat(bytes.readFloat());
                returnBytes.writeFloat(bytes.readFloat());
                bytes.position -= 8;
                returnBytes.writeFloat(bytes.readFloat());
                returnBytes.writeFloat(bytes.readFloat());

            }
            return returnBytes;
        }

This pitch-shifting is very simple and fast and suitable for real-time use in flash, but it does change the speed at which the sound is being played. For pitch-shifting that does not change duration you need to use fourier transfom based approach. Like this guy did here.

Upvotes: 8

Related Questions