diff --git a/PunkOrgan/MainWindow.xaml b/PunkOrgan/MainWindow.xaml index 03bef92..4f16a5f 100644 --- a/PunkOrgan/MainWindow.xaml +++ b/PunkOrgan/MainWindow.xaml @@ -19,7 +19,7 @@ - + diff --git a/PunkOrgan/PunkHammond.cs b/PunkOrgan/PunkHammond.cs index a6eda7d..fc0e267 100644 --- a/PunkOrgan/PunkHammond.cs +++ b/PunkOrgan/PunkHammond.cs @@ -52,7 +52,7 @@ public PunkHammond() CurrentPolyphony = 3; - OverDrive = 0; + OverDrive = 10; } @@ -90,7 +90,8 @@ public override int Read(short[] buffer, int offset, int sampleCount) //The 90 divider is for the drawbars. There are 9 of them. They have 10 position here. currentsamplevalue = currentsamplevalue / 90 * short.MaxValue / CurrentPolyphony; - currentsamplevalue = overdrive(currentsamplevalue); + if (overDrive != 10) currentsamplevalue = overdrive(currentsamplevalue * overDrive / 10); + //currentsamplevalue = distortion(currentsamplevalue, overDrive / 10, 1); currentsamplevalue = currentsamplevalue + echobuffer[limitechophase(echophase + Echo_Freq)] * Echo_Rate / 100; @@ -105,6 +106,7 @@ public override int Read(short[] buffer, int offset, int sampleCount) return sampleCount; } + //Buffer looping private int limitechophase(int phase) { return phase < echobuffersize ? phase : phase - echobuffersize; @@ -146,5 +148,26 @@ private double overdrive(double input) //by Schetzen Formula } return signinput * short.MaxValue; } + + private double distortion(double x, double gain, double mix) + { + // Distortion based on an exponential function + // x - input + // gain - amount of distortion, >0-> + // mix - mix of original and distorted sound, 1=only distorted + if (x == 0) return 0; + x = x / short.MaxValue; + + double y = x / Math.Abs(x) * (1 - Math.Pow(Math.E, gain * x * x / Math.Abs(x))); + return y * short.MaxValue; + + + //double q = x * gain / Math.Abs(x); + //double z = Math.Sign(-q) * (1 - Math.Exp(Math.Sign(-q) * q)); + //double y = mix * z * Math.Abs(x) / Math.Abs(z) + (1 - mix) * x; + //y = y * Math.Abs(x) / Math.Abs(y); + + + } } }