aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rwxr-xr-xmain.cpp46
1 files changed, 8 insertions, 38 deletions
diff --git a/main.cpp b/main.cpp
index 2cf74f6..ea51186 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,51 +1,21 @@
-//Envelopes allow you to shape the sound. The basic idea is that a sound has the following shape
-// Attack: This is how long it takes to fade up to maximum volume
-// Decay: This is how long it takes to reach the sustain level.
-// Sustain: This is the sustain level
-// Release: This is how long it takes to fade out.
-
#include "maximilian.h"
-maxiOsc myCounter,mySwitchableOsc;//
-int CurrentCount;//
-double myOscOutput,myCurrentVolume;//
-maxiEnv myEnvelope;
+maxiSample mySample;
void setup() {//some inits
- //Timing is in ms
-
- myEnvelope.setAttack(0);
- myEnvelope.setDecay(1); // Needs to be at least 1
- myEnvelope.setSustain(1);
- myEnvelope.setRelease(1000);
-
+ mySample.load("/Users/michaelgrierson/Documents/workspace/coursera2/full-stack-mooc-5/code/week2/music_machine_2015/public/bassline32bit.wav");
+ cout << mySample.myBitsPerSample;
+
}
void play(double *output) {
- //notice that we feed in a value of 1. to create an envelope shape we can apply later.
- myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
-
- CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
-
- // You'll notice that these 'if' statements don't require curly braces "{}".
- // This is because there is only one outcome if the statement is true.
-
- if (CurrentCount==1) myEnvelope.trigger=1; //trigger the envelope
- else myEnvelope.trigger=0;//release the envelope to make it fade out only if it's been triggered
-
- if (CurrentCount<5)
-
- myOscOutput=mySwitchableOsc.sawn(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[0]=myOscOutput*myCurrentVolume;//left speaker
+ output[0]=mySample.play(2);
+ output[1]=output[0];
+
}
+