aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian_examples/7.Counting1.cpp
diff options
context:
space:
mode:
authormick grierson <mickgrierson@gmail.com>2015-09-22 09:21:43 +0100
committermick grierson <mickgrierson@gmail.com>2015-09-22 09:21:43 +0100
commit5be3472f0f61d2e479f42759fed6fafd2a0e739a (patch)
tree49f128d4b56d43b3499ffd824b57b7f8b8d8345a /maximilian_examples/7.Counting1.cpp
parentc814dd99dc3c347914c2057b77d1390ba41cfae5 (diff)
more work for kadenze mooc
Diffstat (limited to 'maximilian_examples/7.Counting1.cpp')
-rwxr-xr-xmaximilian_examples/7.Counting1.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/maximilian_examples/7.Counting1.cpp b/maximilian_examples/7.Counting1.cpp
new file mode 100755
index 0000000..6bdfd85
--- /dev/null
+++ b/maximilian_examples/7.Counting1.cpp
@@ -0,0 +1,33 @@
+
+#include "maximilian.h"
+
+maxiOsc mySine; // This is the oscillator we will use to generate the test tone
+maxiClock myClock; // This will allow us to generate a clock signal and do things at specific times
+double freq; // This is a variable that we will use to hold and set the current frequency of the oscillator
+
+void setup() {
+
+ myClock.setTicksPerBeat(1);//This sets the number of ticks per beat
+ myClock.setTempo(120);// This sets the tempo in Beats Per Minute
+ freq=20; // Here we initialise the variable
+}
+
+void play(double *output) {
+
+ myClock.ticker(); // This makes the clock object count at the current samplerate
+
+ //This is a 'conditional'. It does a test and then does something if the test is true
+
+ if (myClock.tick) { // If there is an actual tick at this time, this will be true.
+
+ freq+=100; // DO SOMETHING
+
+ } // The curly braces close the conditional
+
+ //output[0] is the left output. output[1] is the right output
+
+ output[0]=mySine.sinewave(freq);//simple as that!
+ output[1]=output[0];
+
+}
+