チェンジセット 4285
- コミット日時:
- 2010/09/01 23:23:40 (2 年前)
- ファイル:
-
- as3/SiOPM/trunk/archive/sion061.swc (更新) (変更前)
- as3/SiOPM/trunk/archive/sion061_asdoc.zip (更新) (変更前)
- as3/SiOPM/trunk/archive/sion061_src.zip (更新) (変更前)
- as3/SiOPM/trunk/src/org/si/sion/SiONDriver.as (更新) (12 diffs)
- as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMChannelBase.as (更新) (2 diffs)
- as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMOperator.as (更新) (1 diff)
- as3/SiOPM/trunk/src/org/si/sion/sequencer/SiMMLSequencer.as (更新) (1 diff)
- as3/SiOPM/trunk/src/org/si/sion/sequencer/SiMMLTrack.as (更新) (9 diffs)
- as3/SiOPM/trunk/src/org/si/sion/sequencer/base/MMLExecutor.as (更新) (4 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/SiOPM/trunk/src/org/si/sion/SiONDriver.as
r4264 r4285 959 959 { 960 960 var internalTrackID:int = (trackID & SiMMLTrack.TRACK_ID_FILTER) | SiMMLTrack.DRIVER_NOTE, 961 delaySamples:int = sequencer.calcSampleDelay(0, delay, quant), 961 delaySamples:int = sequencer.calcSampleDelay(0, delay, quant), n:int, 962 962 tracks:Vector.<SiMMLTrack> = new Vector.<SiMMLTrack>(); 963 963 for each (var mmlTrack:SiMMLTrack in sequencer.tracks) { 964 964 if (mmlTrack._sion_sequencer_internal::_internalTrackID == internalTrackID) { 965 if (note == -1 || (note == mmlTrack.note && mmlTrack.channel.isNoteOn ())) {965 if (note == -1 || (note == mmlTrack.note && mmlTrack.channel.isNoteOn)) { 966 966 mmlTrack.keyOff(delaySamples, stopImmediately); 967 tracks.push(mmlTrack); 968 } else if (mmlTrack.executor.noteWaitingFor == note) { 969 // if this track is waiting for starting sound ... 970 mmlTrack.keyOn(note, 1, delaySamples); 967 971 tracks.push(mmlTrack); 968 972 } … … 973 977 974 978 975 /** Play sequences with synchronizing. 979 /** Play sequences with synchronizing. This function only is available after play(). 976 980 * @param data The SiONData including sequences. This data is used only for sequences. The system ignores wave, envelop and voice data. 977 981 * @param voice SiONVoice to play sequence. The voice setting in the sequence has priority. … … 1015 1019 1016 1020 1017 /** Stop the sequences with synchronizing. 1021 /** Stop the sequences with synchronizing. This function only is available after play(). 1018 1022 * @param trackID tracks id to stop. 1019 1023 * @param delay sequence off delay units in 16th beat. … … 1270 1274 private function _prepareRender(data:*, renderBuffer:Vector.<Number>, renderBufferChannelCount:int, resetEffector:Boolean) : void 1271 1275 { 1276 // same preparation as streaming 1272 1277 _prepareProcess(data, resetEffector); 1278 1279 // prepare rendering buffer 1273 1280 _renderBuffer = renderBuffer || new Vector.<Number>(); 1274 1281 _renderBufferChannelCount = (renderBufferChannelCount==2) ? 2 : 1; 1275 1282 _renderBufferSizeMax = _renderBuffer.length; 1276 1283 _renderBufferIndex = 0; 1284 1285 // initialize parameters 1277 1286 _jobProgress = 0.01; 1278 1287 _timeRender = 0; … … 1334 1343 { 1335 1344 if (data is String) { 1345 // compile mml and play 1336 1346 _tempData = _tempData || new SiONData(); 1337 1347 _data = compile(data as String, _tempData); 1338 1348 } else { 1349 // type check and play 1339 1350 if (!(data == null || data is SiONData)) throw errorDataIncorrect(); 1340 1351 _data = data; … … 1342 1353 1343 1354 // THESE FUNCTIONS ORDER IS VERY IMPORTANT !! 1344 module.initialize(_channelCount, _bitRate, _bufferLength); 1345 module.reset(); // reset channels1346 if (resetEffector) effector.initialize(); // reset effector1355 module.initialize(_channelCount, _bitRate, _bufferLength); // initialize DSP 1356 module.reset(); // reset all channels 1357 if (resetEffector) effector.initialize(); // initialize (or reset) effectors 1347 1358 else effector._reset(); 1348 sequencer._prepareProcess(_data, _sampleRate, _bufferLength); // set track channels (this must be called after module.reset()).1349 if (_data) _parseSystemCommand(_data.systemCommands); // parse #EFFECT (initialize effector inside)1350 effector._prepareProcess(); // set stream number inside1359 sequencer._prepareProcess(_data, _sampleRate, _bufferLength); // set sequencer tracks (should be called after module.reset()) 1360 if (_data) _parseSystemCommand(_data.systemCommands); // parse #EFFECT command (should be called after effector._reset()) 1361 effector._prepareProcess(); // set effector connections 1351 1362 _trackEventQueue.length = 0; // clear event que 1352 1363 … … 1374 1385 // first streaming 1375 1386 if (_isFirstStreaming) { 1376 _ firstStream();1387 _onFirstFrameAfterStartingStream(); 1377 1388 } else { 1378 1389 // preserve stop … … 1393 1404 1394 1405 1406 // first frame after starting stream 1407 private function _onFirstFrameAfterStartingStream() : void { 1408 _isFirstStreaming = false; 1409 1410 // dispatch streaming start event 1411 var event:SiONEvent = new SiONEvent(SiONEvent.STREAM_START, this, null, true); 1412 dispatchEvent(event); 1413 if (event.isDefaultPrevented()) stop(); // canceled 1414 } 1415 1416 1395 1417 // on sampleData 1396 1418 private function _streaming(e:SampleDataEvent) : void … … 1406 1428 1407 1429 try { 1430 // set streaming flag 1408 1431 _inStreaming = true; 1409 1432 1410 1433 if (_isPaused || _isFirstStreaming) { 1434 // fill silence 1411 1435 _fillzero(e.data); 1412 1436 } else { 1437 // process starting time 1413 1438 var t:int = getTimer(); 1414 1439 … … 1458 1483 1459 1484 // dispatch finishSequence event 1460 if (!_isFinishSeqDispatched) { 1461 if (sequencer.isSequenceFinished) { 1462 dispatchEvent(new SiONEvent(SiONEvent.FINISH_SEQUENCE, this)); 1463 _isFinishSeqDispatched = true; 1464 } 1485 if (!_isFinishSeqDispatched && sequencer.isSequenceFinished) { 1486 dispatchEvent(new SiONEvent(SiONEvent.FINISH_SEQUENCE, this)); 1487 _isFinishSeqDispatched = true; 1465 1488 } 1466 1489 … … 1475 1498 } 1476 1499 } 1500 1501 // reset streaming flag 1477 1502 _inStreaming = false; 1503 1478 1504 } catch (e:Error) { 1479 1505 // error … … 1482 1508 else dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false, e.message)); 1483 1509 } 1484 }1485 1486 1487 // first streaming1488 private function _firstStream() : void {1489 _isFirstStreaming = false;1490 1491 // dispatch streaming start event1492 var event:SiONEvent = new SiONEvent(SiONEvent.STREAM_START, this, null, true);1493 dispatchEvent(event);1494 if (event.isDefaultPrevented()) stop(); // canceled1495 1510 } 1496 1511 as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMChannelBase.as
r4264 r4285 182 182 /** buffer index */ 183 183 public function get bufferIndex() : int { return _bufferIndex; } 184 185 /** is this channel note on ? */ 186 public function get isNoteOn() : Boolean { return _isNoteOn; } 184 187 185 188 /** Is idling ? */ … … 505 508 } 506 509 _isNoteOn = false; 507 }508 509 510 /** Check note on */511 public function isNoteOn() : Boolean512 {513 return _isNoteOn;514 510 } 515 511 as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMOperator.as
r4264 r4285 565 565 _keyon_phase = _pcm_startPoint << _waveFixedBits; 566 566 ptType = SiOPMTable.PT_PCM; 567 }568 569 570 /** Check note on. */571 public function isNoteOn() : Boolean572 {573 return (_eg_state < EG_RELEASE);574 567 } 575 568 as3/SiOPM/trunk/src/org/si/sion/sequencer/SiMMLSequencer.as
r4264 r4285 1090 1090 if (e.next == null || e.next.id != MMLEvent.NOTE) return e.next; // check next note 1091 1091 var term:int = calcSampleCount(e.length); // changing time 1092 _currentTrack. setPitchBend(e.next.data, term); // pitch bending1092 _currentTrack._onPitchBend(e.next.data, term); // pitch bending 1093 1093 } 1094 1094 return currentExecutor._publishProessingEvent(e); as3/SiOPM/trunk/src/org/si/sion/sequencer/SiMMLTrack.as
r4264 r4285 434 434 435 435 436 /** Pitch bend (and slur)437 * @param nextNote The 2nd note to intergradate.438 * @param term bending time in sample count.439 */440 public function setPitchBend(nextNote:int, term:int) : void441 {442 var startPitch:int = channel.pitch,443 endPitch :int = (((nextNote + noteShift)<<6) || (startPitch & 63)) + pitchShift;444 _onSlur();445 if (startPitch == endPitch) return;446 447 _sweep_step = ((endPitch - startPitch) << FIXED_BITS) * _env_internval / term;448 _sweep_end = endPitch << FIXED_BITS;449 _sweep_pitch = startPitch << FIXED_BITS;450 _env_pitch_active = true;451 _env_note = _set_env_note[1];452 _env_pitch = _set_env_pitch[1];453 454 _processMode = ENVELOP;455 }456 457 458 436 /** Limit key on length. 459 437 * @param stopDelay delay to key-off. … … 462 440 { 463 441 var length:int = stopDelay - _trackStartDelay; 464 if (length < _keyOn Counter) {465 _keyOnLength = stopDelay - _trackStartDelay;442 if (length < _keyOnLength) { 443 _keyOnLength = length; 466 444 _keyOnCounter = _keyOnLength; 467 445 } … … 495 473 _mmlKeyOn(note); 496 474 _flagNoKeyOn = slur; 475 } 476 477 478 /** Set pitch bending. 479 * @param noteTo Note number bending to. 480 * @param tickLength length of the note after pitch bending. 481 */ 482 public function setPitchBend(noteTo:int, tickLength:int=0) : void 483 { 484 executor.bendingTo(noteTo, tickLength); 497 485 } 498 486 … … 827 815 } 828 816 829 // almost executing this 830 if (_trackStartDelay == 0) return bufferingLength; 831 817 // sounding now, almost executing this 818 if (_trackStartDelay == 0) { 819 return bufferingLength; 820 } 821 822 // wait for starting sound 832 823 if (bufferingLength <= _trackStartDelay) { 833 824 _trackStartDelay -= bufferingLength; … … 835 826 } 836 827 828 // start sounding at this buffering 837 829 var len:int = bufferingLength - _trackStartDelay; 838 830 channel.nop(_trackStartDelay); … … 887 879 channel.reset(); 888 880 } 889 } else if (channel.isNoteOn ()) {881 } else if (channel.isNoteOn) { 890 882 _keyOff(); 891 883 _note = -1; … … 997 989 private function _toggleKey() : void 998 990 { 999 if (channel.isNoteOn ()) _keyOff();991 if (channel.isNoteOn) _keyOff(); 1000 992 else _keyOn(); 1001 993 } … … 1024 1016 } 1025 1017 // previous note off 1026 if (channel.isNoteOn ()) {1018 if (channel.isNoteOn) { 1027 1019 // callback 1028 1020 if (_callbackBeforeNoteOff != null) _callbackBeforeNoteOff(this); … … 1146 1138 1147 1139 1140 /** @private [internal] Set pitch bend (and slur) immediately. This function called from pitchBend() and '*' command. 1141 * @param nextNote The 2nd note to intergradate. 1142 * @param term bending time in sample count. 1143 */ 1144 internal function _onPitchBend(nextNote:int, term:int) : void 1145 { 1146 var startPitch:int = channel.pitch, 1147 endPitch :int = (((nextNote + noteShift)<<6) || (startPitch & 63)) + pitchShift; 1148 _onSlur(); 1149 if (startPitch == endPitch) return; 1150 1151 _sweep_step = ((endPitch - startPitch) << FIXED_BITS) * _env_internval / term; 1152 _sweep_end = endPitch << FIXED_BITS; 1153 _sweep_pitch = startPitch << FIXED_BITS; 1154 _env_pitch_active = true; 1155 _env_note = _set_env_note[1]; 1156 _env_pitch = _set_env_pitch[1]; 1157 1158 _processMode = ENVELOP; 1159 } 1160 1161 1148 1162 /** @private [internal] change note length. call from SiMMLSequence._onSlur()/_onSlurWeek() when its masked. */ 1149 1163 internal function _changeNoteLength(length:int) : void as3/SiOPM/trunk/src/org/si/sion/sequencer/base/MMLExecutor.as
r4264 r4285 33 33 // event to process 34 34 private var _processEvent:MMLEvent; 35 // rest event36 private var _restEvent:MMLEvent;37 35 // note event 38 36 private var _noteEvent:MMLEvent; 37 // pitchbend event 38 private var _bendEvent:MMLEvent; 39 39 40 40 /** @private [internal] current position in tick count. */ … … 61 61 public function get currentEvent() : MMLEvent { return (pointer === _processEvent) ? pointer.jump : pointer; } 62 62 63 /** Note that wait for note on execution ? -1 for not waiting */ 64 public function get noteWaitingFor() : int { return (pointer === _noteEvent) ? _noteEvent.data : -1; } 65 63 66 64 67 … … 74 77 _repeatPoint = null; 75 78 _processEvent = MMLParser._allocEvent(MMLEvent.PROCESS, 0); 76 _restEvent = MMLParser._allocEvent(MMLEvent.REST, 0); 77 _noteEvent = MMLParser._allocEvent(MMLEvent.DRIVER_NOTE, 0); 79 _noteEvent = MMLParser._allocEvent(MMLEvent.DRIVER_NOTE, 0); 80 _bendEvent = MMLParser._allocEvent(MMLEvent.PITCHBEND, 0); 81 _bendEvent.next = MMLParser._allocEvent(MMLEvent.DRIVER_NOTE, 0); 78 82 _repeatCounter = null; 79 83 _currentTickCount = 0; … … 161 165 162 166 167 /** pitch bending, this function only is avilable after calling singleNote(). 168 * @param note Note number bending to. 169 * @param tickLength length of the note after pitch bending. 170 * @return success or failure 171 */ 172 public function bendingTo(note:int, tickLength:int) : Boolean 173 { 174 if (pointer !== _noteEvent) return false; 175 _noteEvent.next = _bendEvent; 176 _bendEvent.length = _noteEvent.length; 177 _noteEvent.length = 0; 178 _bendEvent.next.next = null; 179 _bendEvent.next.data = note; 180 _bendEvent.next.length = tickLength; 181 return true; 182 } 183 184 163 185 /** @private [sion sequencer internal] Publish processing event. You should return this function's return in the event handler of NOTE and REST. 164 186 * @param e Current event

