- コミット日時:
- 2009/05/14 00:20:45 (3 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/SiOPM/trunk/samples/Tutorials/SyncSequence.as
r2625 r2633 1 // Sample for synchronized play 1 // Sample for synchronized play (with preset voice). 2 2 package { 3 3 import flash.display.Sprite; … … 14 14 public var presetVoice:SiONPresetVoice = new SiONPresetVoice(); 15 15 16 // voice 17 public var voiceClick:SiONVoice; 18 public var voiceKeyOn:SiONVoice; 19 16 20 // MML data 17 21 public var mainMelody:SiONData; 18 22 public var clickSequence:SiONData; 19 20 // voice21 public var voice:SiONVoice;22 23 23 24 … … 28 29 clickSequence = driver.compile("l16v8o6cg<c>g1"); 29 30 30 // select voice 31 voice = presetVoice["valsound.piano8"]; 31 // select voice from preset 32 voiceClick = presetVoice["valsound.piano8"]; 33 voiceKeyOn = presetVoice["valsound.wind1"]; 32 34 33 35 // listen click 34 stage.addEventListener("click", _onClick); 36 stage.addEventListener("click", _onClick); 37 stage.addEventListener("keyDown", _onKeyOn); 35 38 36 39 // play main melody … … 41 44 // click to play sequence. with synchronizaion. 42 45 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 } 44 60 } 45 61 }

