aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorMick Grierson <mickgrierson@strangebook.lan>2011-10-18 19:05:02 +0100
committerMick Grierson <mickgrierson@strangebook.lan>2011-10-18 19:05:02 +0100
commit92af27026aa1aa72535e94bd8007d7066a3136e7 (patch)
treeb07dac5b9f137adc15d6b7a9f343ca18d5fef6c4 /main.cpp
parentc203258295902604f01adadb81a8fd0cb1933912 (diff)
hmm maxiDyn needs a bit more work
Diffstat (limited to 'main.cpp')
-rwxr-xr-xmain.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/main.cpp b/main.cpp
index 307fdad..cd50505 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,11 +1,14 @@
#include "maximilian.h"
-maxiOsc sound,timer;
-maxiEnv AR;
-double out;
-int trigger, lasttrigger;
+maxiOsc sound,bass,timer,mod;
+maxiEnv envelope;
+double bassout,leadout;
+int trigger;
int currentCount,lastCount,playHead=0;
int rhythm[8]={1,0,1,0,1,0,1,0};
+float pitch[8]={220,220,246.9,261.6};
+float currentPitch;
+
void setup() {//some inits
@@ -13,20 +16,20 @@ 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
+ currentCount=(int)timer.phasor(20);//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
+ trigger=rhythm[playHead%8];//read through the array
+ currentPitch=pitch[(playHead%8)/2];
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.
+ bassout=envelope.adsr(bass.saw(currentPitch*0.5)+sound.pulse(currentPitch*0.5,mod.phasor(1)),1,0.9995, 0.25, 0.9995, 1, trigger);//new, simple ADSR.
+
+ *output=bassout;
+