From eabb1855777c8451c8a35bae4309ee112ac4460e Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Fri, 11 Oct 2013 11:13:00 +0100 Subject: additive example --- maximilian_examples/20.additive.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 maximilian_examples/20.additive.cpp (limited to 'maximilian_examples') diff --git a/maximilian_examples/20.additive.cpp b/maximilian_examples/20.additive.cpp new file mode 100644 index 0000000..753434d --- /dev/null +++ b/maximilian_examples/20.additive.cpp @@ -0,0 +1,26 @@ +#include "maximilian.h" + +maxiOsc sineBank[10];//let's create an oscillator and give it a name. + +void setup() {//some inits + //nothing to go here this time +} + + + +void play(double *output) {//this is where the magic happens. Very slow magic. + + double wave=0; + double f0 = 100; + for(int i=0; i < 10; i++) { + double thisSine = wave + sineBank[i].sinewave(f0 + (i * f0)); + double multiplier = 1.0 / (i+1.0); + thisSine = thisSine * multiplier; + wave = wave + thisSine; + } + wave *= 0.1; + *output = wave;//simple as that! + + +} + -- cgit v1.3