チェンジセット 4285

差分発生行の前後
無視リスト:
コミット日時:
2010/09/01 23:23:40 (2 年前)
コミッタ:
keim
ログメッセージ:

SiON ver0.61 updated

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/SiOPM/trunk/src/org/si/sion/SiONDriver.as

    r4264 r4285  
    959959        { 
    960960            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,  
    962962                tracks:Vector.<SiMMLTrack> = new Vector.<SiMMLTrack>(); 
    963963            for each (var mmlTrack:SiMMLTrack in sequencer.tracks) { 
    964964                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)) { 
    966966                        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); 
    967971                        tracks.push(mmlTrack); 
    968972                    } 
     
    973977         
    974978         
    975         /** Play sequences with synchronizing. 
     979        /** Play sequences with synchronizing. This function only is available after play().  
    976980         *  @param data The SiONData including sequences. This data is used only for sequences. The system ignores wave, envelop and voice data. 
    977981         *  @param voice SiONVoice to play sequence. The voice setting in the sequence has priority. 
     
    10151019         
    10161020         
    1017         /** Stop the sequences with synchronizing. 
     1021        /** Stop the sequences with synchronizing. This function only is available after play().  
    10181022         *  @param trackID tracks id to stop. 
    10191023         *  @param delay sequence off delay units in 16th beat. 
     
    12701274        private function _prepareRender(data:*, renderBuffer:Vector.<Number>, renderBufferChannelCount:int, resetEffector:Boolean) : void 
    12711275        { 
     1276            // same preparation as streaming 
    12721277            _prepareProcess(data, resetEffector); 
     1278             
     1279            // prepare rendering buffer 
    12731280            _renderBuffer = renderBuffer || new Vector.<Number>(); 
    12741281            _renderBufferChannelCount = (renderBufferChannelCount==2) ? 2 : 1; 
    12751282            _renderBufferSizeMax = _renderBuffer.length; 
    12761283            _renderBufferIndex = 0; 
     1284 
     1285            // initialize parameters 
    12771286            _jobProgress = 0.01; 
    12781287            _timeRender = 0; 
     
    13341343        { 
    13351344            if (data is String) { 
     1345                // compile mml and play 
    13361346                _tempData = _tempData || new SiONData(); 
    13371347                _data = compile(data as String, _tempData); 
    13381348            } else { 
     1349                // type check and play 
    13391350                if (!(data == null || data is SiONData)) throw errorDataIncorrect(); 
    13401351                _data = data; 
     
    13421353             
    13431354            // THESE FUNCTIONS ORDER IS VERY IMPORTANT !! 
    1344             module.initialize(_channelCount, _bitRate, _bufferLength); 
    1345             module.reset();                                                 // reset channels 
    1346             if (resetEffector) effector.initialize();                       // reset effector 
     1355            module.initialize(_channelCount, _bitRate, _bufferLength);      // initialize DSP 
     1356            module.reset();                                                 // reset all channels 
     1357            if (resetEffector) effector.initialize();                       // initialize (or reset) effectors 
    13471358            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 inside 
     1359            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 
    13511362            _trackEventQueue.length = 0;                                    // clear event que 
    13521363             
     
    13741385            // first streaming 
    13751386            if (_isFirstStreaming) { 
    1376                 _firstStream(); 
     1387                _onFirstFrameAfterStartingStream(); 
    13771388            } else { 
    13781389                // preserve stop 
     
    13931404         
    13941405         
     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         
    13951417        // on sampleData 
    13961418        private function _streaming(e:SampleDataEvent) : void 
     
    14061428 
    14071429            try { 
     1430                // set streaming flag 
    14081431                _inStreaming = true; 
    14091432                 
    14101433                if (_isPaused || _isFirstStreaming) { 
     1434                    // fill silence 
    14111435                    _fillzero(e.data); 
    14121436                } else { 
     1437                    // process starting time 
    14131438                    var t:int = getTimer(); 
    14141439                     
     
    14581483                     
    14591484                    // 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; 
    14651488                    } 
    14661489                     
     
    14751498                    } 
    14761499                } 
     1500                 
     1501                // reset streaming flag 
    14771502                _inStreaming = false; 
     1503                 
    14781504            } catch (e:Error) { 
    14791505                // error 
     
    14821508                else dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false, e.message)); 
    14831509            } 
    1484         } 
    1485          
    1486          
    1487         // first streaming 
    1488         private function _firstStream() : void { 
    1489             _isFirstStreaming = false; 
    1490              
    1491             // dispatch streaming start event 
    1492             var event:SiONEvent = new SiONEvent(SiONEvent.STREAM_START, this, null, true); 
    1493             dispatchEvent(event); 
    1494             if (event.isDefaultPrevented()) stop();   // canceled 
    14951510        } 
    14961511         
  • as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMChannelBase.as

    r4264 r4285  
    182182        /** buffer index */ 
    183183        public function get bufferIndex() : int { return _bufferIndex; } 
     184         
     185        /** is this channel note on ? */ 
     186        public function get isNoteOn() : Boolean { return _isNoteOn; } 
    184187         
    185188        /** Is idling ? */ 
     
    505508            } 
    506509            _isNoteOn = false; 
    507         } 
    508          
    509          
    510         /** Check note on */ 
    511         public function isNoteOn() : Boolean  
    512         { 
    513             return _isNoteOn; 
    514510        } 
    515511         
  • as3/SiOPM/trunk/src/org/si/sion/module/channels/SiOPMOperator.as

    r4264 r4285  
    565565            _keyon_phase = _pcm_startPoint << _waveFixedBits; 
    566566            ptType = SiOPMTable.PT_PCM; 
    567         } 
    568          
    569          
    570         /** Check note on. */ 
    571         public function isNoteOn() : Boolean 
    572         { 
    573             return (_eg_state < EG_RELEASE); 
    574567        } 
    575568         
  • as3/SiOPM/trunk/src/org/si/sion/sequencer/SiMMLSequencer.as

    r4264 r4285  
    10901090                if (e.next == null || e.next.id != MMLEvent.NOTE) return e.next;  // check next note 
    10911091                var term:int = calcSampleCount(e.length);                         // changing time 
    1092                 _currentTrack.setPitchBend(e.next.data, term);                    // pitch bending 
     1092                _currentTrack._onPitchBend(e.next.data, term);                    // pitch bending 
    10931093            } 
    10941094            return currentExecutor._publishProessingEvent(e); 
  • as3/SiOPM/trunk/src/org/si/sion/sequencer/SiMMLTrack.as

    r4264 r4285  
    434434         
    435435         
    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) : void 
    441         { 
    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          
    458436        /** Limit key on length.  
    459437         *  @param stopDelay delay to key-off. 
     
    462440        { 
    463441            var length:int = stopDelay - _trackStartDelay; 
    464             if (length < _keyOnCounter) { 
    465                 _keyOnLength = stopDelay - _trackStartDelay
     442            if (length < _keyOnLength) { 
     443                _keyOnLength = length
    466444                _keyOnCounter = _keyOnLength; 
    467445            } 
     
    495473            _mmlKeyOn(note); 
    496474            _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); 
    497485        } 
    498486         
     
    827815            } 
    828816             
    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 
    832823            if (bufferingLength <= _trackStartDelay) { 
    833824                _trackStartDelay -= bufferingLength; 
     
    835826            } 
    836827             
     828            // start sounding at this buffering 
    837829            var len:int = bufferingLength - _trackStartDelay; 
    838830            channel.nop(_trackStartDelay); 
     
    887879                        channel.reset(); 
    888880                    } 
    889                 } else if (channel.isNoteOn()) { 
     881                } else if (channel.isNoteOn) { 
    890882                    _keyOff(); 
    891883                    _note = -1; 
     
    997989        private function _toggleKey() : void 
    998990        { 
    999             if (channel.isNoteOn()) _keyOff(); 
     991            if (channel.isNoteOn) _keyOff(); 
    1000992            else _keyOn(); 
    1001993        } 
     
    10241016                } 
    10251017                // previous note off 
    1026                 if (channel.isNoteOn()) { 
     1018                if (channel.isNoteOn) { 
    10271019                    // callback 
    10281020                    if (_callbackBeforeNoteOff != null) _callbackBeforeNoteOff(this); 
     
    11461138         
    11471139         
     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         
    11481162        /** @private [internal] change note length. call from SiMMLSequence._onSlur()/_onSlurWeek() when its masked. */ 
    11491163        internal function _changeNoteLength(length:int) : void 
  • as3/SiOPM/trunk/src/org/si/sion/sequencer/base/MMLExecutor.as

    r4264 r4285  
    3333        // event to process 
    3434        private  var _processEvent:MMLEvent; 
    35         // rest event 
    36         private  var _restEvent:MMLEvent; 
    3735        // note event 
    3836        private  var _noteEvent:MMLEvent; 
     37        // pitchbend event 
     38        private  var _bendEvent:MMLEvent; 
    3939         
    4040        /** @private [internal] current position in tick count. */ 
     
    6161        public function get currentEvent() : MMLEvent { return (pointer === _processEvent) ? pointer.jump : pointer; } 
    6262         
     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         
    6366         
    6467         
     
    7477            _repeatPoint = null; 
    7578            _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); 
    7882            _repeatCounter = null; 
    7983            _currentTickCount = 0; 
     
    161165         
    162166         
     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         
    163185        /** @private [sion sequencer internal] Publish processing event. You should return this function's return in the event handler of NOTE and REST. 
    164186         *  @param e Current event