topical media & game development

talk show tell print

actionscript-omr-lib-ToneGenerator.ax

actionscript-omr-lib-ToneGenerator.ax [swf] flex


  package 
  {
          //import flash.media.Sound;
  //import flash.media.SoundChannel;
  //import flash.media.SoundMixer;
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.events.TimerEvent;
  import flash.utils.Timer;
  
  import nu.mine.flashnet.sound.core.*;
      
          public class @ax-actionscript-omr-lib-ToneGenerator extends Sprite
          {
                  
                   private var engine:PlaybackEngine;
                   private var staff:actionscript_omr_lib_Staff;
      
An example program demonstrating use of nu.mine.flashnet.sound @return

  
                  //var mixer:Soundmixer = new SoundMixer();
                  
                  public function @ax-actionscript-omr-lib-ToneGenerator(staff:actionscript_omr_lib_Staff)
                  {
                  this.staff=staff;
                  
                  }
                  
                      
Handles the PlaybackEngine.READY event
parameter: event PlaybackEngine.READY event

  
      public function play(pitch:Number):void{
                      var playbackBufferSize:uint=2048*6;
  var dataProvider:IAudioDataProvider=new SineWaveProvider(pitch); //create a data source
  
  engine=new PlaybackEngine(dataProvider,playbackBufferSize); //hand the data source to the playback engine, and the buffersize for the engine
  engine.addEventListener(PlaybackEngine.READY,engineReady,false,0,true); //listen for when the engine is ready 
  
                          var timer:Timer=new Timer(2000,2);
                          timer.addEventListener(TimerEvent.TIMER_COMPLETE,timerHandler);
                          timer.start();
  
      }
      private function engineReady(event:Event):void
      {
  
          engine.start(); //commence playback
  
      } 
      
      
                  private function timerHandler(timerEvent:TimerEvent):void
                  {
                          
                  //        dataProvider. 
                  engine.stop();
                  engine.stop();
                  engine.stop();
                    //this.dispatchEvent(new Event("event")); 
                    staff.playNotes();
                  }
                  
                  public function stop():void{
                                  engine.stop();
                  }
  
      
  
          }
  }


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.