public void Process(double[] input, int sampleCount) { var feedbackBuffer = DiffuserEnabled ? diffuser.Output : filterOutputBuffer; for (int i = 0; i < sampleCount; i++) { tempBuffer[i] = input[i] + feedbackBuffer[i] * feedback; } delay.Process(tempBuffer, sampleCount); delay.Output.Copy(tempBuffer, sampleCount); if (LowShelfEnabled) { lowShelf.Process(tempBuffer, tempBuffer, sampleCount); } if (HighShelfEnabled) { highShelf.Process(tempBuffer, tempBuffer, sampleCount); } if (CutoffEnabled) { lowPass.Process(tempBuffer, tempBuffer, sampleCount); } tempBuffer.Copy(filterOutputBuffer, sampleCount); if (DiffuserEnabled) { diffuser.Process(filterOutputBuffer, sampleCount); } }
public override void Process() { var gain = Utils.DB2gain(-30 + 48 * Parameters[0]); var volume = Utils.DB2gain(-60 + 66 * Parameters[1]); var decay = (1 - ValueTables.Get(1 - Parameters[2], ValueTables.Response3Oct)) * 1.14; var basePitch = 60 + (int)((Parameters[3] - 0.5) * 24.01); var p1 = basePitch; var p2 = basePitch + (int)((Parameters[4] - 0.5) * 24.01); var p3 = basePitch + (int)((Parameters[5] - 0.5) * 24.01); var p4 = basePitch + (int)((Parameters[6] - 0.5) * 24.01); var p5 = basePitch + (int)((Parameters[7] - 0.5) * 24.01); var vol1 = Utils.DB2gain(-30 + 36 * Parameters[8]); var vol2 = Utils.DB2gain(-30 + 36 * Parameters[9]); var vol3 = Utils.DB2gain(-30 + 36 * Parameters[10]); var vol4 = Utils.DB2gain(-30 + 36 * Parameters[11]); var vol5 = Utils.DB2gain(-30 + 36 * Parameters[12]); var wet = Parameters[13]; var dry = 1 - wet; var cutoff = ValueTables.Get(Parameters[14], ValueTables.Response4Dec) * 22000; var mode = Parameters[15] < 0.5; var delay1 = GetSamplesPerNote(p1); var delay2 = GetSamplesPerNote(p2); var delay3 = GetSamplesPerNote(p3); var delay4 = GetSamplesPerNote(p4); var delay5 = GetSamplesPerNote(p5); Filter.Frequency = cutoff; Filter.Q = 0.7; Filter.Type = mode ? Biquad.FilterType.LowPass : Biquad.FilterType.HighPass; Filter.Update(); for (int i = 0; i < Inputs[0].Length; i++) { var input = Filter.Process(Inputs[0][i]) * gain; var d1 = Buf1.Read(-delay1) * decay; var d2 = Buf2.Read(-delay2) * decay; var d3 = Buf3.Read(-delay3) * decay; var d4 = Buf4.Read(-delay4) * decay; var d5 = Buf5.Read(-delay5) * decay; var signal = d1 * vol1 + d2 * vol2 + d3 * vol3 + d4 * vol4 + d5 * vol5; Outputs[0][i] = (dry * Inputs[0][i] + wet * signal * 0.2) * volume; Outputs[1][i] = Outputs[0][i]; Buf1.Write(Math.Tanh(input + d1)); Buf2.Write(Math.Tanh(input + d2)); Buf3.Write(Math.Tanh(input + d3)); Buf4.Write(Math.Tanh(input + d4)); Buf5.Write(Math.Tanh(input + d5)); } }
public void ProcessSample(double[][] input, double[][] output, uint bufferSize) { double[] inLeft = input[0]; double[] inRight = input[1]; double[] outLeft = output[0]; double[] outRight = output[1]; // copy data to outBuffer for (int i = 0; i < bufferSize; i++) { outLeft[i] = BiquadL.Process(inLeft[i]); outRight[i] = BiquadR.Process(inRight[i]); } }
public double[][] ProcessOutputStage() { var len = timeSignal[0].Length; var stereoSignal = timeSignal; var gain = Utils.DB2gain(outputStage.GainTransformed); var pan = outputStage.PanTransformed; var leftPan = pan <= 0 ? 1.0 : 1 - Math.Abs(pan); var rightPan = pan >= 0 ? 1.0 : 1 - Math.Abs(pan); var leftInvert = outputStage.InvertPhaseLeft ? -1 : 1; var rightInvert = outputStage.InvertPhaseRight ? -1 : 1; var leftDelay = (int)(outputStage.DelayMillisLTransformed / 1000.0 * samplerate); var rightDelay = (int)(outputStage.DelayMillisRTransformed / 1000.0 * samplerate); var windowLen = outputStage.WindowLengthTransformed; var windowType = outputStage.WindowMethodTransformed; var low12db = outputStage.LowCut12dB; var high12db = outputStage.HighCut12dB; var lp1Left = new ZeroLp1(); var lp1Right = new ZeroLp1(); var hp1Left = new ZeroHp1(); var hp1Right = new ZeroHp1(); lp1Left.SetFc(outputStage.HighCutLeftTransformed / (samplerate / 2)); lp1Right.SetFc(outputStage.HighCutRightTransformed / (samplerate / 2)); hp1Left.SetFc(outputStage.LowCutLeftTransformed / (samplerate / 2)); hp1Right.SetFc(outputStage.LowCutRightTransformed / (samplerate / 2)); var lp2Left = new Biquad { Q = 0.707, Type = Biquad.FilterType.LowPass, Gain = 1, Samplerate = samplerate }; var lp2Right = new Biquad { Q = 0.707, Type = Biquad.FilterType.LowPass, Gain = 1, Samplerate = samplerate }; var hp2Left = new Biquad { Q = 0.707, Type = Biquad.FilterType.HighPass, Gain = 1, Samplerate = samplerate }; var hp2Right = new Biquad { Q = 0.707, Type = Biquad.FilterType.HighPass, Gain = 1, Samplerate = samplerate }; lp2Left.Frequency = outputStage.HighCutLeftTransformed; lp2Right.Frequency = outputStage.HighCutRightTransformed; hp2Left.Frequency = outputStage.LowCutLeftTransformed; hp2Right.Frequency = outputStage.LowCutRightTransformed; lp2Left.Update(); lp2Right.Update(); hp2Left.Update(); hp2Right.Update(); var outputLeft = new double[len]; var outputRight = new double[len]; for (int i = 0; i < stereoSignal[0].Length; i++) { var lSample = stereoSignal[0][i] * gain * leftPan * leftInvert; var rSample = stereoSignal[1][i] * gain * rightPan * rightInvert; if (high12db) { lSample = lp2Left.Process(lSample); rSample = lp2Right.Process(rSample); } else { lSample = lp1Left.Process(lSample); rSample = lp1Right.Process(rSample); } if (low12db) { lSample = hp2Left.Process(lSample); rSample = hp2Right.Process(rSample); } else { lSample = hp1Left.Process(lSample); rSample = hp1Right.Process(rSample); } if (i + leftDelay < len) { outputLeft[i + leftDelay] = lSample; } if (i + rightDelay < len) { outputRight[i + rightDelay] = rSample; } } for (int i = 0; i < len; i++) { var window = GetWindow(i, impulseLength, windowLen, windowType); outputLeft[i] *= window; outputRight[i] *= window; } return(new[] { outputLeft, outputRight }); }