示例#1
0
 public void Deactivate()
 {
     _activeParameter.SetTarget(FabricTimer.Get(), 0f, _fadeOutTime, _fadeOutCurve);
     _volumeParameter.SetTarget(FabricTimer.Get(), 0f, _fadeOutTime, _fadeOutCurve);
     _pitchParameter.SetTarget(FabricTimer.Get(), 0f, _fadeOutTime, _fadeOutCurve);
     _isActive = false;
 }
示例#2
0
    public float CalculateVolume()
    {
        float num    = AudioTools.DBToLinear(_volumeParameter.Get(FabricTimer.Get()));
        float linear = 1f - (1f - _gain * num);

        return(AudioTools.LinearToDB(linear));
    }
示例#3
0
 public void Activate()
 {
     _activeParameter.SetTarget(FabricTimer.Get(), 1f, _fadeInTime, _fadeInCurve);
     _volumeParameter.SetTarget(FabricTimer.Get(), _volume, _fadeInTime, _fadeInCurve);
     _pitchParameter.SetTarget(FabricTimer.Get(), _pitch, _fadeInTime, _fadeInCurve);
     _isActive = true;
 }
示例#4
0
 public bool IsActive()
 {
     if (!_isActive)
     {
         return(!_activeParameter.HasReachedTarget(FabricTimer.Get()));
     }
     return(true);
 }
 public void Set(Fabric.Component component, float fadeInTime)
 {
     if (!(_audioSource == null))
     {
         _fadeParameter.SetTarget(FabricTimer.Get(), 1f, fadeInTime, 0.5f);
         _audioSource.volume = 0f;
         _component = component;
         if (_vrAudio != null)
         {
             _vrAudio.Set(component);
         }
         _state = AudioVoiceState.Playing;
     }
 }
示例#6
0
 public override bool UpdateInternal(ref Context context)
 {
     if (_looped && _playMode == RandomComponentPlayMode.RandomNoRepeat && _triggerMode == RandomComponentTriggerMode.Retrigger)
     {
         float realtimeDelta = FabricTimer.GetRealtimeDelta();
         _retriggerTimer += realtimeDelta;
         if (_retriggerTimer >= _retriggerTime)
         {
             _componentInstance._instance.SetPlayScheduled(_retriggerTimer - _retriggerTime, 0.0);
             PlayRandomomponent(_componentInstance);
             _retriggerTime  = _delay + UnityEngine.Random.Range(_delayRandomization, _delayMaxRandomization);
             _retriggerTimer = 0f;
         }
     }
     return(base.UpdateInternal(ref context));
 }
示例#7
0
 public override void UpdateParameters()
 {
     if (_distortionLevel.HasReachedTarget())
     {
         return;
     }
     FabricTimer.Get();
     for (int i = 0; i < _dspInstances.Count; i++)
     {
         AudioDistortionFilter audioDistortionFilter = _dspInstances[i] as AudioDistortionFilter;
         if ((bool)audioDistortionFilter)
         {
             audioDistortionFilter.distortionLevel = _distortionLevel.GetValue();
         }
     }
     base.UpdateParameters();
 }
 public void Update()
 {
     for (int i = 0; i < _eventQueue.Count; i++)
     {
         Fabric.Event @event = _eventQueue[i];
         if (@event._delayTimer < @event._delay)
         {
             @event._delayTimer += FabricTimer.GetRealtimeDelta();
             continue;
         }
         ProcessEvent(@event);
         @event._delay      = 0f;
         @event._delayTimer = 0f;
         @event.eventStatus = EventStatus.Handled;
         _eventQueue.RemoveAt(i);
     }
 }
示例#9
0
 public override void UpdateParameters()
 {
     if (!_FrontLeftChannel.HasReachedTarget() || !_FrontRightChannel.HasReachedTarget() || !_CenterChannel.HasReachedTarget() || !_RearLeftChannel.HasReachedTarget() || !_RearRightChannel.HasReachedTarget() || !_LFEChannel.HasReachedTarget())
     {
         FabricTimer.Get();
         if (_samplePlayerComponent != null)
         {
             _samplePlayerComponent._channelGains[0] = _FrontLeftChannel.GetValue();
             _samplePlayerComponent._channelGains[1] = _FrontRightChannel.GetValue();
             _samplePlayerComponent._channelGains[2] = _CenterChannel.GetValue();
             _samplePlayerComponent._channelGains[3] = _LFEChannel.GetValue();
             _samplePlayerComponent._channelGains[4] = _RearLeftChannel.GetValue();
             _samplePlayerComponent._channelGains[5] = _RearRightChannel.GetValue();
         }
         base.UpdateParameters();
     }
 }
 public void SetValue(float value, float time = 0f, float curve = 0.5f, bool forceDirtyFlag = false)
 {
     if (value != _value || forceDirtyFlag)
     {
         _value = value;
         if (_value >= _max)
         {
             _value = _max;
         }
         if (_value <= _min)
         {
             _value = _min;
         }
         _interpolatedParameter.SetTarget(FabricTimer.Get(), value, time, curve);
         _isDirty = true;
     }
 }
示例#11
0
 public void Stop(float fadeOutTime, bool callStop)
 {
     if (!(_audioSource == null))
     {
         if (fadeOutTime > 0f)
         {
             _fadeParameter.SetTarget(FabricTimer.Get(), 0f, fadeOutTime, 0.5f);
             _volume = _audioSource.volume;
             _callStop = callStop;
             _state = AudioVoiceState.Stopping;
         }
         else
         {
             StopAudioVoice();
         }
     }
 }
示例#12
0
    private void Update()
    {
        profiler.Begin();
        if (_useComponentIsPlayingFlag)
        {
            if (_componentToListen != null && _componentToListen.IsComponentActive())
            {
                _sideChainGain = gain;
            }
            else
            {
                _sideChainGain = 1f;
            }
        }
        else
        {
            if (!(_volumeMeter != null))
            {
                _sideChainGain = 1f;
                profiler.End();
                return;
            }
            float mRMS = _volumeMeter.volumeMeterState.mRMS;
            float db   = AudioTools.LinearToDB(mRMS);
            _sideChainGain = AudioTools.DBToNormalizedDB(db);
        }
        float currentTimeMS = FabricTimer.Get();

        if (_sideChainGain > _envelope.GetCurrentValue())
        {
            _envelope.SetTarget(currentTimeMS, _sideChainGain, fadeUpRate, 0.5f);
        }
        else
        {
            _envelope.SetTarget(currentTimeMS, _sideChainGain, fadeDownRate, 0.5f);
        }
        if (_useComponentIsPlayingFlag)
        {
            _sideChainGain = _envelope.Get(currentTimeMS);
        }
        else
        {
            _sideChainGain = 1f - _envelope.Get(currentTimeMS) * gain;
        }
        profiler.End();
    }
 public override void UpdateParameters()
 {
     if (_cutoffFrequency.HasReachedTarget() && _lowpassResonaceQ.HasReachedTarget())
     {
         return;
     }
     FabricTimer.Get();
     for (int i = 0; i < _dspInstances.Count; i++)
     {
         AudioLowPassFilter audioLowPassFilter = _dspInstances[i] as AudioLowPassFilter;
         if ((bool)audioLowPassFilter)
         {
             audioLowPassFilter.cutoffFrequency   = _cutoffFrequency.GetValue();
             audioLowPassFilter.lowpassResonanceQ = _lowpassResonaceQ.GetValue();
         }
     }
     base.UpdateParameters();
 }
示例#14
0
 public void UpdateInternal()
 {
     if (_audioSource == null)
     {
         return;
     }
     if (_vrAudio != null)
     {
         _vrAudio.Update();
     }
     if (_state == AudioVoiceState.Stopping)
     {
         _audioSource.volume = _volume * _fadeParameter.Get(FabricTimer.Get());
         if (_fadeParameter.HasReachedTarget())
         {
             StopAudioVoice();
         }
     }
 }
 public void Update()
 {
     profiler.Begin();
     FabricTimer.Update();
     EventManager.Instance.UpdateInternal();
     for (int i = 0; i < _components.Count; i++)
     {
         _updateContext.Reset();
         Fabric.Component component = _components[i];
         if (component.IsComponentActive())
         {
             component.UpdateInternal(ref _updateContext);
         }
     }
     UpdateMusicTimeSettings();
     UpdateGroupComponentProxies(ref _updateContext);
     if (AudioSourcePoolManager != null)
     {
         AudioSourcePoolManager.Update();
     }
     profiler.End();
 }
示例#16
0
 public override void UpdateParameters()
 {
     if (_dryMix.HasReachedTarget() && _wetMix1.HasReachedTarget() && _wetMix2.HasReachedTarget() && _wetMix3.HasReachedTarget() && _delay.HasReachedTarget() && _rate.HasReachedTarget() && _depth.HasReachedTarget() && _feedback.HasReachedTarget())
     {
         return;
     }
     FabricTimer.Get();
     for (int i = 0; i < _dspInstances.Count; i++)
     {
         AudioChorusFilter audioChorusFilter = _dspInstances[i] as AudioChorusFilter;
         if ((bool)audioChorusFilter)
         {
             audioChorusFilter.dryMix  = _dryMix.GetValue();
             audioChorusFilter.wetMix1 = _wetMix1.GetValue();
             audioChorusFilter.wetMix2 = _wetMix2.GetValue();
             audioChorusFilter.wetMix3 = _wetMix3.GetValue();
             audioChorusFilter.delay   = _delay.GetValue();
             audioChorusFilter.rate    = _rate.GetValue();
             audioChorusFilter.depth   = _depth.GetValue();
         }
     }
     base.UpdateParameters();
 }
示例#17
0
 public override void UpdateParameters()
 {
     if (!_FrontLeftChannel.HasReachedTarget() && !_FrontRightChannel.HasReachedTarget() && !_CenterChannel.HasReachedTarget() && !_SideLeftChannel.HasReachedTarget() && !_SideRightChannel.HasReachedTarget() && !_RearLeftChannel.HasReachedTarget() && !_RearRightChannel.HasReachedTarget() && !_LFEChannel.HasReachedTarget())
     {
         return;
     }
     FabricTimer.Get();
     for (int i = 0; i < _dspInstances.Count; i++)
     {
         AudioPanner audioPanner = _dspInstances[i] as AudioPanner;
         if ((bool)audioPanner)
         {
             audioPanner._channelGains[0] = _FrontLeftChannel.GetValue();
             audioPanner._channelGains[1] = _FrontRightChannel.GetValue();
             audioPanner._channelGains[2] = _CenterChannel.GetValue();
             audioPanner._channelGains[3] = _LFEChannel.GetValue();
             audioPanner._channelGains[4] = _RearLeftChannel.GetValue();
             audioPanner._channelGains[5] = _RearRightChannel.GetValue();
             audioPanner._channelGains[6] = _SideLeftChannel.GetValue();
             audioPanner._channelGains[7] = _SideRightChannel.GetValue();
         }
     }
     base.UpdateParameters();
 }
示例#18
0
 bool GlobalSwitch.IListener.OnSwitch(GlobalSwitch.Switch _switch)
 {
     for (int i = 0; i < _componentInstances.Length; i++)
     {
         ComponentInstance componentInstance = _componentInstances[i];
         if (componentInstance == null)
         {
             continue;
         }
         GlobalSwitchContainer globalSwitchContainer = GetGlobalSwitchContainer(_switch);
         if (globalSwitchContainer == null)
         {
             continue;
         }
         Fabric.Component component = globalSwitchContainer._components[0];
         if (!(component != null) || !(component != _selectedComponent))
         {
             continue;
         }
         bool isComponentActive = _isComponentActive;
         if (_selectedComponent != null)
         {
             _selectedComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f);
         }
         _selectedComponent = component;
         if (_startOnSwitch && isComponentActive && !IsMusicSyncEnabled())
         {
             _componentInstance._instance.ResetPlayScheduled();
             _selectedComponent.PlayInternal(_componentInstance, 0f, 0.5f);
             if (_componentStatus == ComponentStatus.Stopping)
             {
                 StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve);
             }
         }
         if (HasValidEventNotifier())
         {
             NotifyEvent(EventNotificationType.OnSwitch, _selectedComponent);
         }
     }
     return(true);
 }
示例#19
0
    private void SetSwitch(string name, bool ignoreActiveFlag = false)
    {
        int num = 0;

        Fabric.Component component;
        while (true)
        {
            if (num < _components.Count)
            {
                component = _components[num];
                if (component != null && component.Name == name && component != _selectedComponent)
                {
                    break;
                }
                num++;
                continue;
            }
            return;
        }
        bool flag = ignoreActiveFlag || _isComponentActive;

        if (_selectedComponent != null)
        {
            _selectedComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f);
        }
        _selectedComponent = component;
        if (_startOnSwitch && flag && !IsMusicSyncEnabled())
        {
            _componentInstance._instance.ResetPlayScheduled();
            _selectedComponent.PlayInternal(_componentInstance, 0f, 0.5f);
            if (_componentStatus == ComponentStatus.Stopping)
            {
                StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve);
            }
        }
        if (HasValidEventNotifier())
        {
            NotifyEvent(EventNotificationType.OnSwitch, _selectedComponent);
        }
    }
 public float GetValue()
 {
     return(_interpolatedParameter.Get(FabricTimer.Get()));
 }
示例#21
0
        public void UpdateInternal()
        {
            float realtimeDelta = FabricTimer.GetRealtimeDelta();

            if (_direction > 0f)
            {
                _seekTarget += _velocity * realtimeDelta;
            }
            else
            {
                _seekTarget -= _velocity * realtimeDelta;
            }
            _markers.Update(_seekTarget, _direction);
            if (_markers.IsMarkerKeyOff())
            {
                _seekTarget = _markers._keyOffMarker._value;
            }
            if (_velocity != 0f)
            {
                if (_seekTarget > MAX_NORMALISED_RANGE)
                {
                    if (_loopBehaviour == ParameterLoopBehaviour.Loop)
                    {
                        _seekTarget -= MAX_NORMALISED_RANGE - MIN_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.OneShot)
                    {
                        _seekTarget = MAX_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.PingPong)
                    {
                        _direction = -1f;
                    }
                    else
                    {
                        _seekTarget = MAX_NORMALISED_RANGE;
                    }
                    _markers.Reset();
                }
                else if (_seekTarget < MIN_NORMALISED_RANGE)
                {
                    if (_loopBehaviour == ParameterLoopBehaviour.Loop)
                    {
                        _seekTarget += MAX_NORMALISED_RANGE - MIN_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.OneShot)
                    {
                        _seekTarget = MIN_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.PingPong)
                    {
                        _direction = 1f;
                    }
                    else
                    {
                        _seekTarget = MIN_NORMALISED_RANGE;
                    }
                    _markers.Reset();
                }
                if (_seekTarget > MAX_NORMALISED_RANGE)
                {
                    _seekTarget = MAX_NORMALISED_RANGE;
                }
                else if (_seekTarget < MIN_NORMALISED_RANGE)
                {
                    _seekTarget = MIN_NORMALISED_RANGE;
                }
            }
            if (_seekSpeed != 0f)
            {
                float num = _seekSpeed * realtimeDelta;
                if (_seekTarget > _value)
                {
                    _value += num;
                    if (_value > _seekTarget)
                    {
                        _value = _seekTarget;
                    }
                }
                else if (_seekTarget < _value)
                {
                    _value -= num;
                    if (_value < _seekTarget)
                    {
                        _value = _seekTarget;
                    }
                }
            }
            else
            {
                _value = _seekTarget;
            }
            AudioTools.Limit(ref _value, 0f, 1f);
        }
 private bool PlayNextEntry(double offset = 0.0, double scheduledStop = 0.0)
 {
     if (_playlist != null && _playlist.Length > 0)
     {
         int num = _playlist.Length - 1;
         if (_playingComponentIndex > num)
         {
             if (_sequencePlayMode != SequenceComponentPlayMode.Loop)
             {
                 return(false);
             }
             _playingComponentIndex = 0;
             if (HasValidEventNotifier())
             {
                 NotifyEvent(EventNotificationType.OnSequenceEnd, this);
             }
         }
         if (_currentlyPlayingComponent != null && _sequenceType == SequenceComponentType.PlayOnAdvance)
         {
             _currentlyPlayingComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, scheduledStop);
         }
         _prevPlayingComponentIndex = _playingComponentIndex;
         _currentlyPlayingComponent = _playlist[_playingComponentIndex++];
         if (HasValidEventNotifier())
         {
             NotifyEvent(EventNotificationType.OnSequenceNextEntry, _currentlyPlayingComponent);
         }
     }
     if (_currentlyPlayingComponent != null && _componentInstance != null)
     {
         _currentlyPlayingComponent.PlayInternal(_componentInstance, 0f, 0.5f);
         if (_componentStatus == ComponentStatus.Stopping && _onlyStopOnce && _sequenceType != SequenceComponentType.PlayOnAdvance)
         {
             StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve);
             _onlyStopOnce = false;
         }
     }
     return(true);
 }
示例#23
0
 public float CalculatePitch()
 {
     return(1f + _pitchParameter.Get(FabricTimer.Get()));
 }