aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmain.cpp25
-rw-r--r--maximilian.cpp10
2 files changed, 16 insertions, 19 deletions
diff --git a/main.cpp b/main.cpp
index 307fdad..cd50505 100755
--- a/main.cpp
+++ b/main.cpp
@@ -1,11 +1,14 @@
#include "maximilian.h"
-maxiOsc sound,timer;
-maxiEnv AR;
-double out;
-int trigger, lasttrigger;
+maxiOsc sound,bass,timer,mod;
+maxiEnv envelope;
+double bassout,leadout;
+int trigger;
int currentCount,lastCount,playHead=0;
int rhythm[8]={1,0,1,0,1,0,1,0};
+float pitch[8]={220,220,246.9,261.6};
+float currentPitch;
+
void setup() {//some inits
@@ -13,20 +16,20 @@ void setup() {//some inits
}
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 so often
+ currentCount=(int)timer.phasor(20);//this sets up a metronome that ticks every so often
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
-
- trigger=rhythm[playHead];//read through the array
+ trigger=rhythm[playHead%8];//read through the array
+ currentPitch=pitch[(playHead%8)/2];
playHead++;//iterate the playhead
- if (playHead>7) {//but not if it's too big..
- playHead=0;//in which case reset the playhead
- }
//cout << "tick\n";//the clock ticks
lastCount=0;//set lastCount to 0
}
- *output=AR.adsr(sound.pulse(440,0.5),1,0.999, 0.125, 0.9999, 1, trigger);//new, simple ADSR.
+ bassout=envelope.adsr(bass.saw(currentPitch*0.5)+sound.pulse(currentPitch*0.5,mod.phasor(1)),1,0.9995, 0.25, 0.9995, 1, trigger);//new, simple ADSR.
+
+ *output=bassout;
+
diff --git a/maximilian.cpp b/maximilian.cpp
index b81fa49..476a0f9 100644
--- a/maximilian.cpp
+++ b/maximilian.cpp
@@ -820,9 +820,7 @@ void maxiSample::getLength() {
length=myDataSize*0.5;
}
-/* This is a basic compressor. Can also do expansion. It takes standard args for ratio and threshold
- although threshold is in linear amplitude at the moment. It has some crotchety old excuse for gain compensation
- which will do for now, but if you do choose to use it for expansion, watch out as it will bite you in the bum*/
+/* This is a basic compressor. don't use it until the enveloping is finished */
double maxiDyn::compress(double input, double ratio, double threshold) {
@@ -841,11 +839,7 @@ double maxiDyn::compress(double input, double ratio, double threshold) {
return output;
}
-/*reasonably happy with this. input is the input signal to gate, threshold is the threshold of the gate (default 0.9),
- holdtime is how long you want to hold after the attack finishes (default 1 sample). The envelopes are old school digital.
- An attack of 1 is instant (default). An attack of 0.0015 is a few hundred ms. Likewise, a release
- of 0. is instant and a release of 0.9995 (default) is a few hundred ms. When I can be arsed I'll work out
- what this ends up as in seconds and do the conversion. I may never be arsed. It seems a waste. */
+/* ok this isn't quite ready */
double maxiDyn::gate(double input, double threshold, long holdtime, double attack, double release) {
if (fabs(input)>threshold && attackphase!=1){