public void UpdateParameter(ref Reverb3dParameter parameter) { uint sampleRate = parameter.SampleRate / 1000; EarlyDelayTime = new uint[20]; DryGain = parameter.DryGain; PreviousFeedbackOutputDecayed.AsSpan().Fill(0); PreviousPreDelayValue = 0; EarlyReflectionsGain = FloatingPointHelper.Pow10(Math.Min(parameter.RoomGain + parameter.ReflectionsGain, 5000.0f) / 2000.0f); LateReverbGain = FloatingPointHelper.Pow10(Math.Min(parameter.RoomGain + parameter.ReverbGain, 5000.0f) / 2000.0f); float highFrequencyRoomGain = FloatingPointHelper.Pow10(parameter.RoomHf / 2000.0f); if (highFrequencyRoomGain < 1.0f) { float tempA = 1.0f - highFrequencyRoomGain; float tempB = 2.0f - ((2.0f * highFrequencyRoomGain) * FloatingPointHelper.Cos(256.0f * parameter.HfReference / parameter.SampleRate)); float tempC = MathF.Sqrt(MathF.Pow(tempB, 2) - (4.0f * (1.0f - highFrequencyRoomGain) * (1.0f - highFrequencyRoomGain))); PreviousPreDelayGain = (tempB - tempC) / (2.0f * tempA); TargetPreDelayGain = 1.0f - PreviousPreDelayGain; } else { PreviousPreDelayGain = 0.0f; TargetPreDelayGain = 1.0f; } ReflectionDelayTime = IDelayLine.GetSampleCount(sampleRate, 1000.0f * (parameter.ReflectionDelay + parameter.ReverbDelayTime)); EchoLateReverbDecay = 0.6f * parameter.Diffusion * 0.01f; for (int i = 0; i < FdnDelayLines.Length; i++) { FdnDelayLines[i].SetDelay(FdnDelayMinTimes[i] + (parameter.Density / 100 * (FdnDelayMaxTimes[i] - FdnDelayMinTimes[i]))); uint tempSampleCount = FdnDelayLines[i].CurrentSampleCount + DecayDelays1[i].CurrentSampleCount + DecayDelays2[i].CurrentSampleCount; float tempA = (-60.0f * tempSampleCount) / (parameter.DecayTime * parameter.SampleRate); float tempB = tempA / parameter.HfDecayRatio; float tempC = FloatingPointHelper.Cos(128.0f * 0.5f * parameter.HfReference / parameter.SampleRate) / FloatingPointHelper.Sin(128.0f * 0.5f * parameter.HfReference / parameter.SampleRate); float tempD = FloatingPointHelper.Pow10((tempB - tempA) / 40.0f); float tempE = FloatingPointHelper.Pow10((tempB + tempA) / 40.0f) * 0.7071f; DecayDirectFdnGain[i] = tempE * ((tempD * tempC) + 1.0f) / (tempC + tempD); DecayCurrentFdnGain[i] = tempE * (1.0f - (tempD * tempC)) / (tempC + tempD); DecayCurrentOutputGain[i] = (tempC - tempD) / (tempC + tempD); DecayDelays1[i].SetDecayRate(EchoLateReverbDecay); DecayDelays2[i].SetDecayRate(EchoLateReverbDecay * -0.9f); } for (int i = 0; i < EarlyDelayTime.Length; i++) { uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (EarlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax); EarlyDelayTime[i] = sampleCount; } }