aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rwxr-xr-xmain.cpp117
1 files changed, 78 insertions, 39 deletions
diff --git a/main.cpp b/main.cpp
index dbce5bf..9bd1025 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,49 +1,88 @@
-//Using BPF equation from http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
+//#include "maximilian.h"
+//
+//maxiOsc myOsc;
+//maxiEnvelope myEnv;
+//int counter;
+//double vals[12]={1,0.1,0.5,0.0,1.5,0.0,0.1,1,1.0,0.15,1.0,0.1};
+//std::vector<double> rampsA(vals, vals+12);
+//
+//
+//void setup() {//some inits
+//
+// myEnv.trigger(true);
+//
+//}
+//
+//void play(double *output) {//this is where the magic happens. Very slow magic.
+//
+// counter++;
+//
+// if (counter ==0 || counter % 330400==0) {
+// myEnv.trigger(true);
+// }
+//
+//
+// double out = myEnv.ramps(rampsA);
+//
+// output[0]=myOsc.sinewave(440)*out;
+//
+// output[1]=output[0];
+//}
-#include "maximilian.h"
-float xs[3], ys[3];
-float a0, a1, a2, b0, b1, b2;
-float f0 = 400; //THE FREQUENCY
-float Q = 1.0;
+//#include "maximilian.h"
+//
+//maxiOsc myOsc;
+//maxiEnvelope myEnv;
+//int counter=0;
+//
+//void setup() {
+//}
+//
+//void play(double *output) {
+//
+//
+// if (counter ==0 || counter % 17640==0) {
+// myEnv.trigger(true);
+// }
+//
+// if (counter % 8821==0) {
+// myEnv.trigger(false);
+// }
+//
+// counter++;
+//
+// double out = myEnv.adsr(0.1,0.2,0.1,3);
+//
+// output[0]=myOsc.sinewave(440)*out;
+//
+// output[1]=output[0];
+//
+//}
-maxiOsc mySwitchableOsc;
+#include "maximilian.h"
-void setup() {//some inits
- double w0 = 2*PI*f0/44100;
- double alpha = sin(w0)/(2*Q);
- //Band-pass reson:
-// b0 = alpha;
-// b1 = 0;
-// b2 = -1 * alpha;
-// a0 = 1 + alpha;
-// a1 = -2*cos(w0);
-// a2 = 1 - alpha;
-
- //Notch:
- b0 = 1;
- b1 = -2*cos(w0);
- b2 = 1;
- a0 = 1 + alpha;
- a1 = -2*cos(w0);
- a2 = 1 - alpha;
-
- //LPF:
-// b0 = (1 - cos(w0))/2;
-// b1 = 1 - cos(w0);
-// b2 = (1 - cos(w0))/2;
-// a0 = 1 + alpha;
-// a1 = -2*cos(w0);
-// a2 = 1 - alpha;
+maxiOsc myOsc;
+maxiEnvelope myEnv;
+int counter;
+
+void setup() {
}
void play(double *output) {
- xs[0] = mySwitchableOsc.sawn(400);
- ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2]
- - (a1/a0)*ys[1] - (a2/a0)*ys[2];
- *output = ys[0];
- ys[2] = ys[1]; ys[1] = ys[0];
- xs[2] = xs[1]; xs[1] = xs[0];
+ if (counter ==0 || counter % 8820==0) {
+ myEnv.trigger(true);
+ }
+
+
+ counter++;
+
+ double out = myEnv.ar(0.01,1);
+
+ output[0]=myOsc.sinewave(440)*out;
+
+ output[1]=output[0];
+
}