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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "maximilian.h"
maxiSample kick,snare; //We give our sample a name. It's called beats this time. We could have loads of them, but they have to have different names.
maxiOsc timer;
int currentCount,lastCount,playHead,hit[16]={1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0};
int snarehit[16]={0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0};
int kicktrigger,snaretrigger;
double sampleOut;
void setup() {//some inits
kick.load("/Users/mickgrierson/Documents/audio/blip.wav");//load in your samples. Provide the full path to a wav file.
snare.load("/Users/mickgrierson/Documents/audio/snare.wav");//load in your samples. Provide the full path to a wav file.
printf("Summary:\n%s", kick.getSummary());//get info on samples if you like.
//beats.getLength();
}
void play(double *output) {//this is where the magic happens. Very slow magic.
currentCount=(int)timer.phasor(4);//this sets up a metronome that ticks 8 times a second
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
kicktrigger=hit[playHead%16];
snaretrigger=snarehit[playHead%16];
playHead++;
lastCount=0;
}
if (kicktrigger==1) {
kick.trigger();
}
if (snaretrigger==1) {
snare.trigger();
}
sampleOut=kick.playOnce()+snare.playOnce();//just play the file. Looping is default for all play functions.
*output=sampleOut;
}
|