Finally Flash will have built in ability to access the sound output buffer when using FlashPlayer 10 that just has been released.
Tinic Uro have posted a little information about the implementation.
So no more relying on complicated hacks, this is all the code you will need to generate a sine wave (snipped from Tinics post):

  var sound:Sound = new Sound();
  function sineWavGenerator(event:SamplesCallbackEvent):void {
    for ( var c:int=0; c<1234; c++ ) {
      var sample:Number = Math.sin(
               (Number(c+event.position)/Math.PI/2))*0.25;
      sound.samplesCallbackData.writeFloat(sample);
      sound.samplesCallbackData.writeFloat(sample);
    }
  }
  sound.addEventListener("samplesCallback",sineWavGenerator);
  sound.play();
  • Share/Bookmark

Related posts:

  1. Random thoughts on Vectors and samplesCallbackData
  2. Flash Player 10 Sound API changes, SampleData and SampleDataEvent
  3. Tweaking the samplesCallbackEvent loop
  4. SVN version control in Flashdevelop projects
  5. FlashPlayer 10 support in FlashDevelop

One Response to “Sound generation in FlashPlayer 10”

Comments (1)
  1. joshspoon says:

    I posted a dynamic piano with the new SampleDataEvent: http://tinyurl.com/65bzmx

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2010 BlixtSystems Suffusion WordPress theme by Sayontan Sinha