diff options
| author | Chris Kiefer <chrisk13fer@gmail.com> | 2011-12-09 11:57:47 +0000 |
|---|---|---|
| committer | Chris Kiefer <chrisk13fer@gmail.com> | 2011-12-09 11:57:47 +0000 |
| commit | 09251755f8e5b1aace125897a1af16357a3b1528 (patch) | |
| tree | 92bff8428ff3411cb76e90f131677e7e76d09e0a /ofxMaxim | |
| parent | c8963a4de178b46b6e230ea99dba1bb1ee850331 (diff) | |
fixed position initialisation in maxisample
added in maxiDistortion
Diffstat (limited to 'ofxMaxim')
| -rw-r--r-- | ofxMaxim/ofxMaxim/libs/maximilian.cpp | 5 | ||||
| -rwxr-xr-x | ofxMaxim/ofxMaxim/libs/maximilian.h | 31 |
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 |
