Changeset 34488 for lang/actionscript
- Timestamp:
- 07/19/09 23:25:57 (3 years ago)
- Location:
- lang/actionscript/flmml/trunk/src
- Files:
-
- 14 modified
-
com/txt_nifty/sketch/flmml/MChannel.as (modified) (8 diffs)
-
com/txt_nifty/sketch/flmml/MEvent.as (modified) (2 diffs)
-
com/txt_nifty/sketch/flmml/MML.as (modified) (7 diffs)
-
com/txt_nifty/sketch/flmml/MOscFcTri.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MOscGbWave.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MOscMod.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MOscPulse.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MOscSaw.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MOscSine.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MOscTriangle.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MSequencer.as (modified) (3 diffs)
-
com/txt_nifty/sketch/flmml/MStatus.as (modified) (1 diff)
-
com/txt_nifty/sketch/flmml/MTrack.as (modified) (2 diffs)
-
flmml.swf (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MChannel.as
r33297 r34488 34 34 private var m_outMode:int; 35 35 private var m_outPipe:int; 36 private var m_ringSens:Number; 37 private var m_ringPipe:int; 38 private var m_syncMode:int; 39 private var m_syncPipe:int; 36 40 public static var PITCH_RESOLUTION:int = 100; 37 41 protected static var s_init:int = 0; … … 42 46 protected static var s_samples:Vector.<Number>; // mono 43 47 protected static var s_pipeArr:Vector.<Vector.<Number>>; 48 protected static var s_syncSources:Vector.<Vector.<Boolean>>; 44 49 protected static var s_lfoDelta:int = 245; 45 50 … … 73 78 setInput(0, 0); 74 79 setOutput(0, 0); 80 setRing(0, 0); 81 setSync(0, 0); 75 82 } 76 83 public static function boot(numSamples:int):void { … … 100 107 } 101 108 } 109 } 110 public static function createSyncSources(num:int):void { 111 s_syncSources = new Vector.<Vector.<Boolean>>(num); 112 for (var i:int = 0; i < num; i++) { 113 s_syncSources[i] = new Vector.<Boolean>(s_samples.length); 114 for (var j:int = 0; j < s_samples.length; j++) { 115 s_syncSources[i][j] = false; 116 } 117 } 102 118 } 103 119 public static function getFrequency(freqNo:int):Number { … … 241 257 m_outPipe = p; 242 258 } 259 public function setRing(s:int, p:int):void { 260 m_ringSens = (1 << (s - 1)) / 8.0; 261 m_ringPipe = p; 262 } 263 public function setSync(m:int, p:int):void { 264 m_syncMode = m; 265 m_syncPipe = p; 266 } 243 267 protected function getNextCutoff():Number { 244 268 var cut:Number = m_lpfFrq + m_lpfAmt * m_envelope2.getNextAmplitudeLinear(); … … 260 284 if (m_osc2Connect == 0) { 261 285 // no input, no LFO 262 m_oscMod1.getSamples(s_samples, start, end); 286 if(m_syncMode == 1){ 287 // sync out 288 m_oscMod1.getSamplesWithSyncOut(s_samples, s_syncSources[m_syncPipe], start, end); 289 }else if(m_syncMode == 2){ 290 // sync in 291 m_oscMod1.getSamplesWithSyncIn(s_samples, s_syncSources[m_syncPipe], start, end); 292 }else{ 293 m_oscMod1.getSamples(s_samples, start, end); 294 } 263 295 if (m_volMode == 0) m_envelope1.ampSamplesLinear(s_samples, start, end, m_ampLevel); 264 296 else m_envelope1.ampSamplesNonLinear(s_samples, start, end, m_ampLevel); … … 277 309 } 278 310 m_oscMod1.setFrequency(getFrequency(freqNo)); 279 m_oscMod1.getSamples(s_samples, s, e); 311 if(m_syncMode == 1){ 312 // sync out 313 m_oscMod1.getSamplesWithSyncOut(s_samples, s_syncSources[m_syncPipe], s, e); 314 }else if(m_syncMode == 2){ 315 // sync in 316 m_oscMod1.getSamplesWithSyncIn(s_samples, s_syncSources[m_syncPipe], s, e); 317 }else{ 318 m_oscMod1.getSamples(s_samples, s, e); 319 } 280 320 if (m_volMode == 0) m_envelope1.ampSamplesLinear(s_samples, s, e, m_ampLevel); 281 321 else m_envelope1.ampSamplesNonLinear(s_samples, s, e, m_ampLevel); … … 313 353 } 314 354 } 355 if (m_ringSens >= 0.000001) { 356 // with ring 357 for(i = start; i < end; i++){ 358 s_samples[i] *= s_pipeArr[m_ringPipe][i] * m_ringSens; 359 } 360 } 315 361 m_formant.run(s_samples, start, end); 316 362 m_filter.run(s_samples, start, end, m_envelope2, m_lpfFrq, m_lpfAmt, m_lpfRes, key); -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MEvent.as
r32952 r34488 43 43 public function setOutput(mode:int, pipe:int):void { set(MStatus.OUTPUT, mode, pipe); } 44 44 public function setExpression(ex:int):void { set(MStatus.EXPRESSION, ex, 0); } 45 public function setRing(sens:int, pipe:int):void { set(MStatus.RINGMODULATE, sens, pipe); } 46 public function setSync(mode:int, pipe:int):void { set(MStatus.SYNC, mode, pipe); } 45 47 public function setDelta(delta:int):void { m_delta = delta; } 46 48 public function getStatus():int { return m_status; } … … 77 79 public function getOutputPipe():int { return m_data1; } 78 80 public function getExpression():int { return m_data0; } 81 public function getRingSens():int { return m_data0; } 82 public function getRingInput():int { return m_data1; } 83 public function getSyncMode():int { return m_data0; } 84 public function getSyncPipe():int { return m_data1; } 79 85 } 80 86 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MML.as
r34284 r34488 24 24 protected var m_warning:String; 25 25 protected var m_maxPipe:int; 26 protected var m_maxSyncSource:int; 26 27 protected static var MAX_PIPE:int = 3; 28 protected static var MAX_SYNCSOURCE:int = 3; 27 29 28 30 public function MML() { … … 87 89 protected function atmark():void { 88 90 var c:String = getChar(); 89 var o:int = 1, a:int = 0, d:int = 64, s:int = 32, r:int = 0 ;91 var o:int = 1, a:int = 0, d:int = 64, s:int = 32, r:int = 0, sens:int = 0, mode:int = 0; 90 92 switch(c) { 91 93 case 'v': // Volume … … 212 214 case 'i': // Input 213 215 { 214 var sens:int= 0;216 sens = 0; 215 217 next(); 216 218 sens = getUInt(sens); … … 228 230 case 'o': // Output 229 231 { 230 var mode:int= 0;232 mode = 0; 231 233 next(); 232 234 mode = getUInt(mode); … … 245 247 // if (n == 1) overwrite 246 248 // if (n == 2) add 249 break; 250 case 'r': // Ring 251 { 252 sens = 0; 253 next(); 254 sens = getUInt(sens); 255 if (getChar() == ',') { 256 next(); 257 a = getUInt(a); 258 if (a > m_maxPipe) a = m_maxPipe; 259 } 260 m_tracks[m_trackNo].recRing(sens, a); 261 } 262 break; 263 case 's': // Sync 264 { 265 mode = 0; 266 next(); 267 mode = getUInt(mode); 268 if (getChar() == ',') { 269 next(); 270 a = getUInt(a); 271 if (mode == 1) { 272 // Sync out 273 if (a > m_maxSyncSource) { 274 m_maxSyncSource = a; 275 if (m_maxSyncSource >= MAX_SYNCSOURCE) m_maxSyncSource = a = MAX_SYNCSOURCE; 276 } 277 } else if (mode == 2) { 278 // Sync in 279 if (a > m_maxSyncSource) a = m_maxSyncSource; 280 } 281 } 282 m_tracks[m_trackNo].recSync(mode, a); 283 } 247 284 break; 248 285 default: … … 749 786 m_noteShift = 0; 750 787 m_maxPipe = 0; 788 m_maxSyncSource = 0; 751 789 752 790 processComment(str); … … 776 814 // initialize modules 777 815 m_sequencer.createPipes(m_maxPipe+1); 816 m_sequencer.createSyncSources(m_maxSyncSource + 1); 778 817 779 818 // dispatch event -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscFcTri.as
r27528 r34488 35 35 } 36 36 } 37 public override function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 38 var i:int; 39 for(i = start; i < end; i++) { 40 if(syncin[i]){ 41 resetPhase(); 42 } 43 samples[i] = s_table[m_phase >> (PHASE_SFT+11)]; 44 m_phase = (m_phase + m_freqShift) & PHASE_MSK; 45 } 46 } 47 public override function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 48 var i:int; 49 for(i = start; i < end; i++) { 50 samples[i] = s_table[m_phase >> (PHASE_SFT+11)]; 51 m_phase += m_freqShift; 52 syncout[i] = (m_phase > PHASE_MSK); 53 m_phase &= PHASE_MSK; 54 } 55 } 37 56 } 38 57 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscGbWave.as
r32842 r34488 59 59 } 60 60 } 61 public override function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 62 var i:int; 63 for(i = start; i < end; i++) { 64 if(syncin[i]){ 65 resetPhase(); 66 } 67 samples[i] = s_table[m_waveNo][m_phase >> (PHASE_SFT+11)]; 68 m_phase = (m_phase + m_freqShift) & PHASE_MSK; 69 } 70 } 71 public override function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 72 var i:int; 73 for(i = start; i < end; i++) { 74 samples[i] = s_table[m_waveNo][m_phase >> (PHASE_SFT+11)]; 75 m_phase += m_freqShift; 76 syncout[i] = (m_phase > PHASE_MSK); 77 m_phase &= PHASE_MSK; 78 } 79 } 61 80 } 62 81 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscMod.as
r27528 r34488 31 31 public function getSamples(samples:Vector.<Number>, start:int, end:int):void { 32 32 } 33 public function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 34 getSamples(samples, start, end); 35 } 36 public function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 37 getSamples(samples, start, end); 38 } 33 39 public function getFrequency():Number { 34 40 return m_frequency; -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscPulse.as
r27528 r34488 29 29 } 30 30 } 31 public override function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 32 var i:int; 33 for(i = start; i < end; i++) { 34 if(syncin[i]){ 35 resetPhase(); 36 } 37 samples[i] = (m_phase < m_pwm) ? 1.0 : -1.0; 38 m_phase = (m_phase + m_freqShift) & PHASE_MSK; 39 } 40 } 41 public override function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 42 var i:int; 43 for(i = start; i < end; i++) { 44 samples[i] = (m_phase < m_pwm) ? 1.0 : -1.0; 45 m_phase += m_freqShift; 46 syncout[i] = (m_phase > PHASE_MSK); 47 m_phase &= PHASE_MSK; 48 } 49 } 31 50 public function setPWM(pwm:Number):void { 32 51 m_pwm = pwm * PHASE_LEN; -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscSaw.as
r28310 r34488 39 39 } 40 40 } 41 public override function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 42 var i:int; 43 for(i = start; i < end; i++) { 44 if(syncin[i]){ 45 resetPhase(); 46 } 47 samples[i] = s_table[m_phase >> PHASE_SFT]; 48 m_phase = (m_phase + m_freqShift) & PHASE_MSK; 49 } 50 } 51 public override function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 52 var i:int; 53 for(i = start; i < end; i++) { 54 samples[i] = s_table[m_phase >> PHASE_SFT]; 55 m_phase += m_freqShift; 56 syncout[i] = (m_phase > PHASE_MSK); 57 m_phase &= PHASE_MSK; 58 } 59 } 41 60 } 42 61 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscSine.as
r27528 r34488 38 38 } 39 39 } 40 public override function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 41 var i:int; 42 for(i = start; i < end; i++) { 43 if(syncin[i]){ 44 resetPhase(); 45 } 46 samples[i] = s_table[m_phase >> PHASE_SFT]; 47 m_phase = (m_phase + m_freqShift) & PHASE_MSK; 48 } 49 } 50 public override function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 51 var i:int; 52 for(i = start; i < end; i++) { 53 samples[i] = s_table[m_phase >> PHASE_SFT]; 54 m_phase += m_freqShift; 55 syncout[i] = (m_phase > PHASE_MSK); 56 m_phase &= PHASE_MSK; 57 } 58 } 40 59 } 41 60 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MOscTriangle.as
r27528 r34488 38 38 } 39 39 } 40 public override function getSamplesWithSyncIn(samples:Vector.<Number>, syncin:Vector.<Boolean>, start:int, end:int):void { 41 var i:int; 42 for(i = start; i < end; i++) { 43 if(syncin[i]){ 44 resetPhase(); 45 } 46 samples[i] = s_table[m_phase >> PHASE_SFT]; 47 m_phase = (m_phase + m_freqShift) & PHASE_MSK; 48 } 49 } 50 public override function getSamplesWithSyncOut(samples:Vector.<Number>, syncout:Vector.<Boolean>, start:int, end:int):void { 51 var i:int; 52 for(i = start; i < end; i++) { 53 samples[i] = s_table[m_phase >> PHASE_SFT]; 54 m_phase += m_freqShift; 55 syncout[i] = (m_phase > PHASE_MSK); 56 m_phase &= PHASE_MSK; 57 } 58 } 40 59 } 41 60 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MSequencer.as
r32587 r34488 1 1 package com.txt_nifty.sketch.flmml { 2 import __AS3__.vec.Vector; 3 4 import flash.events.Event; 2 5 import flash.events.EventDispatcher; 3 6 import flash.events.SampleDataEvent; 4 import flash.events.Event;5 7 import flash.events.TimerEvent; 6 8 import flash.media.Sound; … … 9 11 import flash.media.SoundTransform; 10 12 import flash.utils.*; 11 import __AS3__.vec.Vector;12 13 13 14 public class MSequencer extends EventDispatcher { … … 302 303 MChannel.createPipes(num); 303 304 } 305 public function createSyncSources(num:int):void { 306 MChannel.createSyncSources(num); 307 } 304 308 public function getTotalMSec():uint { 305 309 return m_trackArr[MTrack.TEMPO_TRACK].getTotalMSec(); -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MStatus.as
r32952 r34488 28 28 public static const OUTPUT:int = 25; 29 29 public static const EXPRESSION:int = 26; 30 public static const RINGMODULATE:int = 27; 31 public static const SYNC:int = 28; 30 32 } 31 33 } -
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MTrack.as
r32952 r34488 140 140 m_ch.setExpression(e.getExpression()); 141 141 break; 142 case MStatus.RINGMODULATE: 143 m_ch.setRing(e.getRingSens(), e.getRingInput()); 144 break; 145 case MStatus.SYNC: 146 m_ch.setSync(e.getSyncMode(), e.getSyncPipe()); 147 break; 142 148 case MStatus.CLOSE: 143 149 m_ch.close(); … … 383 389 e.setExpression(ex); 384 390 m_events.push(e); 391 } 392 393 public function recRing(sens:int, pipe:int):void { 394 var e:MEvent = new MEvent(); 395 recDelta(e); 396 e.setRing(sens, pipe); 397 m_events.push(e); 398 } 399 400 public function recSync(mode:int, pipe:int):void { 401 var e:MEvent = new MEvent(); 402 recDelta(e); 403 e.setSync(mode, pipe); 404 m_events.push(e); 385 405 } 386 406
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)