チェンジセット 3504
- コミット日時:
- 2010/03/08 23:12:32 (2 年前)
- ファイル:
-
- as3/SiOPM/trunk/src/org/si/sion/effector/SiEffectModule.as (更新) (5 diffs)
- as3/SiOPM/trunk/src/org/si/sion/effector/SiEffectStream.as (更新) (9 diffs)
- as3/SiOPM/trunk/src/org/si/sion/module/SiOPMChannelParam.as (更新) (1 diff)
- as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMChannelFM.as (更新) (3 diffs)
- as3/SiOPM/trunk/src/org/si/sion/utils/Translator.as (更新) (2 diffs)
- as3/SiOPM/trunk/src/org/si/sound/Note.as (更新) (2 diffs)
- as3/SiOPM/trunk/src/org/si/sound/PatternSequencer.as (更新) (7 diffs)
- as3/SiOPM/trunk/src/org/si/sound/RhythmBox.as (更新) (3 diffs)
- as3/SiOPM/trunk/src/org/si/sound/base/EffectChain.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/base/SoundObject.as (更新) (11 diffs)
- as3/SiOPM/trunk/src/org/si/sound/mdx/MDXData.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/mdx/MDXTrack.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/mdx/PDXData.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/APU.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/CPU.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/MMU.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/Mapper.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/MapperNSF.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/NES.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/NESconfig.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/NSFData.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/PAD.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/PPU.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/nsf/ROM.as (追加)
- as3/SiOPM/trunk/src/org/si/sound/smf/SMFData.as (更新) (1 diff)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/SiOPM/trunk/src/org/si/sion/effector/SiEffectModule.as
r3480 r3504 74 74 //-------------------------------------------------------------------------------- 75 75 /** Initialize all effectors. This function is called from SiONDriver.play() with the 2nd argment true. 76 * When you want to connect effectors by code, you have to call this first, then call connect() and SiONDriver.play() with the 2nd argment false.76 * When you want to connect effectors by code, you have to call this first, then call connect() and SiONDriver.play() with the 2nd argment false. 77 77 */ 78 78 public function initialize() : void … … 142 142 _sion_internal function _endProcess() : void 143 143 { 144 var i:int, slot:int, buffer:Vector.<Number>, 144 var i:int, slot:int, buffer:Vector.<Number>, effect:SiEffectStream, 145 145 bufferLength:int = _module.bufferLength, 146 146 output:Vector.<Number> = _module.output, … … 154 154 // global effect (slot1-slot7) 155 155 for (slot=1; slot<SiOPMModule.STREAM_SEND_SIZE; slot++) { 156 if (_globalEffects[slot]) { 157 _globalEffects[slot].process(0, bufferLength, false); 156 effect = _globalEffects[slot]; 157 if (effect) { 158 effect.process(0, bufferLength, false); 159 buffer = effect._stream.buffer; 158 160 for (i=0; i<imax; i++) output[i] += buffer[i]; 159 161 } … … 229 231 { 230 232 if (_globalEffects[slot] == null) _globalEffects[slot] = _allocStream(); 231 _globalEffects[slot].c onnect(effector);233 _globalEffects[slot].chain.push(effector); 232 234 } 233 235 … … 253 255 { 254 256 if (_globalEffects[slot] == null) return null; 255 return _globalEffects[slot].getEffector(index); 257 var chain:Vector.<SiEffectBase> = _globalEffects[slot].chain; 258 return (index<chain.length) ? chain[index] : null; 256 259 } 257 260 as3/SiOPM/trunk/src/org/si/sion/effector/SiEffectStream.as
r3480 r3504 15 15 // valiables 16 16 //-------------------------------------------------------------------------------- 17 /** effector chain */ 18 public var chain:Vector.<SiEffectBase> = new Vector.<SiEffectBase>(); 19 17 20 /** @private [internal] streaming buffer */ 18 21 internal var _stream:SiOPMStream; 19 20 // effector chain21 private var _chain:Vector.<SiEffectBase> = new Vector.<SiEffectBase>();22 22 23 23 // module … … 57 57 // setting 58 58 //-------------------------------------------------------------------------------- 59 /** set all stream send levels by Vector.<int>. 60 * @param param Vector.<int>(8) of all volumes[0-128]. 61 */ 62 public function setAllStreamSendLevels(param:Vector.<int>) : void 63 { 64 var i:int, imax:int = SiOPMModule.STREAM_SEND_SIZE, v:int; 65 for (i=0; i<imax; i++) { 66 v = param[i]; 67 _volumes[i] = (v != int.MIN_VALUE) ? (v * 0.0078125) : 0; 68 } 69 for (_hasEffectSend=false, i=1; i<imax; i++) { 70 if (_volumes[i] > 0) _hasEffectSend = true; 71 } 72 } 73 74 59 75 /** set stream send. 60 76 * @param streamNum stream number[0-7]. The streamNum of 0 means master volume. … … 99 115 public function reset() : void 100 116 { 117 var i:int; 101 118 _stream.buffer.length = _module.bufferLength<<1; 102 for (var i:int=0; i<SiOPMModule.STREAM_SEND_SIZE; i++) { 119 _stream.clear(); 120 121 for (i=0; i<SiOPMModule.STREAM_SEND_SIZE; i++) { 103 122 _volumes[i] = 0; 104 123 _outputStreams[i] = null; … … 113 132 public function free() : void 114 133 { 115 for each (var e:SiEffectBase in _chain) e._isFree = true;116 _chain.length = 0;134 for each (var e:SiEffectBase in chain) e._isFree = true; 135 chain.length = 0; 117 136 } 118 137 … … 121 140 public function prepareProcess() : int 122 141 { 123 if ( _chain.length == 0) return 0;124 _stream.channels = _chain[0].prepareProcess();125 for (var i:int=1; i< _chain.length; i++) _chain[i].prepareProcess();142 if (chain.length == 0) return 0; 143 _stream.channels = chain[0].prepareProcess(); 144 for (var i:int=1; i<chain.length; i++) chain[i].prepareProcess(); 126 145 return _stream.channels; 127 146 } … … 133 152 var i:int, imax:int, effect:SiEffectBase, stream:SiOPMStream, 134 153 buffer:Vector.<Number> = _stream.buffer, channels:int = _stream.channels; 135 imax = _chain.length;154 imax = chain.length; 136 155 for (i=0; i<imax; i++) { 137 channels = _chain[i].process(channels, buffer, startIndex, length);156 channels = chain[i].process(channels, buffer, startIndex, length); 138 157 } 139 158 … … 161 180 // effector connection 162 181 //-------------------------------------------------------------------------------- 163 /** Connect effector at tail.164 * @param effector Effector instance.165 */166 public function connect(effector:SiEffectBase) : void167 {168 _chain.push(effector);169 }170 171 172 182 /** Parse MML for effector 173 183 * @param mml MML string. … … 205 215 if (e) { 206 216 e.mmlCallback(args); 207 c onnect(e);217 chain.push(e); 208 218 } 209 219 } … … 214 224 } 215 225 } 216 217 218 /** Get connected effector219 * @param slot Effector slot number.220 * @param index The index of connected effector.221 * @return Effector instance.222 */223 public function getEffector(index:int) : SiEffectBase224 {225 return (index < _chain.length) ? _chain[index] : null;226 }227 226 } 228 227 } as3/SiOPM/trunk/src/org/si/sion/module/SiOPMChannelParam.as
r3480 r3504 191 191 function $2(p:String, i:int, q:String, j:int) : void { str += " " + p + "=" + String(i) + " / " + q + "=" + String(j) + "\n"; } 192 192 } 193 194 195 /** Set voice by OPM's register value 196 * @param channel pseudo OPM channel number 197 * @param addr register address 198 * @param data register data 199 */ 200 public function setByOPMRegister(channel:int, addr:int, data:int) : SiOPMChannelParam 201 { 202 var v:int, pms:int, ams:int, opp:SiOPMOperatorParam; 203 204 if (addr < 0x20) { // Module parameter 205 switch(addr) { 206 case 15: // NOIZE:7 FREQ:4-0 for channel#7 207 if (channel == 7 && data & 128) { 208 operatorParam[3].setPGType(SiOPMTable.PG_NOISE_PULSE); 209 operatorParam[3].fixedPitch = ((data & 31) << 6) + 2048; 210 } 211 break; 212 case 24: // LFO FREQ:7-0 for all 8 channels 213 lfoFreqStep = SiOPMTable.instance.lfo_timerSteps[data]; 214 break; 215 case 25: // A(0)/P(1):7 DEPTH:6-0 for all 8 channels 216 if (data & 128) pmd = data & 127; 217 else amd = data & 127; 218 break; 219 case 27: // LFO WS:10 for all 8 channels 220 lfoWaveShape = data & 3 221 break; 222 } 223 } else { 224 if (channel == (addr&7)) { 225 if (addr < 0x40) { 226 // Channel parameter 227 switch((addr-0x20) >> 3) { 228 case 0: // L:7 R:6 FB:5-3 ALG:2-0 229 v = data >> 6; 230 volumes[0] = (v) ? 0.5 : 0; 231 pan = (v==1) ? 128 : (v==2) ? 0 : 64; 232 fb = (data >> 3) & 7; 233 alg = (data ) & 7; 234 break; 235 case 1: // KC:6-0 236 break; 237 case 2: // KF:6-0 238 break; 239 case 3: // PMS:6-4 AMS:10 240 pms = (data >> 4) & 7; 241 ams = (data ) & 3; 242 //pmd = (pms<6) ? (_pmd >> (6-pms)) : (_pmd << (pms-5)); 243 //amd = (ams>0) ? (_amd << (ams-1)) : 0; 244 break; 245 } 246 } else { 247 // Operator parameter 248 opp = operatorParam[[0,2,1,3][(addr >> 3) & 3]]; 249 switch((addr-0x40) >> 5) { 250 case 0: // DT1:6-4 MUL:3-0 251 opp.dt1 = (data >> 4) & 7; 252 opp.mul = (data ) & 15; 253 break; 254 case 1: // TL:6-0 255 opp.tl = data & 127; 256 break; 257 case 2: // KS:76 AR:4-0 258 opp.ksr = (data >> 6) & 3; 259 opp.ar = (data & 31) << 1; 260 break; 261 case 3: // AMS:7 DR:4-0 262 opp.ams = ((data >> 7) & 1)<<1; 263 opp.dr = (data & 31) << 1; 264 break; 265 case 4: // DT2:76 SR:4-0 266 opp.detune = [0, 384, 500, 608][(data >> 6) & 3]; 267 opp.sr = (data & 31) << 1; 268 break; 269 case 5: // SL:7-4 RR:3-0 270 opp.sl = (data >> 4) & 15; 271 opp.rr = (data & 15) << 2; 272 break; 273 } 274 } 275 } 276 } 277 return this; 278 } 279 280 281 /** Set voice by OPNA's register value */ 282 public function setByOPNARegister(addr:int, data:int) : SiOPMChannelParam { 283 throw new Error("SiOPMChannelParam.setByOPNARegister(): Sorry, this function is not available."); 284 return this; 285 } 193 286 } 194 287 } as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMChannelFM.as
r3480 r3504 79 79 /** LFO_TIMER_INITIAL * freq_ratio */ protected var _lfo_timer_initial:int; 80 80 81 /** register map type */ 82 _sion_internal var registerMapType:int; 81 83 82 84 … … 326 328 327 329 330 /** set register */ 331 override public function setRegister(addr:int, data:int) : void 332 { 333 switch(_sion_internal::registerMapType) { 334 case 1: 335 _setByOPMRegister(addr, data); 336 break; 337 case 0: 338 default: 339 _setBy2A03Register(addr, data); 340 break; 341 } 342 } 343 344 345 // 2A03 register value 346 private function _setBy2A03Register(addr:int, data:int) : void 347 { 348 } 349 350 351 // OPM register value 352 private function _setByOPMRegister(addr:int, data:int) : void 353 { 354 } 355 356 328 357 329 358 … … 490 519 operator[0].initialize(); 491 520 _isNoteOn = false; 521 _sion_internal::registerMapType = 0; 492 522 493 523 // initialize sound channel as3/SiOPM/trunk/src/org/si/sion/utils/Translator.as
r3450 r3504 8 8 import org.si.sion.module.*; 9 9 import org.si.sion.sequencer.SiMMLTable; 10 import org.si.sion.effector.SiEffectModule; 11 import org.si.sion.effector.SiEffectBase; 10 12 11 13 … … 335 337 336 338 339 // Effector 340 //-------------------------------------------------- 341 // parse effector MML string 342 //-------------------------------------------------- 343 /** parse effector mml */ 344 static public function parseEffectorMML(mml:String, postfix:String="") : Array 345 { 346 var ret:Array, res:*, rex:RegExp = /([a-zA-Z_]+|,)\s*([.\-\d]+)?/g, i:int, 347 cmd:String = "", argc:int = 0, args:Vector.<Number> = new Vector.<Number>(16, true); 348 349 // clear 350 ret = []; 351 _clearArgs(); 352 353 // parse mml 354 res = rex.exec(mml); 355 while (res) { 356 if (res[1] == ",") { 357 args[argc++] = Number(res[2]); 358 } else { 359 _connectEffect(); 360 cmd = res[1]; 361 _clearArgs(); 362 args[0] = Number(res[2]); 363 argc = 1; 364 } 365 res = rex.exec(mml); 366 } 367 _connectEffect(); 368 369 return ret; 370 371 // connect new effector 372 function _connectEffect() : void { 373 if (argc == 0) return; 374 var e:SiEffectBase = SiEffectModule.getInstance(cmd); 375 if (e) { 376 e.mmlCallback(args); 377 ret.push(e); 378 } 379 } 380 381 // clear arguments 382 function _clearArgs() : void { 383 for (var i:int=0; i<16; i++) args[i]=Number.NaN; 384 } 385 } 386 387 388 389 337 390 // FM parameters 338 391 //-------------------------------------------------- as3/SiOPM/trunk/src/org/si/sound/Note.as
r3480 r3504 10 10 public class Note 11 11 { 12 /** Note number[-1-127], -1 sets playing with sequencers default note. */ 12 // variables 13 //-------------------------------------------------- 14 /** Note number[-1-127], -1 (or all negatives) sets playing with sequencers default note. */ 13 15 public var note:int = 0; 14 /** Velocity[-1-128], -1 sets playing with sequencers default velocity, 0 sets no note (rest). */16 /** Velocity[-1-128], -1 (or all negatives) sets playing with sequencers default velocity, 0 sets no note (rest). */ 15 17 public var velocity:int = 0; 16 18 /** Length in 16th beat [16 for whole tone], Number.NaN sets playing with sequencers default length. */ 17 19 public var length:Number = 0; 20 /** Voice index refering from PatternSequencer.voiceList, -1 (or all negatives) sets no voice changing. @see si.org.sound.PatternSequencer.voiceList */ 21 public var voiceIndex:Number = 0; 18 22 19 23 24 25 26 // constructor 27 //-------------------------------------------------- 20 28 /** constructor 21 29 * @param note Note number[-1-127], -1 sets playing with sequencer's default note. 22 30 * @param velocity Velocity[-1-128], -1 sets playing with sequencer's default velocity, 0 sets no note (rest). 23 31 * @param length Length in 16th beat [16 for whole tone], Number.NaN sets playing with sequencers default length. 32 * @param voiceIndex Voice index refering from PatternSequencer.voiceList, -1 (or all negatives) sets no voice changing. @see si.org.sound.PatternSequencer.voiceList. 24 33 */ 25 function Note(note:int=-1, velocity:int=0, length:Number=Number.NaN )34 function Note(note:int=-1, velocity:int=0, length:Number=Number.NaN, voiceIndex:int=-1) 26 35 { 27 setNote(note, velocity, length); 36 this.note = note; 37 this.velocity = velocity; 38 this.length = length; 39 this.voiceIndex = voiceIndex; 28 40 } 29 41 30 42 43 44 45 // operations 46 //-------------------------------------------------- 31 47 /** Set note. 32 48 * @param note Note number[-1-127], -1 sets playing with sequencer's default note. 33 49 * @param velocity Velocity[-1-128], -1 sets playing with sequencer's default velocity, 0 sets no note (rest). 34 50 * @param length Length in 16th beat [16 for whole tone], Number.NaN sets playing with sequencers default length. 51 * @param voiceIndex Voice index refering from PatternSequencer.voiceList, -1 (or all negatives) sets no voice changing. @see si.org.sound.PatternSequencer.voiceList. 35 52 * @return this instance. 36 53 */ 37 public function setNote(note:int=-1, velocity:int=-1, length:Number=Number.NaN ) : Note54 public function setNote(note:int=-1, velocity:int=-1, length:Number=Number.NaN, voiceIndex:int=-1) : Note 38 55 { 39 56 this.note = note; 40 57 this.velocity = velocity; 41 58 this.length = length; 59 this.voiceIndex = voiceIndex; 42 60 return this; 43 61 } … … 50 68 return this; 51 69 } 70 71 72 /** Copy from another note. 73 * @param src source note instnace. 74 * @return this instance 75 */ 76 public function copyFrom(src:Note) : Note { 77 if (src == null) return setRest(); 78 note = src.note; 79 velocity = src.velocity; 80 length = src.length; 81 voiceIndex = src.voiceIndex; 82 return this; 83 } 84 85 86 /** return new instance copied parameters from this note. 87 * @return new clone instance 88 */ 89 public function clone() : Note { 90 return new Note(note, velocity, length, voiceIndex); 91 } 52 92 } 53 93 } as3/SiOPM/trunk/src/org/si/sound/PatternSequencer.as
r3480 r3504 25 25 /** note pattern */ 26 26 public var pattern:Vector.<Note>; 27 /** voice list refered by Note.voiceIndex. @see org.si.sound.Note.voiceIndex */ 28 public var voiceList:Array; 27 29 28 30 /** portament */ … … 48 50 protected var _currentNote:Note; 49 51 52 /** default pattern, this pattern is used when notes or velocities propertiy is called */ 53 protected var _defaultPattern:Vector.<Note>; 54 50 55 51 56 … … 67 72 68 73 69 /** note.*/74 /** curent note */ 70 75 override public function get note() : int { 71 if (_currentNote==null || _currentNote.note ==-1) return _note;76 if (_currentNote==null || _currentNote.note<0) return _note; 72 77 return _currentNote.note; 73 78 } … … 77 82 78 83 79 /** velocity. */84 /** curent note's velocity. */ 80 85 public function get velocity() : int { 81 if (_currentNote==null || _currentNote.velocity ==-1) return _velocity;86 if (_currentNote==null || _currentNote.velocity<0) return _velocity; 82 87 return _currentNote.velocity; 83 88 } 84 89 public function set velocity(v:int) : void { 85 90 _velocity = v; 91 } 92 93 94 /** Array of sequence's notes. */ 95 public function set notes(list:Array) : void { 96 var i:int, pi:int, li:int; 97 if (pattern && pattern !== _defaultPattern) { 98 for (i=0; i<16; i++) { 99 pi = i % pattern.length; 100 _defaultPattern[i].copyFrom(pattern[pi]); 101 } 102 } 103 for (i=0; i<16; i++) { 104 li = i % list.length; 105 _defaultPattern[i].note = list[li]; 106 } 107 pattern = _defaultPattern; 108 } 109 110 111 /** Array of sequence's velocities */ 112 public function set velocities(list:Array) : void { 113 var i:int, pi:int, li:int; 114 if (pattern && pattern !== _defaultPattern) { 115 for (i=0; i<16; i++) { 116 pi = i % pattern.length; 117 _defaultPattern[i].copyFrom(pattern[pi]); 118 } 119 } 120 for (i=0; i<16; i++) { 121 li = i % list.length; 122 _defaultPattern[i].velocity = list[li]; 123 } 124 pattern = _defaultPattern; 125 } 126 127 128 /** Array of sequence's voice indicies */ 129 public function set voiceIndicies(list:Array) : void { 130 var i:int, pi:int, li:int; 131 if (pattern && pattern !== _defaultPattern) { 132 for (i=0; i<16; i++) { 133 pi = i % pattern.length; 134 _defaultPattern[i].copyFrom(pattern[pi]); 135 } 136 } 137 for (i=0; i<16; i++) { 138 li = i % list.length; 139 _defaultPattern[i].voiceIndex = list[li]; 140 } 141 pattern = _defaultPattern; 86 142 } 87 143 … … 112 168 super("Pattern sequencer"); 113 169 pattern = null; 170 voiceList = null; 114 171 onEnterSegument = null; 115 172 _data = new SiONData(); … … 129 186 _currentNote = null; 130 187 quantize = 16; 188 189 _defaultPattern = new Vector.<Note>(16); 190 for (var i:int=0; i<16; i++) _defaultPattern[i] = new Note(); 131 191 132 192 this.division = division; … … 177 237 if (_currentNote && _currentNote.velocity > 0) { 178 238 var sampleLength:int = driver.sequencer.calcSampleLength(length); 179 _track.setNote(note, sampleLength, (_portament>0));180 _track.velocity = velocity;181 239 if (onNoteOn != null) onNoteOn(); 240 // voice change 241 if (voiceList && _currentNote.voiceIndex >= 0) { 242 voice = voiceList[_currentNote.voiceIndex]; 243 } 182 244 if (_synthesizer._synthesizer_internal::_requireVoiceUpdate) { 183 245 _synthesizer.setTrackVoice(_track); 184 } 246 } 247 _track.velocity = velocity; 248 _track.setNote(note, sampleLength, (_portament>0)); 185 249 } 186 250 _pointer++; as3/SiOPM/trunk/src/org/si/sound/RhythmBox.as
r3480 r3504 29 29 public var hihat:PatternSequencer; 30 30 31 protected var _closeHHPattern:Vector.<int>;32 protected var _openHHPattern:Vector.<int>;33 protected var _hhVoiceIndex:Vector.<int>;34 protected var _hhVoices:Vector.<SiONVoice>;35 protected var _currentHHIndex:int;36 37 31 38 32 … … 40 34 // properties 41 35 //---------------------------------------- 42 /** bass drum velocity pattern*/43 public function set bassPattern( pat:Array) : void36 /** bass drum pattern number */ 37 public function set bassPattern(index:int) : void 44 38 { 45 var i:int, len:int = pat.length;46 for (i=0; i<16; i++) {47 bass.pattern[i].velocity = pat[i % len];48 }49 39 } 50 40 51 41 52 /** snare drum velocity pattern*/53 public function set snarePattern( pat:Array) : void42 /** snare drum pattern number */ 43 public function set snarePattern(index:int) : void 54 44 { 55 var i:int, len:int = pat.length;56 for (i=0; i<16; i++) {57 snare.pattern[i].velocity = pat[i % len];58 }59 45 } 60 46 61 47 62 /** close hi-hat cymbal velocity pattern*/63 public function set closeHHPattern(pat:Array) : void48 /** close hi-hat cymbal pattern number */ 49 public function set hihatPattern(index:int) : void 64 50 { 65 var i:int, len:int = pat.length;66 for (i=0; i<16; i++) _closeHHPattern[i] = pat[i % len];67 _updateHHPatterns();68 }69 70 71 /** open hi-hat cymbal velocity pattern */72 public function set openHHPattern(pat:Array) : void73 {74 var i:int, len:int = pat.length;75 for (i=0; i<16; i++) _openHHPattern[i] = pat[i % len];76 _updateHHPatterns();77 }78 79 80 /** close hi-hat cymbal voice */81 public function set closeHHVoice(v:SiONVoice) : void82 {83 _hhVoices[0] = v;84 hihat.voice = v;85 }86 87 88 /** open hi-hat cymbal voice */89 public function set openHHVoice(v:SiONVoice) : void90 {91 _hhVoices[1] = v;92 51 } 93 52 … … 102 61 super("RhythmBox"); 103 62 _interruptStep = 120; 104 _closeHHPattern = new Vector.<int>(16, true);105 _openHHPattern = new Vector.<int>(16, true);106 _hhVoiceIndex = new Vector.<int>(16, true);107 _hhVoices = new Vector.<SiONVoice>(2, true);108 63 addChild(bass = new PatternSequencer(16, 36, 255, 1)); 109 64 addChild(snare = new PatternSequencer(16, 68, 128, 1)); 110 65 addChild(hihat = new PatternSequencer(16, 68, 64, 1)); 111 bass.pattern = new Vector.<Note>();112 snare.pattern = new Vector.<Note>();113 hihat.pattern = new Vector.<Note>();114 hihat.onNoteOn = _onNoteOnHH;115 for (var i:int=0; i<16; i++) {116 bass.pattern[i] = new Note();117 snare.pattern[i] = new Note();118 hihat.pattern[i] = new Note();119 _hhVoiceIndex[i] = 0;120 }121 }122 123 124 125 126 // settings127 //----------------------------------------128 /** Get track volume */129 public function getTrackVolume(trackIndex:int) : Number {130 return _soundList[trackIndex].volume;131 }132 133 134 /** Set track volume */135 public function setTrackVolume(trackIndex:int, v:Number) : void {136 _soundList[trackIndex].volume = v;137 }138 139 140 /** Get track voice */141 public function getTrackVoice(trackIndex:int) : SiONVoice {142 return _soundList[trackIndex].voice;143 }144 145 146 /** Set track voice */147 public function setTrackVoice(trackIndex:int, v:SiONVoice) : void {148 _soundList[trackIndex].voice = v;149 }150 151 152 153 154 // operations155 //----------------------------------------156 /** @inhriteDoc */157 override public function play() : void {158 _currentHHIndex = 0;159 super.play();160 }161 162 163 164 165 // internal166 //----------------------------------------167 /** call after updating hi-hat patterns */168 protected function _updateHHPatterns() : void {169 var i:int, vel:int;170 for (i=0; i<16; i++) {171 if (_openHHPattern[i] > 0) {172 vel = _openHHPattern[i];173 _hhVoiceIndex[i] = 2;174 } else {175 vel = _closeHHPattern[i];176 _hhVoiceIndex[i] = (vel==0) ? 0 : 1;177 }178 hihat.pattern[i].velocity = vel;179 }180 }181 182 183 /** handler for hi-hat note on */184 private function _onNoteOnHH() : void {185 var voiceIndex:int = _hhVoiceIndex[hihat.frameCount];186 if (voiceIndex != 0 && voiceIndex != _currentHHIndex) {187 hihat.voice = _hhVoices[voiceIndex-1];188 _currentHHIndex = voiceIndex;189 }190 66 } 191 67 } as3/SiOPM/trunk/src/org/si/sound/base/SoundObject.as
r3480 r3504 8 8 package org.si.sound.base { 9 9 import org.si.sion.*; 10 import org.si.sion.utils.Translator; 10 11 import org.si.sion.module.SiOPMModule; 12 import org.si.sion.effector.SiEffectBase; 11 13 import org.si.sion.sequencer.SiMMLTrack; 12 14 import org.si.sound.synthesizer.SynthesizerBase; … … 36 38 /** Synthesizer instance to use SiONVoice */ 37 39 protected var _defaultSynthesizer:SynthesizerBase; 40 /** Effect chain instance */ 41 protected var _effectChain:EffectChain; 38 42 /** track for noteOn() */ 39 43 protected var _track:SiMMLTrack; … … 225 229 226 230 231 /** Effectors to process this sound object's output. You can set effectors by SiEffectBase, Array of SiEffectBase, EffecChain or effector MML String. 232 */ 233 public function get effectors() : * { 234 return _effectChain.effectList; 235 } 236 public function set effectors(obj:*) :void { 237 if (_effectChain) _effectChain.free(); 238 if (obj == null) { 239 _effectChain = null; 240 } else 241 if (obj is SiEffectBase) { 242 _effectChain = EffectChain.alloc([obj]); 243 } else 244 if (obj is Array) { 245 _effectChain = EffectChain.alloc(obj as Array); 246 } else 247 if (obj is String) { 248 var list:Array = Translator.parseEffectorMML(obj as String); 249 _effectChain = EffectChain.alloc(list); 250 } else 251 if (obj is EffectChain) { 252 _effectChain = obj as EffectChain; 253 } 254 } 255 256 227 257 // counter to asign unique track id 228 258 static private var _uniqueTrackID:int = 0; … … 240 270 _synthesizer = _defaultSynthesizer = new SynthesizerBase(); 241 271 _synthesizer._synthesizer_internal::_owner = this; 272 _effectChain = null; 242 273 _track = null; 243 274 _tracks = null; … … 286 317 _quantize = 1; 287 318 319 _effectChain = null; 288 320 _volumes[0] = 64; 289 321 for (var i:int=1; i<SiOPMModule.STREAM_SEND_SIZE; i++) _volumes[i] = 0; … … 303 335 _thisPan = 0; 304 336 _thisMute = false; 305 }337 } 306 338 307 339 … … 370 402 var v:SiONVoice = voice, 371 403 t:SiMMLTrack = driver.noteOn(note, v, _length, _delay, _quantize, _trackID, isDisposable); 372 t.channel.setAllStreamSendLevels(_volumes); 404 if (_effectChain && _effectChain.effectList.length > 0) { 405 _effectChain._activateLocalEffect(); 406 _effectChain.setAllStreamSendLevels(_volumes); 407 t.channel.masterVolume = 128; 408 t.channel.setStreamBuffer(0, _effectChain.streamingBuffer); 409 } else { 410 t.channel.setAllStreamSendLevels(_volumes); 411 } 373 412 t.channel.pan = _pan; 374 413 t.channel.mute = _mute; … … 389 428 { 390 429 if (!driver) return null; 430 if (_effectChain) _effectChain._inactivateLocalEffect(); 391 431 return driver.noteOff(note, _trackID, _delay, _quantize, stopImmediately); 392 432 } … … 403 443 if (!driver) return null; 404 444 var len:Number = (applyLength) ? _length : 0; 405 var v:SiONVoice = voice, 445 var v:SiONVoice = voice, effectActive:Boolean = false, 406 446 list:Vector.<SiMMLTrack> = driver.sequenceOn(data, v, len, _delay, _quantize, _trackID, isDisposable), 407 447 t:SiMMLTrack, ps:int = _pitchShift * 64, pb:int = _pitchBend * 64; 448 if (_effectChain && _effectChain.effectList.length > 0) { 449 _effectChain._activateLocalEffect(); 450 _effectChain.setAllStreamSendLevels(_volumes); 451 effectActive = true; 452 } 408 453 for each (t in list) { 409 t.channel.setAllStreamSendLevels(_volumes); 454 if (effectActive) { 455 t.channel.masterVolume = 128; 456 t.channel.setStreamBuffer(0, _effectChain.streamingBuffer); 457 } else { 458 t.channel.setAllStreamSendLevels(_volumes); 459 } 410 460 t.channel.pan = _pan; 411 461 t.channel.mute = _mute; … … 414 464 t.pitchShift = ps; 415 465 t.setEventTrigger(_eventTriggerID, _noteOnTrigger, _noteOffTrigger); 416 if ( isNaN(v.gateTime)) t.quantRatio = _gateTime;466 if (v && isNaN(v.gateTime)) t.quantRatio = _gateTime; 417 467 } 418 468 return list; … … 427 477 { 428 478 if (!driver) return null; 479 if (_effectChain) _effectChain._inactivateLocalEffect(); 429 480 return driver.sequenceOff(_trackID, 0, _quantize, stopImmediately); 430 481 } as3/SiOPM/trunk/src/org/si/sound/smf/SMFData.as
r3480 r3504 14 14 package org.si.sound.smf { 15 15 import flash.utils.ByteArray; 16 import org.si.sound.smf.*;17 16 18 17

