private unsafe void ProcessDelayStereo(ref DelayState state, Span <IntPtr> outputBuffers, ReadOnlySpan <IntPtr> inputBuffers, uint sampleCount) { const ushort channelCount = 2; float delayFeedbackBaseGain = state.DelayFeedbackBaseGain; float delayFeedbackCrossGain = state.DelayFeedbackCrossGain; float inGain = FixedPointHelper.ToFloat(Parameter.InGain, FixedPointPrecision); float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision); float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision); Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain); for (int i = 0; i < sampleCount; i++) { Vector2 channelInput = new Vector2 { X = *((float *)inputBuffers[0] + i) * 64, Y = *((float *)inputBuffers[1] + i) * 64, }; Vector2 delayLineValues = new Vector2() { X = state.DelayLines[0].Read(), Y = state.DelayLines[1].Read(), }; Vector2 temp = MatrixHelper.Transform(ref channelInput, ref delayFeedback) + channelInput * inGain; state.UpdateLowPassFilter(ref Unsafe.As <Vector2, float>(ref temp), channelCount); *((float *)outputBuffers[0] + i) = (channelInput.X * dryGain + delayLineValues.X * outGain) / 64; *((float *)outputBuffers[1] + i) = (channelInput.Y * dryGain + delayLineValues.Y * outGain) / 64; } }
private unsafe void ProcessDelaySurround(ref DelayState state, Span <IntPtr> outputBuffers, ReadOnlySpan <IntPtr> inputBuffers, uint sampleCount) { const ushort channelCount = 6; float feedbackGain = FixedPointHelper.ToFloat(Parameter.FeedbackGain, FixedPointPrecision); float delayFeedbackBaseGain = state.DelayFeedbackBaseGain; float delayFeedbackCrossGain = state.DelayFeedbackCrossGain; float inGain = FixedPointHelper.ToFloat(Parameter.InGain, FixedPointPrecision); float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision); float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision); Matrix6x6 delayFeedback = new Matrix6x6(delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain, 0.0f, 0.0f, 0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f, 0.0f, delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, feedbackGain); for (int i = 0; i < sampleCount; i++) { Vector6 channelInput = new Vector6 { X = *((float *)inputBuffers[0] + i) * 64, Y = *((float *)inputBuffers[1] + i) * 64, Z = *((float *)inputBuffers[2] + i) * 64, W = *((float *)inputBuffers[3] + i) * 64, V = *((float *)inputBuffers[4] + i) * 64, U = *((float *)inputBuffers[5] + i) * 64 }; Vector6 delayLineValues = new Vector6 { X = state.DelayLines[0].Read(), Y = state.DelayLines[1].Read(), Z = state.DelayLines[2].Read(), W = state.DelayLines[3].Read(), V = state.DelayLines[4].Read(), U = state.DelayLines[5].Read() }; Vector6 temp = MatrixHelper.Transform(ref channelInput, ref delayFeedback) + channelInput * inGain; state.UpdateLowPassFilter(ref Unsafe.As <Vector6, float>(ref temp), channelCount); *((float *)outputBuffers[0] + i) = (channelInput.X * dryGain + delayLineValues.X * outGain) / 64; *((float *)outputBuffers[1] + i) = (channelInput.Y * dryGain + delayLineValues.Y * outGain) / 64; *((float *)outputBuffers[2] + i) = (channelInput.Z * dryGain + delayLineValues.Z * outGain) / 64; *((float *)outputBuffers[3] + i) = (channelInput.W * dryGain + delayLineValues.W * outGain) / 64; *((float *)outputBuffers[4] + i) = (channelInput.V * dryGain + delayLineValues.V * outGain) / 64; *((float *)outputBuffers[5] + i) = (channelInput.U * dryGain + delayLineValues.U * outGain) / 64; } }
private unsafe void ProcessDelayMono(ref DelayState state, float *outputBuffer, float *inputBuffer, uint sampleCount) { float feedbackGain = FixedPointHelper.ToFloat(Parameter.FeedbackGain, FixedPointPrecision); float inGain = FixedPointHelper.ToFloat(Parameter.InGain, FixedPointPrecision); float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision); float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision); for (int i = 0; i < sampleCount; i++) { float input = inputBuffer[i] * 64; float delayLineValue = state.DelayLines[0].Read(); float temp = input * inGain + delayLineValue * feedbackGain; state.UpdateLowPassFilter(ref temp, 1); outputBuffer[i] = (input * dryGain + delayLineValue * outGain) / 64; } }