aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ofxMaxim/ofxMaxim/libs/maximilian.cpp5
-rwxr-xr-xofxMaxim/ofxMaxim/libs/maximilian.h31
2 files changed, 33 insertions, 3 deletions
diff --git a/ofxMaxim/ofxMaxim/libs/maximilian.cpp b/ofxMaxim/ofxMaxim/libs/maximilian.cpp
index 0f37cf1..a734636 100644
--- a/ofxMaxim/ofxMaxim/libs/maximilian.cpp
+++ b/ofxMaxim/ofxMaxim/libs/maximilian.cpp
@@ -82,7 +82,7 @@ double maxiOsc::sinewave(double frequency) {
double maxiOsc::sinebuf4(double frequency) {
double remainder;
double a,b,c,d,a1,a2,a3;
- phase += 512./(maxiSettings::sampleRate/(frequency));
+ phase += 512./(maxiSettings::sampleRate/(freq§uency));
if ( phase >= 511 ) phase -=512;
remainder = phase - floor(phase);
@@ -1024,4 +1024,5 @@ double maxiEnv::adsr(double input, double attack, double decay, double sustain,
double convert::mtof(int midinote) {
return mtofarray[midinote];
-} \ No newline at end of file
+}
+
diff --git a/ofxMaxim/ofxMaxim/libs/maximilian.h b/ofxMaxim/ofxMaxim/libs/maximilian.h
index fdee6ea..334ba1f 100755
--- a/ofxMaxim/ofxMaxim/libs/maximilian.h
+++ b/ofxMaxim/ofxMaxim/libs/maximilian.h
@@ -207,7 +207,7 @@ public:
myDataSize = NULL;
}
- maxiSample():myData(NULL){};
+ maxiSample():myData(NULL),position(0){};
bool load(string fileName, int channel=0);
@@ -366,4 +366,33 @@ public:
double mtof(int midinote);
};
+
+
+class maxiDistortion {
+public:
+ /*atan distortion, see http://www.musicdsp.org/showArchiveComment.php?ArchiveID=104*/
+ /*shape from 1 (soft clipping) to infinity (hard clipping)*/
+ double atanDist(double in, double shape);
+ double fastAtanDist(double in, double shape);
+ double fastatan( double x );
+};
+
+inline double maxiDistortion::fastatan(double x)
+{
+ return (x / (1.0 + 0.28 * (x * x)));
+}
+
+inline double maxiDistortion::atanDist(double in, double shape) {
+ double out;
+ out = (1.0 / atan(shape)) * atan(in * shape);
+ return out;
+}
+
+inline double maxiDistortion::fastAtanDist(double in, double shape) {
+ double out;
+ out = (1.0 / fastatan(shape)) * fastatan(in * shape);
+ return out;
+}
+
+
#endif