/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var sound:Sound = new Sound(); var noise:Number = 0; function sineWavGenerator(event:SampleDataEvent):void { for(var c:int=0; c<2048; c++) { noise += mouseX / 44100; var sample:Number = Math.sin(noise * Math.PI * 2); event.data.writeFloat(sample); event.data.writeFloat(sample); } } sound.addEventListener("sampleData",sineWavGenerator); sound.play();