Modifying sound from mp3 data

You use the Sound.extract() method to extract data from a Sound object. You can use (and modify) that data to write to the dynamic stream of another Sound object for playback. For example, the following code uses the bytes of a loaded mp3 file and passes them through a filter function, upOctave() :

var mySound = new air.Sound(); 
var sourceSnd = new air.Sound(); 
var urlReq = new air.URLRequest("test.mp3"); 
sourceSnd.load(urlReq); 
sourceSnd.addEventListener(air.Event.COMPLETE, loaded); 
function loaded(event) 
{ 
    mySound.addEventListener(SampleDataEvent.SAMPLE_DATA, processSound); 
    mySound.play(); 
} 
function processSound(event) 
{ 
        var bytes = new air.ByteArray(); 
        sourceSnd.extract(bytes, 8192); 
        event.data.writeBytes(upOctave(bytes)); 
} 
function upOctave(bytes) 
{ 
    var returnBytes = new air.ByteArray(); 
    bytes.position = 0; 
    while(bytes.bytesAvailable > 0) 
    { 
        returnBytes.writeFloat(bytes.readFloat()); 
        returnBytes.writeFloat(bytes.readFloat()); 
        if (bytes.bytesAvailable > 0) 
        { 
            bytes.position += 8; 
        } 
    } 
    return returnBytes; 
}

// Ethnio survey code removed