aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
blob: 307fdad8a48cadc4caaaaa097ba97aca84c594b1 (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
27
28
29
30
31
32
33
34
#include "maximilian.h"

maxiOsc sound,timer;
maxiEnv AR;
double out;
int trigger, lasttrigger;
int currentCount,lastCount,playHead=0;
int rhythm[8]={1,0,1,0,1,0,1,0};


void setup() {//some inits
	
}

void play(double *output) {//this is where the magic happens. Very slow magic.
	currentCount=(int)timer.phasor(16);//this sets up a metronome that ticks every so often
	
	if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound

		trigger=rhythm[playHead];//read through the array
		playHead++;//iterate the playhead
		if (playHead>7) {//but not if it's too big..
			playHead=0;//in which case reset the playhead
		}
		//cout << "tick\n";//the clock ticks
		lastCount=0;//set lastCount to 0
	}
	
	*output=AR.adsr(sound.pulse(440,0.5),1,0.999, 0.125, 0.9999, 1, trigger);//new, simple ADSR.


	
}