flash on 2011-6-11
♥0 |
Line 41 |
Modified 2011-06-11 03:37:32 |
MIT License
archived:2017-03-20 04:54:11
ActionScript3 source code
/**
* Copyright andrew.olton ( http://wonderfl.net/user/andrew.olton )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mCbA
*/
package {
import flash.display.Sprite;
import flash.events.*;
import flash.media.*;
import flash.net.*;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var sourceSnd:Sound = new Sound();
var outputSnd:Sound = new Sound();
var urlReq:URLRequest = new URLRequest("test.mp3");
sourceSnd.load(urlReq);
sourceSnd.addEventListener(Event.COMPLETE, loaded);
function loaded(event:Event):void
{
outputSnd.addEventListener(SampleDataEvent.SAMPLE_DATA, processSound);
outputSnd.play();
}//End of loaded
function processSound(event:SampleDataEvent):void
{
var bytes:ByteArray = new ByteArray();
sourceSnd.extract(bytes, 4096);
event.data.writeBytes(upOctave(bytes));
}//End processSound function
function upOctave(bytes:ByteArray):ByteArray
{
var returnBytes:ByteArray = new ByteArray();
bytes.position = 0;
while(bytes.bytesAvailable > 0)
{
returnBytes.writeFloat(bytes.readFloat());
returnBytes.writeFloat(bytes.readFloat());
if (bytes.bytesAvailable > 0)
{
bytes.position += 8;
}//End if
}//End while
return returnBytes;
}//End upOctave function
}
}/End of class
}//End of package