New Dynamic Sound


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var sound:Sound = new Sound();
  2. var noise:Number = 0;
  3.  
  4. function sineWavGenerator(event:SampleDataEvent):void
  5. {
  6. for(var c:int=0; c<2048; c++)
  7. {
  8. noise += mouseX / 44100;
  9. var sample:Number = Math.sin(noise * Math.PI * 2);
  10. event.data.writeFloat(sample);
  11. event.data.writeFloat(sample);
  12. }
  13. }
  14.  
  15. sound.addEventListener("sampleData",sineWavGenerator);
  16. sound.play();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.