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; }
public float CalculateVolume() { float num = AudioTools.DBToLinear(_volumeParameter.Get(FabricTimer.Get())); float linear = 1f - (1f - _gain * num); return(AudioTools.LinearToDB(linear)); }
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; }
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; } }
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(); } } }
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 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; } }
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(); } }
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(); }
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 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(); }
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(); }
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); }
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())); }
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); }
public float CalculatePitch() { return(1f + _pitchParameter.Get(FabricTimer.Get())); }