private static void DrawMeter(string name, float value, float length) { float db = AudioTools.LinearToDB(value); AudioTools.DBToNormalizedDB(db); GUILayout.BeginVertical("box"); GUILayout.Label(name + ":" + db.ToString("N0") + " dB"); GUILayout.EndVertical(); }
private void DrawSideChain(SideChain sideChain, float length) { GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("SideChain"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); float db = AudioTools.LinearToDB(1f - sideChain._sideChainGain); AudioTools.DBToNormalizedDB(db); GUILayout.BeginVertical("box"); GUILayout.Label("Gain:" + db.ToString("N0") + " dB"); GUILayout.EndVertical(); GUILayout.EndVertical(); }
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 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(); }