Skip to content

Commit

Permalink
compressor lookahead and convenience functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskiefer committed Jan 6, 2023
1 parent 43e61d4 commit 654bb10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 0 additions & 3 deletions cpp/commandline/maximilian_examples/17.Compressor/main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 1,7 @@
#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.
maxiDyn compressor; //this is a compressor
maxiDynamics dyn;
maxiOsc osc1, osc2;

void setup() {//some inits

Expand All @@ -23,7 21,6 @@ void play(double *output) {//this is where the magic happens. Very slow magic.
//here, we're just compressing the file in real-time

double out=beats.play();
double oscs = osc1.saw(300);// * (osc2.phasor(0.5) > 0.5);
out = dyn.play(out, out,
0, 0, 0, // above high thresh
-30, 100, 1 //below low thresh
Expand Down
14 changes: 14 additions & 0 deletions src/maximilian.h
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 2425,20 @@ class CHEERP_EXPORT maxiDynamics {
return sigOut;
}

double compress(double sig, double threshold, double ratio, double knee) {
return play(sig, sig, threshold, ratio, knee, 0, 0, 0);
}
double sidechainCompress(double sig, double control, double threshold, double ratio, double knee) {
return play(sig, control, threshold, ratio, knee, 0, 0, 0);
}
double compandAbove(double sig, double control, double threshold, double ratio, double knee) {
return play(sig, control, threshold, ratio, knee, 0, 0, 0);
}
double compandBelow(double sig, double control, double threshold, double ratio, double knee) {
return play(sig, control, 0, 0, 0, threshold, ratio, knee);
}


void setAttackHigh(double attack) {
arEnvHigh.setTime(0, attack);
}
Expand Down

0 comments on commit 654bb10

Please sign in to comment.