From cfb9046eec768c76baa4c0711870bb255c86ef4a Mon Sep 17 00:00:00 2001 From: mick grierson Date: Mon, 19 Dec 2016 22:35:23 +0000 Subject: Fixing errors in new envelope functions. maxiEnvelope now has a ramp function, a ramps function that takes time / value pairs from a std::vector, an adsr and ar that all sync directly to the samplerate. They all take params in seconds. This makes it easier for javascript users when I transpile with emscripten. Wait what? --- main.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index ac320ba..e1bc272 100755 --- a/main.cpp +++ b/main.cpp @@ -3,20 +3,88 @@ maxiOsc myOsc; maxiEnvelope myEnv; int counter; -double tv[8] = {1,1,0,1,1,2,0,4}; +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 rampsA(vals, vals+12); + void setup() {//some inits - + + myEnv.note(true); + } void play(double *output) {//this is where the magic happens. Very slow magic. + counter++; + if (counter ==0 || counter % 330400==0) { + myEnv.note(true); + } - double out = myEnv.ramps(tv); - output[0]=myOsc.sinewave(440)*out; + double out = myEnv.ramps(rampsA); + output[0]=myOsc.sinewave(440)*out; + output[1]=output[0]; } + +//#include "maximilian.h" +// +//maxiOsc myOsc; +//maxiEnvelope myEnv; +//int counter; +// +//void setup() { +// cout << myEnv.trigger << endl; +//} +// +//void play(double *output) { +// +// +// if (counter ==0 || counter % 88201==0) { +// myEnv.note(true); +// } +// +// if (counter % 44100==0) { +// myEnv.note(false); +// } +// +// counter++; +// +// double out = myEnv.adsr(); +// +// output[0]=myOsc.sinewave(440)*out; +// +// output[1]=output[0]; +// +//} + +//#include "maximilian.h" +// +//maxiOsc myOsc; +//maxiEnvelope myEnv; +//int counter; +// +//void setup() { +// cout << myEnv.trigger << endl; +//} +// +//void play(double *output) { +// +// +// if (counter ==0 || counter % 88200==0) { +// myEnv.note(true); +// } +// +// +// counter++; +// +// double out = myEnv.ar(1,1); +// +// output[0]=myOsc.sinewave(440)*out; +// +// output[1]=output[0]; +// +//} -- cgit v1.3