diff options
| author | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-22 21:09:54 +0100 |
|---|---|---|
| committer | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-22 21:09:54 +0100 |
| commit | 6bb3b92852d9d7f4efb63994bf818b5a01ca86b9 (patch) | |
| tree | 77eae09ffeab32ef9f57b43a2e94bce8722d71fe /main.cpp | |
| parent | 948f46623d24fac7aa41172434f7e8d46ce21ce1 (diff) | |
fixed the triangle waveform generator. Added some samples to test the drum machine example with
Diffstat (limited to 'main.cpp')
| -rwxr-xr-x | main.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
@@ -2,21 +2,29 @@ maxiSample kick,snare; //we've got two sampleplayers +maxiDyn compress,basscompress; + +maxiOsc sound1,sound2,sound3; + +maxiFilter slew;//we'regoing to use this low pass filter for portamentor + maxiOsc timer; //and a timer -int currentCount,lastCount,playHead,hit[16]={1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1}; //This is the sequence for the kick +int currentCount,lastCount,playHead,hit[16]={1,0,0,1,0,0,1,0,0,1,0,1,0,0,0,1}; //This is the sequence for the kick int snarehit[16]={0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0};//This is the sequence for the snare +int bassline[8]={220,110,110,220,110,400,1280,260}; + -int kicktrigger,snaretrigger; +int kicktrigger,snaretrigger,basslinetrigger; -double sampleOut; +double sampleOut,bassout,bassfreq,temp; void setup() {//some inits //YOU HAVE TO PROVIDE THE SAMPLES.... - 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. + kick.load("../../blip.wav");//load in your samples. Provide the full path to a wav file. + snare.load("../../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. @@ -25,6 +33,8 @@ void setup() {//some inits void play(double *output) {//this is where the magic happens. Very slow magic. + bassout=0; + currentCount=(int)timer.phasor(8);//this sets up a metronome that ticks 8 times a second @@ -32,26 +42,29 @@ void play(double *output) {//this is where the magic happens. Very slow magic. kicktrigger=hit[playHead%16];//get the value out of the array for the kick snaretrigger=snarehit[playHead%16];//same for the snare + bassfreq=bassline[playHead%8]; playHead++;//iterate the playhead lastCount=0;//reset the metrotest } - if (kicktrigger==1) {//if the sequence has a 1 in it + if (kicktrigger==1 && playHead>64) {//if the sequence has a 1 in it kick.trigger();//reset the playback position of the sample to 0 (the beginning) } - if (snaretrigger==1) { - + if (snaretrigger==1 &&playHead>32) { snare.trigger();//likewise for the snare } - sampleOut=kick.playOnce()+snare.playOnce();//just play the file. No looping. - output[0]=sampleOut;//left channel - output[1]=sampleOut;//right channel + bassout+=basscompress.compressor(sound1.pulse(slew.lopass(bassfreq/2,0.001), sound2.phasor(8)*0.25),10,0.5,0.0001,0.995)*0.25; + + sampleOut=compress.compressor(kick.playOnce()+snare.playOnce(),5,0.5),0.0001,0.9995;//just play the file. No looping. + + output[0]=sampleOut+bassout;//left channel + output[1]=sampleOut+bassout;//right channel kicktrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering. snaretrigger = 0; |
