aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMick Grierson <mickgrierson@strangebook.local>2011-10-28 15:13:23 +0100
committerMick Grierson <mickgrierson@strangebook.local>2011-10-28 15:13:23 +0100
commit46ee21d048ec62e9532fb009a3ffa99ced28b149 (patch)
tree3d07d70d57391b8c692aef209620dc7dbf5eb6be
parent139ef699ec4eb864e3c240832a05026b85a042e1 (diff)
added new enveloping example
-rwxr-xr-xmain.cpp61
-rw-r--r--maximilian_examples/19.Enveloping2.cpp55
2 files changed, 79 insertions, 37 deletions
diff --git a/main.cpp b/main.cpp
index 6340cba..112c5e8 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,68 +1,55 @@
#include "maximilian.h"
-maxiSample kick,snare; //we've got two sampleplayers
+//this tutorial explains how to use the maxiEnv
-maxiDyn compress,basscompress;
+maxiSample sound1;
-maxiOsc sound1,sound2,sound3;
+maxiOsc timer,snarePhase; //and a timer
-maxiFilter slew;//we're going to use this low pass filter for portamento
+maxiEnv envelope;//this is going to be an envelope
-maxiOsc timer; //and a timer
+int currentCount,lastCount,playHead,
-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};
+sequence[16]={1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0}; //This is the sequence for the kick
+int sampleTrigger;
-int kicktrigger,snaretrigger,basslinetrigger;
-
-double sampleOut,bassout,bassfreq,temp;
+double sampleOut;
void setup() {//some inits
-
- 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.
+
+ //YOU HAVE TO PROVIDE THE SAMPLES....
+
+ sound1.load("/Users/mickgrierson/Documents/audio/68373__juskiddink__Cello_open_string_bowed.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.
+ printf("Summary:\n%s", sound1.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(8);//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];//get the value out of the array for the kick
- snaretrigger=snarehit[playHead%16];//same for the snare
- bassfreq=bassline[playHead%8];
+ sampleTrigger=sequence[playHead%16];
playHead++;//iterate the playhead
lastCount=0;//reset the metrotest
- }
- 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 &&playHead>32) {
- snare.trigger();//likewise for the snare
+ //the envelope we're using here is an AR envelope.
+ //It has an input (which in this case is a sound)
+ //It has an attack coefficient, a hold val (in samples)
+ //and a release coefficient. Finally, it has a trigger input.
+ //If you stick a 1 in the trigger input, it retriggers the envelope
+ sampleOut=envelope.ar(sound1.play(1.), 0.1, 0.9999, 1, sampleTrigger); //
- }
-
-
- bassout=basscompress.compressor(sound1.pulse(slew.lopass(bassfreq/2,0.001), sound2.phasor(8)*0.25),5,0.5,0.0001,0.995)*0.125;
+ output[0]=sampleOut;//left channel
+ output[1]=sampleOut;//right channel
- sampleOut=compress.compressor(kick.playOnce(1)+snare.playOnce(0.5),1,0.5),0.01,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;
+ sampleTrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering.
+
} \ No newline at end of file
diff --git a/maximilian_examples/19.Enveloping2.cpp b/maximilian_examples/19.Enveloping2.cpp
new file mode 100644
index 0000000..112c5e8
--- /dev/null
+++ b/maximilian_examples/19.Enveloping2.cpp
@@ -0,0 +1,55 @@
+#include "maximilian.h"
+
+//this tutorial explains how to use the maxiEnv
+
+maxiSample sound1;
+
+maxiOsc timer,snarePhase; //and a timer
+
+maxiEnv envelope;//this is going to be an envelope
+
+int currentCount,lastCount,playHead,
+
+sequence[16]={1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0}; //This is the sequence for the kick
+
+int sampleTrigger;
+
+double sampleOut;
+
+void setup() {//some inits
+
+ //YOU HAVE TO PROVIDE THE SAMPLES....
+
+ sound1.load("/Users/mickgrierson/Documents/audio/68373__juskiddink__Cello_open_string_bowed.wav");//load in your samples. Provide the full path to a wav file.
+
+
+ printf("Summary:\n%s", sound1.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(8);//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
+
+ sampleTrigger=sequence[playHead%16];
+ playHead++;//iterate the playhead
+ lastCount=0;//reset the metrotest
+
+ }
+
+ //the envelope we're using here is an AR envelope.
+ //It has an input (which in this case is a sound)
+ //It has an attack coefficient, a hold val (in samples)
+ //and a release coefficient. Finally, it has a trigger input.
+ //If you stick a 1 in the trigger input, it retriggers the envelope
+ sampleOut=envelope.ar(sound1.play(1.), 0.1, 0.9999, 1, sampleTrigger); //
+
+ output[0]=sampleOut;//left channel
+ output[1]=sampleOut;//right channel
+
+ sampleTrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering.
+
+} \ No newline at end of file