aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian_examples
diff options
context:
space:
mode:
authorChris Kiefer <chrisk13fer@gmail.com>2011-08-23 16:59:47 +0100
committerChris Kiefer <chrisk13fer@gmail.com>2011-08-23 16:59:47 +0100
commit9b02537e82866bcfdcb22a5e7fd9c7f5217c2c64 (patch)
tree193b798778c258d52093f17fd41b2f250a079553 /maximilian_examples
parentbc4a8dbc0fb0fcafffa1e94edfaedf9c4845cecc (diff)
maximillian basic examples
Diffstat (limited to 'maximilian_examples')
-rw-r--r--maximilian_examples/.DS_Storebin0 -> 6148 bytes
-rwxr-xr-xmaximilian_examples/1.TestTone.cpp14
-rwxr-xr-xmaximilian_examples/10.Filters.cpp33
-rwxr-xr-xmaximilian_examples/11.Mixing.cpp40
-rwxr-xr-xmaximilian_examples/12.SamplePlayer.cpp21
-rwxr-xr-xmaximilian_examples/2.TwoTones.cpp14
-rwxr-xr-xmaximilian_examples/3.AM1.cpp15
-rwxr-xr-xmaximilian_examples/4.AM2.cpp16
-rwxr-xr-xmaximilian_examples/5.FM1.cpp14
-rwxr-xr-xmaximilian_examples/6.FM2.cpp14
-rwxr-xr-xmaximilian_examples/7.Counting.cpp15
-rwxr-xr-xmaximilian_examples/8.Counting2.cpp24
-rwxr-xr-xmaximilian_examples/9.Envelopes.cpp33
13 files changed, 253 insertions, 0 deletions
diff --git a/maximilian_examples/.DS_Store b/maximilian_examples/.DS_Store
new file mode 100644
index 0000000..5008ddf
--- /dev/null
+++ b/maximilian_examples/.DS_Store
Binary files differ
diff --git a/maximilian_examples/1.TestTone.cpp b/maximilian_examples/1.TestTone.cpp
new file mode 100755
index 0000000..77783b4
--- /dev/null
+++ b/maximilian_examples/1.TestTone.cpp
@@ -0,0 +1,14 @@
+#include "maximilian.h"
+
+maxiOsc mySine;//let's create an oscillator and give it a name.
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {//this is where the magic happens. Very slow magic.
+
+ *output=mySine.sinewave(440);//simple as that!
+
+}
+
diff --git a/maximilian_examples/10.Filters.cpp b/maximilian_examples/10.Filters.cpp
new file mode 100755
index 0000000..b80b512
--- /dev/null
+++ b/maximilian_examples/10.Filters.cpp
@@ -0,0 +1,33 @@
+#include "maximilian.h"
+
+maxiOsc myCounter,mySwitchableOsc;//
+int CurrentCount;//
+double myOscOutput,myFilteredOutput;//
+double myEnvelopeData[6] = {500,0,1000,500,0,500};//this data will be used to make an envelope. Value and time to value in ms.
+maxiEnvelope myEnvelope;
+maxiFilter myFilter;
+
+void setup() {//some inits
+ myEnvelope.amplitude=myEnvelopeData[0]; //initialise the envelope
+}
+
+void play(double *output) {
+
+ CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
+
+ if (CurrentCount<5)//simple if statement
+
+ myOscOutput=mySwitchableOsc.square(CurrentCount*100);
+
+ else if (CurrentCount>=5)//and the 'else' bit.
+
+ myOscOutput=mySwitchableOsc.saw(CurrentCount*50);//one osc object can produce whichever waveform you want.
+
+ if (CurrentCount==1)
+
+ myEnvelope.trigger(0,myEnvelopeData[0]); //trigger the envelope
+
+ myFilteredOutput=myFilter.lores(myOscOutput,(myEnvelope.line(6, myEnvelopeData)),10);//lores takes an audio input, a frequency and a resonance factor (1-100)
+
+ *output=myFilteredOutput;//point me at your speakers and fire.
+}
diff --git a/maximilian_examples/11.Mixing.cpp b/maximilian_examples/11.Mixing.cpp
new file mode 100755
index 0000000..6fd7a34
--- /dev/null
+++ b/maximilian_examples/11.Mixing.cpp
@@ -0,0 +1,40 @@
+#include "maximilian.h"
+
+maxiOsc myCounter,mySwitchableOsc,myAutoPanner;//
+int CurrentCount;//
+double myOscOutput,myFilteredOutput,myPanPosition;//
+double myStereoOutput[2];// we need an output for each channel.
+double myEnvelopeData[6] = {500,0,1000,500,0,500};//this data will be used to make an envelope. Value and time to value in ms.
+maxiEnvelope myEnvelope;
+maxiFilter myFilter;
+maxiMix myOutputs;//this is the stereo mixer channel.
+
+void setup() {//some inits
+ myEnvelope.amplitude=myEnvelopeData[0]; //initialise the envelope
+}
+
+void play(double *output) {
+
+ CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
+
+ if (CurrentCount<5)//simple if statement
+
+ myOscOutput=mySwitchableOsc.square(CurrentCount*100);
+
+ else if (CurrentCount>=5)//and the 'else' bit.
+
+ myOscOutput=mySwitchableOsc.saw(CurrentCount*50);//one osc object can produce whichever waveform you want.
+
+ if (CurrentCount==1)
+
+ myEnvelope.trigger(0,myEnvelopeData[0]); //trigger the envelope
+
+ myFilteredOutput=myFilter.lores(myOscOutput,(myEnvelope.line(6, myEnvelopeData)),10);//lores takes an audio input, a frequency and a resonance factor (1-100)
+
+ myPanPosition=myAutoPanner.sinewave(1);
+
+ myOutputs.stereo(myFilteredOutput,myStereoOutput,myPanPosition);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the output[numberofchannels], and the pan (0-1,equal power).
+ output[0]=myStereoOutput[0];//When working with mixing, you need to specify the outputs explicityly
+ output[1]=myStereoOutput[1];//
+
+}
diff --git a/maximilian_examples/12.SamplePlayer.cpp b/maximilian_examples/12.SamplePlayer.cpp
new file mode 100755
index 0000000..2706f0b
--- /dev/null
+++ b/maximilian_examples/12.SamplePlayer.cpp
@@ -0,0 +1,21 @@
+#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.
+
+void setup() {//some inits
+
+ beats.load("/Users/username/somewhere/Maximilian/beat2.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.
+
+ *output=beats.play();//just play the file. Looping is default for all play functions.
+ // *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.
+ // *output=beats.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing.
+
+
+}
+
diff --git a/maximilian_examples/2.TwoTones.cpp b/maximilian_examples/2.TwoTones.cpp
new file mode 100755
index 0000000..4e22994
--- /dev/null
+++ b/maximilian_examples/2.TwoTones.cpp
@@ -0,0 +1,14 @@
+#include "maximilian.h"
+
+maxiOsc mySine,myOtherSine;//Two oscillators with names.
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {//this is where the magic happens. Very slow magic.
+
+ *output=mySine.sinewave(440)+myOtherSine.sinewave(441);//these two sines will beat together. They're now a bit too loud though..
+
+}
+
diff --git a/maximilian_examples/3.AM1.cpp b/maximilian_examples/3.AM1.cpp
new file mode 100755
index 0000000..ec96c7f
--- /dev/null
+++ b/maximilian_examples/3.AM1.cpp
@@ -0,0 +1,15 @@
+#include "maximilian.h"
+
+//This shows how to use maximilian to do basic amplitude modulation
+
+maxiOsc mySine,myOtherSine;//Two oscillators. They can be called anything. They can be any of the available waveforms. These ones will be sinewaves
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {
+
+ *output=mySine.sinewave(440)*myOtherSine.sinewave(10);
+
+}
diff --git a/maximilian_examples/4.AM2.cpp b/maximilian_examples/4.AM2.cpp
new file mode 100755
index 0000000..4e783d3
--- /dev/null
+++ b/maximilian_examples/4.AM2.cpp
@@ -0,0 +1,16 @@
+#include "maximilian.h"
+
+//This shows how to use maximilian to do basic amplitude modulation
+
+maxiOsc mySine,myOtherSine,myPhasor;//Three oscillators. They can be called anything. They can be any of the available waveforms.
+
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {
+
+ *output=mySine.sinewave(440)*myOtherSine.sinewave(myPhasor.phasor(0.1,0,440));
+
+}
diff --git a/maximilian_examples/5.FM1.cpp b/maximilian_examples/5.FM1.cpp
new file mode 100755
index 0000000..c734dcf
--- /dev/null
+++ b/maximilian_examples/5.FM1.cpp
@@ -0,0 +1,14 @@
+#include "maximilian.h"
+
+maxiOsc mySine,myOtherSine;//Two oscillators
+
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {
+
+ *output=mySine.sinewave(myOtherSine.sinewave(1)*440);
+
+}
diff --git a/maximilian_examples/6.FM2.cpp b/maximilian_examples/6.FM2.cpp
new file mode 100755
index 0000000..d9acd72
--- /dev/null
+++ b/maximilian_examples/6.FM2.cpp
@@ -0,0 +1,14 @@
+#include "maximilian.h"
+
+maxiOsc mySine,myOtherSine,myLastSine,myPhasor;//Three oscillators
+
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {
+
+ *output=mySine.sinewave(myOtherSine.sinewave(myLastSine.sinewave(0.1)*30)*440);//awesome bassline
+
+}
diff --git a/maximilian_examples/7.Counting.cpp b/maximilian_examples/7.Counting.cpp
new file mode 100755
index 0000000..7de2f0e
--- /dev/null
+++ b/maximilian_examples/7.Counting.cpp
@@ -0,0 +1,15 @@
+#include "maximilian.h"
+
+maxiOsc myCounter,mySquare;//these oscillators will help us count and play sound
+int CurrentCount;//we're going to put the current count in this variable so that we can use it more easily.
+
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {
+
+ CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
+ *output=mySquare.square(CurrentCount*100);
+}
diff --git a/maximilian_examples/8.Counting2.cpp b/maximilian_examples/8.Counting2.cpp
new file mode 100755
index 0000000..ce016d0
--- /dev/null
+++ b/maximilian_examples/8.Counting2.cpp
@@ -0,0 +1,24 @@
+#include "maximilian.h"
+
+maxiOsc myCounter,mySwitchableOsc;//these oscillators will help us count and make sound.
+int CurrentCount;//we're going to put the current count in this variable so that we can use it more easily.
+double myOscOutput;//we're going to stick the output here to make it easier to mess with stuff.
+
+void setup() {//some inits
+ //nothing to go here this time
+}
+
+void play(double *output) {
+
+ CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
+
+ if (CurrentCount<5)//simple if statement
+
+ myOscOutput=mySwitchableOsc.square(CurrentCount*100);
+
+ else if (CurrentCount>=5)//and the 'else' bit.
+
+ myOscOutput=mySwitchableOsc.sinewave(CurrentCount*50);//one osc object can produce whichever waveform you want.
+
+ *output=myOscOutput;//point me at your speakers and fire.
+}
diff --git a/maximilian_examples/9.Envelopes.cpp b/maximilian_examples/9.Envelopes.cpp
new file mode 100755
index 0000000..806e14f
--- /dev/null
+++ b/maximilian_examples/9.Envelopes.cpp
@@ -0,0 +1,33 @@
+#include "maximilian.h"
+
+maxiOsc myCounter,mySwitchableOsc;//
+int CurrentCount;//
+double myOscOutput,myCurrentVolume;//
+double myEnvelopeData[4] = {1,0,0,500};//this data will be used to make an envelope. Value and time to value in ms.
+maxiEnvelope myEnvelope;
+
+
+void setup() {//some inits
+ myEnvelope.amplitude=myEnvelopeData[0]; //initialise the envelope
+}
+
+void play(double *output) {
+
+ myCurrentVolume=myEnvelope.line(4,myEnvelopeData);
+
+ CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
+
+ if (CurrentCount<5)//simple if statement
+
+ myOscOutput=mySwitchableOsc.square(CurrentCount*100);
+
+ else if (CurrentCount>=5)//and the 'else' bit.
+
+ myOscOutput=mySwitchableOsc.sinewave(CurrentCount*50);//one osc object can produce whichever waveform you want.
+
+ if (CurrentCount==1)
+
+ myEnvelope.trigger(0,myEnvelopeData[0]); //trigger the envelope
+
+ *output=myOscOutput*myCurrentVolume;//point me at your speakers and fire.
+}