X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/1059e1cc0c2ecfa237406949aa26155b6a5b9154..66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83:/interpreter/preprocessor/faust-0.9.47mr3/tools/faust2flash_v0.1/Step_2_FlashBuilder_project/src/Flausht.mxml diff --git a/interpreter/preprocessor/faust-0.9.47mr3/tools/faust2flash_v0.1/Step_2_FlashBuilder_project/src/Flausht.mxml b/interpreter/preprocessor/faust-0.9.47mr3/tools/faust2flash_v0.1/Step_2_FlashBuilder_project/src/Flausht.mxml new file mode 100644 index 0000000..d1481a7 --- /dev/null +++ b/interpreter/preprocessor/faust-0.9.47mr3/tools/faust2flash_v0.1/Step_2_FlashBuilder_project/src/Flausht.mxml @@ -0,0 +1,229 @@ + + + + (inputSound.length*44100/1000)) { + // ran out of buffer + inputSoundPosition = 0; + } + + inputSoundBuffer.position = 0; + inputSound.extract(inputSoundBuffer, 8192, inputSoundPosition); + inputSoundBuffer.position = 0; + faust.api_tick(8192, 1, inputSoundBuffer, event.data); + inputSoundPosition += 8192; + + // uncomment this section to debug in case calling C++ isn't working: + // just copy the mp3 data directly to the output buffer. + /* + inputSound.extract(event.data, 8192, inputSoundPosition); + inputSoundPosition += (8192); + */ + } else { + faust.api_tick(8192, 0, inputSoundBuffer, event.data); + } + } + + // "Start" button callback. + protected function button1_clickHandler(event:MouseEvent):void + { + initFaust(); + dbgtext.text = "Playback started."; + sound.addEventListener(SampleDataEvent.SAMPLE_DATA, soundCallback); + sound.play(); + } + + public function onControlChange(id:int, val:Number):void { + if (!faustOK) return; + faust.api_onControlChange(id, val); + } + + // UI Hooks + public function ui_addButton(label:String, id:int):void { + var b:Button = new Button(); + b.label = label; + b.addEventListener("click", function(evt:Event):void { + onControlChange(id, 1.0); + }); + addElement(b); + } + + public function ui_addToggleButton(label:String, id:int):void { + // toggle/check buttons seem to be identical. + return ui_addCheckButton(label, id); + } + + public function ui_addCheckButton(label:String, id:int):void { + var cb:CheckBox = new CheckBox(); + cb.label = label; + cb.addEventListener("change", + function(evt:SliderEvent):void { + var checked_val:int = cb.selected ? 1.0 : 0.0; + onControlChange(id, checked_val); + }); + } + + + public function ui_addVerticalSlider(label:String, id:int, init:Number, min:Number, max:Number, step:Number):void { + // Just call HSlider since we have a vertical cascade of controls. + return ui_addHorizontalSlider(label, id, init, min, max, step); + } + + public function ui_addHorizontalSlider(label:String, id:int, init:Number, min:Number, max:Number, step:Number):void { + var compGroup:HGroup = new HGroup(); + // Text label + var compLabel:Label = new Label(); + compLabel.text = label; + // Actual control + var compSlider:spark.components.HSlider = new spark.components.HSlider(); + compSlider.minimum = min; + compSlider.maximum = max; + compSlider.liveDragging = true; // update faust params while dragging the slider + compSlider.value = init; + compSlider.valueInterval = step; + compSlider.width = 200; + + compSlider.addEventListener("change", + function(evt:Event):void { + onControlChange(id, compSlider.value); + }); + // wire everything up + compGroup.addElement(compLabel); + compGroup.addElement(compSlider); + addElement(compGroup); + } + + public function ui_addNumEntry(label:String, id:int, init:Number, min:Number, max:Number, step:Number):void { + // TODO: A proper text box requires validation. + // Also, slider controls could probably benefit from numeric input too... + // Create a unified control for {VSlider, HSlider, NumEntry} + return ui_addHorizontalSlider(label, id, init, min, max, step); + } + + + // Layout management + // These are "nice to have" functions but aren't critical. + // It doesn't look like they're widely used. + // TODO: if using Flex, these should be easy enough to implement. + public function ui_openFrameBox(label:String):void { } + public function ui_openTabBox(label:String):void { } + public function ui_openHorizontalBox(label:String):void { } + public function ui_openVerticalBox(label:String):void { } + public function ui_closeBox():void { } + // We don't need a run() notification since we call into Faust code directly. + public function ui_run():void { } + + + // "Load input sound" button callback + protected function button2_clickHandler(evt:MouseEvent):void { + inputSoundOn = false; + if (!inputSound) + inputSound = new Sound(); + var urlReq:URLRequest = new URLRequest(mp3path.text); + inputSound.load(urlReq); + inputSound.addEventListener(Event.COMPLETE, + function(evt:Event):void { + dbgtext.text = "sound finished loading."; + inputSoundOn = true; + inputSoundPosition = 0; + }); + } + + + //"Stop input sound" button callback + protected function button3_clickHandler(event:MouseEvent):void + { + dbgtext.text = "sound stopped."; + inputSoundOn = false; + inputSoundPosition = 0; + } + + ]]> + + + + + + + + + + + + + +