Skip to content

Commit

Permalink
Add option to disable DPW anti-aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveBenham committed Nov 28, 2024
1 parent 2783850 commit 15a780c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
Binary file modified doc/QuadVCPolarizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 19 additions & 8 deletions src/Oscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ struct Oscillator : VenomModule {
};

bool clampLevel = true;
bool disableDPW = false;
bool disableOver[INPUTS_LEN]{};
bool unity5[5]{};
bool bipolar[5]{};
Expand Down Expand Up @@ -320,10 +321,12 @@ struct Oscillator : VenomModule {
return -(((-0.540347 * t2 + 2.53566) * t2 - 5.16651) * t2 + 3.14159) * t;
}

void setMode() {
void setMode(bool aliasSuppressOnly = false) {
currentMode = static_cast<int>(params[MODE_PARAM].getValue());
mode = currentMode>5 ? 1 : currentMode>2 ? 0 : currentMode;
aliasSuppress = !mode;
aliasSuppress = !mode && !disableDPW;
if (aliasSuppressOnly)
return;
if (!paramExtensions[OVER_PARAM].locked)
params[OVER_PARAM].setValue(modeDefaultOver[mode]);
paramQuantities[OVER_PARAM]->defaultValue = modeDefaultOver[mode];
Expand Down Expand Up @@ -1017,6 +1020,7 @@ struct Oscillator : VenomModule {
json_object_set_new(rootJ, "linDCCouple", json_boolean(linDCCouple));
json_object_set_new(rootJ, "overParam", json_integer(params[OVER_PARAM].getValue()));
json_object_set_new(rootJ, "clampLevel", json_boolean(clampLevel));
json_object_set_new(rootJ, "disableDPW", json_boolean(disableDPW));
return rootJ;
}

Expand Down Expand Up @@ -1060,16 +1064,14 @@ struct Oscillator : VenomModule {
if ((val = json_object_get(rootJ, "linDCCouple"))) {
linDCCouple = json_boolean_value(val);
}
val = json_object_get(rootJ, "disableDPW");
disableDPW = val ? json_boolean_value(val) : true;
setMode();
if ((val = json_object_get(rootJ, "overParam"))) {
params[OVER_PARAM].setValue(json_integer_value(val));
}
if ((val = json_object_get(rootJ, "clampLevel"))) {
clampLevel = json_boolean_value(val);
}
else {
clampLevel = false;
}
val = json_object_get(rootJ, "clampLevel");
clampLevel = val ? json_boolean_value(val) : false;
}

};
Expand Down Expand Up @@ -1307,6 +1309,15 @@ struct OscillatorWidget : VenomWidget {
Oscillator* module = dynamic_cast<Oscillator*>(this->module);
menu->addChild(new MenuSeparator);
menu->addChild(createBoolPtrMenuItem("Limit levels to 100%", "", &module->clampLevel));
menu->addChild(createBoolMenuItem("Disable DPW anti-alias", "",
[=]() {
return module->disableDPW;
},
[=](bool val) {
module->disableDPW = val;
module->setMode(true);
}
));
VenomWidget::appendContextMenu(menu);
}

Expand Down
19 changes: 17 additions & 2 deletions src/VCOUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct VCOUnit : VenomModule {
float shpScale = 0.2f;
bool softSync = false;
bool alternate = false;
bool disableDPW = false;
bool aliasSuppress = false;
using float_4 = simd::float_4;
int oversample = -1;
Expand Down Expand Up @@ -192,10 +193,12 @@ struct VCOUnit : VenomModule {
return -(((-0.540347 * t2 + 2.53566) * t2 - 5.16651) * t2 + 3.14159) * t;
}

void setMode() {
void setMode(bool aliasSuppressOnly = false) {
currentMode = static_cast<int>(params[MODE_PARAM].getValue());
mode = currentMode>5 ? 1 : currentMode>2 ? 0 : currentMode;
aliasSuppress = !mode;
aliasSuppress = !(mode || disableDPW);
if (aliasSuppressOnly)
return;
if (!paramExtensions[OVER_PARAM].locked)
params[OVER_PARAM].setValue(modeDefaultOver[mode]);
paramQuantities[OVER_PARAM]->defaultValue = modeDefaultOver[mode];
Expand Down Expand Up @@ -668,6 +671,7 @@ struct VCOUnit : VenomModule {
json_object_set_new(rootJ, "linDCCouple", json_boolean(linDCCouple));
json_object_set_new(rootJ, "overParam", json_integer(params[OVER_PARAM].getValue()));
json_object_set_new(rootJ, "clampLevel", json_boolean(clampLevel));
json_object_set_new(rootJ, "disableDPW", json_boolean(disableDPW));
json_object_set_new(rootJ, "shapeModeParam", json_integer(params[SHAPE_MODE_PARAM].getValue()));
return rootJ;
}
Expand All @@ -691,6 +695,8 @@ struct VCOUnit : VenomModule {
if ((val = json_object_get(rootJ, "linDCCouple"))) {
linDCCouple = json_boolean_value(val);
}
val = json_object_get(rootJ, "disableDPW");
disableDPW = val ? json_boolean_value(val) : true;
setMode();
if ((val = json_object_get(rootJ, "overParam"))) {
params[OVER_PARAM].setValue(json_integer_value(val));
Expand Down Expand Up @@ -898,6 +904,15 @@ struct VCOUnitWidget : VenomWidget {
VCOUnit* module = dynamic_cast<VCOUnit*>(this->module);
menu->addChild(new MenuSeparator);
menu->addChild(createBoolPtrMenuItem("Limit level to 100%", "", &module->clampLevel));
menu->addChild(createBoolMenuItem("Disable DPW anti-alias", "",
[=]() {
return module->disableDPW;
},
[=](bool val) {
module->disableDPW = val;
module->setMode(true);
}
));
VenomWidget::appendContextMenu(menu);
}

Expand Down

0 comments on commit 15a780c

Please sign in to comment.