差分発生行の前後
無視リスト:
コミット日時:
2009/05/14 00:20:45 (3 年前)
コミッタ:
keim
ログメッセージ:

サウンドライブラリ SiON ver0.5.2.1 更新 debuged

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/SiOPM/trunk/samples/Tutorials/SyncSequence.as

    r2625 r2633  
    1 // Sample for synchronized play 
     1// Sample for synchronized play (with preset voice). 
    22package { 
    33    import flash.display.Sprite; 
     
    1414        public var presetVoice:SiONPresetVoice = new SiONPresetVoice(); 
    1515         
     16        // voice 
     17        public var voiceClick:SiONVoice; 
     18        public var voiceKeyOn:SiONVoice; 
     19         
    1620        // MML data 
    1721        public var mainMelody:SiONData; 
    1822        public var clickSequence:SiONData; 
    19          
    20         // voice 
    21         public var voice:SiONVoice; 
    2223         
    2324         
     
    2829            clickSequence = driver.compile("l16v8o6cg<c>g1"); 
    2930             
    30             // select voice 
    31             voice = presetVoice["valsound.piano8"]; 
     31            // select voice from preset 
     32            voiceClick = presetVoice["valsound.piano8"]; 
     33            voiceKeyOn = presetVoice["valsound.wind1"]; 
    3234             
    3335            // listen click 
    34             stage.addEventListener("click", _onClick); 
     36            stage.addEventListener("click",   _onClick); 
     37            stage.addEventListener("keyDown", _onKeyOn); 
    3538 
    3639            // play main melody 
     
    4144        // click to play sequence. with synchronizaion. 
    4245        private function _onClick(e:Event) : void { 
    43             driver.sequenceOn(clickSequence, voice, 0, 0, 2); 
     46            // play with length=0(play all of sequence), delay=0(no delay), quantize=2(8th beat) 
     47            driver.sequenceOn(clickSequence, voiceClick, 0, 0, 2); 
     48        } 
     49         
     50         
     51        // key down ("1" to "9") to play single note 
     52        private function _onKeyOn(e:KeyboardEvent) : void { 
     53            // calculate note number (60=o5c=key"1") 
     54            var noteNum:int = e.charCode - ("1".charCodeAt()) + 60; 
     55            // key 1-9 to play note 
     56            if (60<=noteNum && noteNum<=68) { 
     57                // play with length=1(8th note), delay=0(no delay), quantize=2(8th beat) 
     58                driver.noteOn(noteNum, voiceKeyOn, 2, 0, 2); 
     59            } 
    4460        } 
    4561    }