aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorMick Grierson <mickgrierson@strangebook.lan>2011-10-17 02:01:12 +0100
committerMick Grierson <mickgrierson@strangebook.lan>2011-10-17 02:01:12 +0100
commit9b352d42f4631a515345ed7c4992a736aab1fea2 (patch)
tree557dc6cecc0becda49311cc6b4f139bee1076a1a /main.cpp
parent3a90e8344192e60f65cf9a1fe821bb080a323d34 (diff)
added maxiEnv - easier to use ADSR and AR envelopes for those who find ramps a bit weird
Diffstat (limited to 'main.cpp')
-rwxr-xr-xmain.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/main.cpp b/main.cpp
index 70803aa..34befac 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,21 +1,35 @@
#include "maximilian.h"
-maxiSample beats;//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.
-maxiDyn compressor;
-double beat;
+maxiOsc sound,timer;//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.
+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
- beats.load("/Users/mickgrierson/Documents/audio/59210__suonho__abstract_electrofunkbreakbeats_124bpm_mono.wav");//load in your samples. Provide the full path to a wav file.
- printf("Summary:\n%s", beats.getSummary());//get info on samples if you like.
-
}
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 2 seconds
+
+ if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
+
+ trigger=rhythm[playHead];
+ playHead++;
+ if (playHead>7) {
+ playHead=0;
+ }
+ //cout << "tick\n";//the clock ticks
+ lastCount=0;//set lastCount to 0
+ }
+
+
+// beat=beats.play();//just play the file. Looping is default for all play functions.
- beat=beats.play();//just play the file. Looping is default for all play functions.
- *output=compressor.compress(beat,100,0.01)*10;//OMG an evil compressor
+ *output=AR.adsr(sound.pulse(440,0.5),1,0.999, 0.125, 0.9999, 1, trigger);//new, simple ADSR.
// *output=beats.play(0.69);//play the file with a speed setting. 1. is normal speed.
// *output=beats.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing.