コード例 #1
0
    public double GetDelay(MusicSyncType syncType)
    {
        switch (syncType)
        {
        case MusicSyncType.OnBeat:
            return(_nextBeatTimeEvent - AudioSettings.dspTime);

        case MusicSyncType.OnBar:
            return(_nextBarTimeEvent - AudioSettings.dspTime);

        default:
            return(0.0);
        }
    }
コード例 #2
0
        private void PlayNext(double time)
        {
            Component     component = null;
            MusicSyncType transitionMusicSyncType = GetTransitionMusicSyncType(_activeTransition, _musicTransitionState);

            if (_musicTransitionState == MusicTransitionState.FromComponent)
            {
                if (_activeTransition._transition._component != null)
                {
                    component             = _activeTransition._transition._component;
                    _musicTransitionState = MusicTransitionState.Transition;
                }
                else
                {
                    component             = _activeTransition._toComponent._component;
                    _musicTransitionState = MusicTransitionState.Idle;
                }
            }
            else if (_musicTransitionState == MusicTransitionState.Transition)
            {
                component             = _activeTransition._toComponent._component;
                _musicTransitionState = MusicTransitionState.Idle;
            }
            else
            {
                if (!_toComponent)
                {
                    return;
                }
                component    = _toComponent;
                _toComponent = null;
            }
            if (_currentlyPlayingComponent != null && transitionMusicSyncType != MusicSyncType.OnMarker)
            {
                double scheduleEnd = time;
                if (_currentlyPlayingComponent.FadeOutTime > 0f)
                {
                    scheduleEnd = 0.0;
                }
                _currentlyPlayingComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, scheduleEnd);
            }
            _componentInstance._instance.SetPlayScheduled(time, 0.0);
            component.PlayInternal(_componentInstance, 0f, 0.5f);
            _currentlyPlayingComponent = component;
        }
コード例 #3
0
    public bool CheckIfNextEventIsWithinRange(MusicSyncType syncType, ref double offset)
    {
        double num = AudioSettings.dspTime + _lookAheadTime;

        if (syncType == MusicSyncType.OnBeat && num > _nextBeatTimeEvent)
        {
            offset              = _nextBeatTimeEvent - AudioSettings.dspTime;
            _nextBeatTimeEvent += _notesPerSecond;
            return(true);
        }
        if (syncType == MusicSyncType.OnBar && num > _nextBarTimeEvent)
        {
            offset             = _nextBarTimeEvent - AudioSettings.dspTime;
            _nextBarTimeEvent += _barsPerSecond;
            return(true);
        }
        offset = 0.0;
        return(false);
    }