예제 #1
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();
    }
예제 #2
0
 public void Update()
 {
     profiler.Begin();
     if (samples != null && audioComponents != null)
     {
         Array.Clear(samples, 0, samples.Length);
         for (int i = 0; i < audioComponents.Length; i++)
         {
             AudioComponent audioComponent = audioComponents[i];
             if (!(audioComponent != null) || !audioComponent.IsPlaying() || !(audioComponent.AudioSource != null))
             {
                 continue;
             }
             AudioSource audioSource = audioComponent.AudioSource;
             if (!audioSource.isPlaying || !(audioComponent.ParentGameObject != null))
             {
                 continue;
             }
             float num = 0f;
             if (_is3D)
             {
                 float distance = 0f;
                 if (listener != null)
                 {
                     distance = (listener.transform.position - audioComponent.ParentGameObject.transform.position).magnitude;
                 }
                 num = distanceAttenuation(distance, audioSource.minDistance, audioSource.maxDistance, audioSource.rolloffMode) * audioSource.volume;
             }
             else
             {
                 num = audioSource.volume;
             }
             for (int j = 0; j < 2; j++)
             {
                 audioSource.GetOutputData(tempSamples, j);
                 for (int k = 0; k < 256; k++)
                 {
                     samples[j, k] += tempSamples[k] * num;
                 }
             }
         }
         VolumeMeterProcess(ref volumeMeterState);
     }
     if (_globalParameterName != null)
     {
         float db = AudioTools.LinearToDB(volumeMeterState.mRMS);
         EventManager.Instance._globalParameterManager.SetGlobalParameter(_globalParameterName, AudioTools.DBToNormalizedDB(db));
     }
     profiler.End();
 }
 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();
 }
예제 #4
0
 public static void CodeProfilerEnd(string label)
 {
     CodeProfiler.End(label);
 }