Skip to content

Commit

Permalink
Anti-pop mute and solo buttons in Mixovnik
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomek Sosnowski committed Apr 15, 2018
1 parent 4340525 commit f074262
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SLUG = Koralfx-Modules

# Must follow the format in the Versioning section of https://vcvrack.com/manual/PluginDevelopmentTutorial.html
VERSION = 0.6.7
VERSION = 0.6.8

# FLAGS will be passed to both the C and C++ compiler
FLAGS +=
Expand Down
108 changes: 83 additions & 25 deletions src/Mixovnik/Mixovnik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void Mixovnik::step() {
float cvVolumeRatio[16];


//Solo test
//First Solo test
bool soloTest = false;
int step = 0;
do {
Expand All @@ -25,37 +25,94 @@ void Mixovnik::step() {



//Anti Pop Mix
antiPopMixLeft -= (params[MIX_L_MUTE].value ==1) ? antiPopSpeed : -antiPopSpeed;
if (antiPopMixLeft <0 ) antiPopMixLeft = 0;
if (antiPopMixLeft >1 ) antiPopMixLeft = 1;

antiPopMixRight -= (params[MIX_R_MUTE].value ==1) ? antiPopSpeed : -antiPopSpeed;
if (antiPopMixRight <0 ) antiPopMixRight = 0;
if (antiPopMixRight >1 ) antiPopMixRight = 1;

//Anti Pop Auxes
antiPopAux1 -= (params[AUX1_MUTE].value ==1) ? antiPopSpeed : -antiPopSpeed;
if (antiPopAux1 <0 ) antiPopAux1 = 0;
if (antiPopAux1 >1 ) antiPopAux1 = 1;

antiPopAux2 -= (params[AUX2_MUTE].value ==1) ? antiPopSpeed : -antiPopSpeed;
if (antiPopAux2 <0 ) antiPopAux2 = 0;
if (antiPopAux2 >1 ) antiPopAux2 = 1;



// Main loop
for (int i = 0; i < 16; i++) {

//Get signal
float INPUT_SIGNAL = 0;
cvVolumeRatio[i] = 1;
float INPUT_SIGNAL = 0;
cvVolumeRatio[i] = 1;

if (inputs[STRIPE_CV_VOL_INPUT + i].active) cvVolumeRatio[i] = inputs[STRIPE_CV_VOL_INPUT + i].value/10;

if (i%2 == 0) {
if (soloTest && params[LINK_PARAM + (i/2)].value == 1) {
params[SOLO_PARAM + i +1].value = params[SOLO_PARAM + i].value;
}
INPUT_SIGNAL = inputs[STRIPE_INPUT + i].value * cvVolumeRatio[i] *
params[VOLUME_PARAM + i].value * ((params[MUTE_PARAM + i].value == 0) ? 1.0 : 0.0);

if (inputs[STRIPE_CV_VOL_INPUT + i].active) cvVolumeRatio[i] = inputs[STRIPE_CV_VOL_INPUT + i].value/10;


bool nieparzystyStripe = (i%2 == 0) ? true : false;
bool linkActive = (params[LINK_PARAM + ((i-1)/2)].value == 1) ? true : false;

//stripes 1,3,5,7,9,11,13,15
if (nieparzystyStripe) {
INPUT_SIGNAL = inputs[STRIPE_INPUT + i].value * cvVolumeRatio[i] * params[VOLUME_PARAM + i].value;
//stripes 2,4,6,8,10,12,14,16
} else {
if (params[LINK_PARAM + ((i-1)/2)].value == 0) {
INPUT_SIGNAL = inputs[STRIPE_INPUT + i].value * cvVolumeRatio[i] *
params[VOLUME_PARAM + i].value * ((params[MUTE_PARAM + i].value == 0) ? 1.0 : 0.0);
//link with left stripes?
if (linkActive) {
INPUT_SIGNAL = inputs[STRIPE_INPUT + i].value * cvVolumeRatio[i-1] * params[VOLUME_PARAM + (i - 1)].value ;
} else {
INPUT_SIGNAL = inputs[STRIPE_INPUT + i].value * cvVolumeRatio[i-1] *
params[VOLUME_PARAM + (i - 1)].value * ((params[MUTE_PARAM + i -1].value == 0) ? 1.0 : 0.0);
INPUT_SIGNAL = inputs[STRIPE_INPUT + i].value * cvVolumeRatio[i] * params[VOLUME_PARAM + i].value;
}

}


//MUTE SOLO test for Anti Pop

//SOLO
if (soloTest) {
if (params[SOLO_PARAM + i].value == 0) INPUT_SIGNAL = 0;
if (nieparzystyStripe) {
antiPopCurrentSpeed[i] = (params[MUTE_PARAM + i].value == 0 && params[SOLO_PARAM + i].value == 1)
? +antiPopSpeed : -antiPopSpeed;
} else {
if (linkActive) {
antiPopCurrentSpeed[i] = (params[MUTE_PARAM + i -1].value == 0 && params[SOLO_PARAM + i -1].value == 1)
? +antiPopSpeed : -antiPopSpeed;
} else {
antiPopCurrentSpeed[i] = (params[MUTE_PARAM + i].value == 0 && params[SOLO_PARAM + i].value == 1)
? +antiPopSpeed : -antiPopSpeed;
}
}
//NO SOLO
} else {
if (nieparzystyStripe) {
antiPopCurrentSpeed[i] = (params[MUTE_PARAM + i].value == 1) ? -antiPopSpeed : +antiPopSpeed;
} else {
if (linkActive) {
antiPopCurrentSpeed[i] = (params[MUTE_PARAM + i -1].value == 1) ? -antiPopSpeed : +antiPopSpeed;
} else {
antiPopCurrentSpeed[i] = (params[MUTE_PARAM + i].value == 1) ? -antiPopSpeed : +antiPopSpeed;
}
}
}


//Anti Pop final

if (!inputs[STRIPE_INPUT + i].active) antiPopCurrentSpeed[i] = -antiPopSpeed;

antiPop[i] += antiPopCurrentSpeed[i];
if (antiPop[i] <0 ) antiPop[i] = 0;
if (antiPop[i] >1 ) antiPop[i] = 1;
INPUT_SIGNAL *= antiPop[i];

//Constant-power panning
float KNOB_PAN_POS = params[PAN_PARAM + i].value + (inputs[STRIPE_CV_PAN_INPUT + i].value / 5);

Expand Down Expand Up @@ -102,7 +159,6 @@ void Mixovnik::step() {
lights[SIGNAL_LIGHT_NORMAL + i*2 +1].value = 1;
}


}

//AUX1 and AUX2 sends
Expand All @@ -114,16 +170,16 @@ void Mixovnik::step() {

//AUX1 and AUX2 returns
float AUX1_SUM_L =
inputs[AUX1_INPUT_L].value * params[AUX1_VOLUME].value * ((params[AUX1_MUTE].value == 0) ? 1.0 : 0.0);
inputs[AUX1_INPUT_L].value * params[AUX1_VOLUME].value * antiPopAux1;

float AUX1_SUM_R =
inputs[AUX1_INPUT_R].value * params[AUX1_VOLUME].value * ((params[AUX1_MUTE].value == 0) ? 1.0 : 0.0);
inputs[AUX1_INPUT_R].value * params[AUX1_VOLUME].value * antiPopAux1;

float AUX2_SUM_L =
inputs[AUX2_INPUT_L].value * params[AUX2_VOLUME].value * ((params[AUX2_MUTE].value == 0) ? 1.0 : 0.0);
inputs[AUX2_INPUT_L].value * params[AUX2_VOLUME].value * antiPopAux2;

float AUX2_SUM_R =
inputs[AUX2_INPUT_R].value * params[AUX2_VOLUME].value * ((params[AUX2_MUTE].value == 0) ? 1.0 : 0.0);
inputs[AUX2_INPUT_R].value * params[AUX2_VOLUME].value * antiPopAux2;

SUM_L += AUX1_SUM_L + AUX2_SUM_L;
SUM_R += AUX1_SUM_R + AUX2_SUM_R;
Expand All @@ -138,14 +194,15 @@ void Mixovnik::step() {
SUM_R *= ((params[MIX_LINK].value == 0) ? params[MIX_R_VOLUME].value : params[MIX_L_VOLUME].value);

//Final mix with mute switches
SUM_L *= ((params[MIX_L_MUTE].value == 0) ? 1.0 : 0.0);
SUM_L *= antiPopMixLeft;

if (params[MIX_LINK].value == 1) {
SUM_R *= ((params[MIX_L_MUTE].value == 0) ? 1.0 : 0.0);
SUM_R *= antiPopMixLeft;
} else {
SUM_R *= ((params[MIX_R_MUTE].value == 0) ? 1.0 : 0.0);
SUM_R *= antiPopMixRight;
}


//Final out
outputs[STEREO_OUTPUT_L].value = SUM_L;
outputs[STEREO_OUTPUT_R].value = SUM_R;
Expand All @@ -156,6 +213,7 @@ void Mixovnik::step() {

lights[AUX1_LIGHT].value = (fabs(AUX1_SUM_L) > 5 || fabs(AUX1_SUM_R) > 5) ? 1.0 : 0.0;
lights[AUX2_LIGHT].value = (fabs(AUX2_SUM_L) > 5 || fabs(AUX2_SUM_R) > 5) ? 1.0 : 0.0;

}

///////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 7 additions & 1 deletion src/Mixovnik/Mixovnik.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ struct Mixovnik : Module {
};

int panelStyle = 0;

float antiPop [16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
float antiPopCurrentSpeed [16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
float antiPopMixLeft = 0.0f;
float antiPopMixRight = 0.0f;
float antiPopAux1 = 0.0f;
float antiPopAux2 = 0.0f;
float antiPopSpeed = 0.0005f;
///////////////////////////////////////////////////////////////////////////////

Mixovnik();
Expand Down

0 comments on commit f074262

Please sign in to comment.