示例#1
0
        public float CalculateVolume()
        {
            float num    = AudioTools.DBToLinear(_volumeParameter.Get(FabricTimer.Get()));
            float linear = 1f - (1f - _gain * num);

            return(AudioTools.LinearToDB(linear));
        }
示例#2
0
 private void Update()
 {
     if (!_isInitialised)
     {
         _groupComponents = FabricManager.Instance.gameObject.GetComponentsInChildren <GroupComponent>();
         _isInitialised   = true;
     }
     if (_presetList != null)
     {
         for (int i = 0; i < _presetList.Length; i++)
         {
             Preset preset = _presetList[i];
             if (preset.HasEventNameSet() && preset.IsEventActive())
             {
                 AddPreset(preset);
             }
         }
     }
     if (_groupComponents == null)
     {
         return;
     }
     for (int j = 0; j < _groupComponents.Length; j++)
     {
         GroupComponent groupComponent = _groupComponents[j];
         float          num            = 0f;
         float          num2           = 1f;
         for (int k = 0; k < _activePresets.Count; k++)
         {
             Preset preset2 = _activePresets[k];
             if (preset2.HasEventNameSet() && !preset2.IsEventActive() && !preset2.IsDeactivating)
             {
                 preset2.Deactivate();
             }
             if (preset2.IsActive())
             {
                 GroupPreset groupComponentByID = preset2.GetGroupComponentByID(groupComponent.GetInstanceID());
                 if (groupComponentByID != null)
                 {
                     num  += groupComponentByID.CalculateVolume();
                     num2 *= groupComponentByID.CalculatePitch();
                 }
             }
             else
             {
                 _activePresets.Remove(preset2);
             }
         }
         float value = AudioTools.DBToLinear(num);
         AudioTools.Limit(ref value, 0f, 1f);
         groupComponent.MixerVolume = value;
         groupComponent.MixerPitch  = num2;
     }
 }