Skip to content

Commit

Permalink
Fix bug with switching banks in Noise Plethhora
Browse files Browse the repository at this point in the history
  • Loading branch information
hemmer committed Nov 18, 2024
1 parent 8dfbbc1 commit 4a0da48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v2.8.1
* Noise Plethora
* Fix bug where program choice is wrongly copied between top and bottom sections

## v2.8.0
* Molten Bypass
* Initial release
Expand Down
12 changes: 6 additions & 6 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"slug": "Befaco",
"version": "2.8.0",
"version": "2.8.1",
"license": "GPL-3.0-or-later",
"name": "Befaco",
"brand": "Befaco",
Expand All @@ -14,7 +14,7 @@
{
"slug": "EvenVCO",
"name": "Even VCO",
"description": "Oscillator including even-harmonic waveform",
"description": "Even VCO is an oscillator including even-harmonic waveform",
"manualUrl": "https://www.befaco.org/even-vco/",
"modularGridUrl": "https://www.modulargrid.net/e/befaco-even-vco-",
"tags": [
Expand Down Expand Up @@ -207,7 +207,7 @@
{
"slug": "Muxlicer",
"name": "Muxlicer",
"description": "VC adressable sequential switch and sequencer",
"description": "Muxlicer is a VC adressable sequential switch and sequencer",
"manualUrl": "https://github.com/VCVRack/Befaco/blob/v2/docs/Muxlicer.md",
"modularGridUrl": "https://www.modulargrid.net/e/befaco-muxlicer",
"tags": [
Expand All @@ -232,7 +232,7 @@
{
"slug": "NoisePlethora",
"name": "Noise Plethora",
"description": "Multitimbral noise monster",
"description": "Noise Plethora is a multitimbral noise monster",
"manualUrl": "https://www.befaco.org/noise-plethora/",
"modularGridUrl": "https://www.modulargrid.net/e/befaco-noise-plethora",
"tags": [
Expand Down Expand Up @@ -260,7 +260,7 @@
{
"slug": "PonyVCO",
"name": "PonyVCO",
"description": "Compact Thru-Zero (TZFM) oscillator with wavefolder and VCA",
"description": "Pony VCO is a compact Thru-Zero (TZFM) oscillator with wavefolder and VCA",
"manualUrl": "https://www.befaco.org/pony-vco/",
"modularGridUrl": "https://www.modulargrid.net/e/befaco-pony-vco",
"tags": [
Expand Down Expand Up @@ -348,7 +348,7 @@
{
"slug": "Bandit",
"name": "Bandit",
"description": "A spectral processing playground.",
"description": "Bandit is a spectral processing playground.",
"tags": [
"Equalizer",
"Filter",
Expand Down
24 changes: 13 additions & 11 deletions src/NoisePlethora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ struct NoisePlethora : Module {

// section A/B
bool bypassFilters = false;
std::shared_ptr<NoisePlethoraPlugin> algorithm[2]{nullptr, nullptr}; // pointer to actual algorithm
std::string_view algorithmName[2]{"", ""}; // variable to cache which algorithm is active (after program CV applied)
std::shared_ptr<NoisePlethoraPlugin> algorithm[2] {nullptr, nullptr}; // pointer to actual algorithm
std::string_view algorithmName[2] {"", ""}; // variable to cache which algorithm is active (after program CV applied)
std::map<std::string_view, std::shared_ptr<NoisePlethoraPlugin>> A_algorithms{};
std::map<std::string_view, std::shared_ptr<NoisePlethoraPlugin>> B_algorithms{};

Expand Down Expand Up @@ -197,7 +197,7 @@ struct NoisePlethora : Module {
configParam(Y_A_PARAM, 0.f, 1.f, 0.5f, "YA");
configParam(CUTOFF_CV_A_PARAM, 0.f, 1.f, 0.f, "Cutoff CV A");
configSwitch(FILTER_TYPE_A_PARAM, 0.f, 2.f, 0.f, "Filter type", {"Lowpass", "Bandpass", "Highpass"});
configParam(PROGRAM_PARAM, 0, 1, 0.f, "Program/Bank selection");
configParam(PROGRAM_PARAM, -INFINITY, +INFINITY, 0.f, "Program/Bank selection");
configSwitch(FILTER_TYPE_B_PARAM, 0.f, 2.f, 0.f, "Filter type", {"Lowpass", "Bandpass", "Highpass"});
configParam(CUTOFF_CV_B_PARAM, 0.f, 1.f, 0.f, "Cutoff CV B");
configParam(X_B_PARAM, 0.f, 1.f, 0.5f, "XB");
Expand Down Expand Up @@ -233,7 +233,7 @@ struct NoisePlethora : Module {
getInputInfo(PROG_A_INPUT)->description = "CV sums with active program (0.5V increments)";
getInputInfo(PROG_B_INPUT)->description = "CV sums with active program (0.5V increments)";

for (auto const &entry : MyFactory::Instance()->factoryFunctionRegistry) {
for (auto const& entry : MyFactory::Instance()->factoryFunctionRegistry) {
A_algorithms[entry.first] = MyFactory::Instance()->Create(entry.first);
B_algorithms[entry.first] = MyFactory::Instance()->Create(entry.first);
}
Expand Down Expand Up @@ -440,23 +440,25 @@ struct NoisePlethora : Module {
void processProgramBankKnobLogic(const ProcessArgs& args) {

// program knob will either change program for current bank...
{
if (programButtonDragged) {
// work out the change (in discrete increments) since the program/bank knob started being dragged
const int delta = (int)(dialResolution * (params[PROGRAM_PARAM].getValue() - programKnobReferenceState));

if (programKnobMode == PROGRAM_MODE) {
const int numProgramsForCurrentBank = getBankForIndex(programSelector.getCurrent().getBank()).getSize();
const int currentProgram = programSelector.getCurrent().getProgram();
const int newProgramFromKnob = (int) std::round((numProgramsForCurrentBank - 1) * params[PROGRAM_PARAM].getValue());

if (newProgramFromKnob != currentProgram) {
if (delta != 0) {
const int newProgramFromKnob = unsigned_modulo(programSelector.getCurrent().getProgram() + delta, numProgramsForCurrentBank);
programKnobReferenceState = params[PROGRAM_PARAM].getValue();
setAlgorithmViaProgram(newProgramFromKnob);
}
}
// ...or change bank, (trying to) keep program the same
else {
const int currentBank = programSelector.getCurrent().getBank();
const int newBankFromKnob = (int) std::round((numBanks - 1) * params[PROGRAM_PARAM].getValue());

if (currentBank != newBankFromKnob) {
if (delta != 0) {
const int newBankFromKnob = unsigned_modulo(programSelector.getCurrent().getBank() + delta, numBanks);
programKnobReferenceState = params[PROGRAM_PARAM].getValue();
setAlgorithmViaBank(newBankFromKnob);
}
}
Expand Down

0 comments on commit 4a0da48

Please sign in to comment.