private void Update(EvaluationContext context) { //Log.Debug(" global time " + EvaluationContext.BeatTime); var list = Input.GetValue(context); if (list == null || list.Count == 0) { return; } if (_averagedValues.Length != list.Count) { _averagedValues = new float[list.Count]; _lastValues = new float[list.Count]; _output = new List <float>(list.Count); _output.AddRange(Enumerable.Repeat(0f, list.Count)); } int index2 = 0; var hasChanged = false; for (; index2 < list.Count; index2++) { // ReSharper disable once CompareOfFloatsByEqualityOperator if (list[index2] != _lastValues[index2]) { hasChanged = true; break; } } if (hasChanged) { float smoothing = Smoothing.GetValue(context); var mixAverage = MixAverage.GetValue(context); var mixCurrent = MixCurrent.GetValue(context); var mixAboveAverage = MixAboveAverage.GetValue(context); for (var index = 0; index < list.Count; index++) { var v = list[index]; _lastValues[index] = v; if (double.IsNaN(v)) { v = 0; } var smoothed = MathUtils.Lerp(v, _averagedValues[index], smoothing); if (float.IsNaN(smoothed) || float.IsInfinity(smoothed)) { smoothed = 0; } _averagedValues[index] = smoothed; _output[index] = (v - smoothed).Clamp(0, 1000) * mixAboveAverage + v * mixCurrent + smoothed * mixAverage; } } Output.Value = _output; }