aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian_examples/20.additive.cpp
blob: 753434deaedb4ae38bb76f067351e4e8a9aa3a05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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!
	
    
}