aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--blip.wavbin0 -> 18964 bytes
-rwxr-xr-xmain.cpp35
-rw-r--r--maximilian.cpp16
-rwxr-xr-xmaximilian.h3
-rw-r--r--snare.wavbin0 -> 26734 bytes
5 files changed, 36 insertions, 18 deletions
diff --git a/blip.wav b/blip.wav
new file mode 100644
index 0000000..0ea9b2b
--- /dev/null
+++ b/blip.wav
Binary files differ
diff --git a/main.cpp b/main.cpp
index 1888567..5e60993 100755
--- a/main.cpp
+++ b/main.cpp
@@ -2,21 +2,29 @@
maxiSample kick,snare; //we've got two sampleplayers
+maxiDyn compress,basscompress;
+
+maxiOsc sound1,sound2,sound3;
+
+maxiFilter slew;//we'regoing to use this low pass filter for portamentor
+
maxiOsc timer; //and a timer
-int currentCount,lastCount,playHead,hit[16]={1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1}; //This is the sequence for the kick
+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};
+
-int kicktrigger,snaretrigger;
+int kicktrigger,snaretrigger,basslinetrigger;
-double sampleOut;
+double sampleOut,bassout,bassfreq,temp;
void setup() {//some inits
//YOU HAVE TO PROVIDE THE SAMPLES....
- kick.load("/Users/mickgrierson/Documents/audio/blip.wav");//load in your samples. Provide the full path to a wav file.
- snare.load("/Users/mickgrierson/Documents/audio/snare.wav");//load in your samples. Provide the full path to a wav file.
+ 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.
printf("Summary:\n%s", kick.getSummary());//get info on samples if you like.
@@ -25,6 +33,8 @@ void setup() {//some inits
void play(double *output) {//this is where the magic happens. Very slow magic.
+ bassout=0;
+
currentCount=(int)timer.phasor(8);//this sets up a metronome that ticks 8 times a second
@@ -32,26 +42,29 @@ void play(double *output) {//this is where the magic happens. Very slow magic.
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];
playHead++;//iterate the playhead
lastCount=0;//reset the metrotest
}
- if (kicktrigger==1) {//if the sequence has a 1 in it
+ 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) {
-
+ if (snaretrigger==1 &&playHead>32) {
snare.trigger();//likewise for the snare
}
- sampleOut=kick.playOnce()+snare.playOnce();//just play the file. No looping.
- output[0]=sampleOut;//left channel
- output[1]=sampleOut;//right channel
+ bassout+=basscompress.compressor(sound1.pulse(slew.lopass(bassfreq/2,0.001), sound2.phasor(8)*0.25),10,0.5,0.0001,0.995)*0.25;
+
+ sampleOut=compress.compressor(kick.playOnce()+snare.playOnce(),5,0.5),0.0001,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;
diff --git a/maximilian.cpp b/maximilian.cpp
index d55793d..92f1292 100644
--- a/maximilian.cpp
+++ b/maximilian.cpp
@@ -66,6 +66,11 @@ double maxiOsc::noise() {
return(output);
}
+void maxiOsc::phaseReset(double phaseIn) {
+ phase=phaseIn;
+
+}
+
double maxiOsc::sinewave(double frequency) {
output=sin (phase*(TWOPI));
if ( phase >= 1.0 ) phase -= 1.0;
@@ -164,14 +169,13 @@ double maxiOsc::saw(double frequency) {
}
-double maxiOsc::triangle(double frequency, double phase) {
- output=tri*2;
+double maxiOsc::triangle(double frequency) {
if ( phase >= 1.0 ) phase -= 1.0;
- phase += (1./(maxiSettings::sampleRate/(frequency*chandiv)));
+ phase += (1./(maxiSettings::sampleRate/(frequency)));
if (phase <= 0.5 ) {
- tri = phase;
- } else {
- tri =(1-phase);
+ output =((phase)*4)-1;
+ } else {
+ output =((0.5-phase)*4)-1;
}
return(output);
diff --git a/maximilian.h b/maximilian.h
index 2170782..ad0e116 100755
--- a/maximilian.h
+++ b/maximilian.h
@@ -79,12 +79,13 @@ public:
double phasor(double frequency);
double phasor(double frequency, double startphase, double endphase);
double saw(double frequency);
- double triangle(double frequency,double phase);
+ double triangle(double frequency);
double square(double frequency);
double pulse(double frequency, double duty);
double noise();
double sinebuf(double frequency);
double sinebuf4(double frequency);
+ void phaseReset(double phaseIn);
};
diff --git a/snare.wav b/snare.wav
new file mode 100644
index 0000000..40a9c54
--- /dev/null
+++ b/snare.wav
Binary files differ