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 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 actionscript_omr_lib_ToneGenerator(staff:actionscript_omr_lib_Staff) { this.staff=staff; } /** * Handles the PlaybackEngine.READY event * @param 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(); } } }