computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 584e77967f17f8fecacdb16375439c7deb1aacd7
parent 5fc7ba31e2eee2011e4f16daa3e2ab349a72a1c9
Author: Adam M <aemalone@gmail.com>
Date:   Wed, 11 Dec 2019 22:57:11 -0600

Merge branch 'master' into stolyfickpigure

Diffstat:
ACHANGELOG.MD | 9+++++++++
Mplugin.json | 4++--
Msrc/ComputerscareLaundrySoup.cpp | 23++++++++++-------------
Msrc/ComputerscarePatchSequencer.cpp | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
4 files changed, 103 insertions(+), 47 deletions(-)

diff --git a/CHANGELOG.MD b/CHANGELOG.MD @@ -0,0 +1,8 @@ +1.2.0 +Laundry Soup +- Fix regression which made patches load incorrectly +- Add right-click options for polyphony +- Move JSON loading to module + +Father & Son Patch Sequencer +- Add right-click options for polyphony +\ No newline at end of file diff --git a/plugin.json b/plugin.json @@ -1,6 +1,6 @@ { "slug": "computerscare", - "version": "1.1.1", + "version": "1.2.0", "name": "computerscare", "brand": "computerscare", "author": "computerscare", @@ -40,7 +40,7 @@ {"slug":"computerscare-laundry-soup", "name":"Laundry Soup", "description":"Rhythm sequencer, pulse generator, text-based", - "tags":["Sequencer","Clock modulator","Random"] + "tags":["Sequencer","Clock modulator","Random","Polyphonic"] }, {"slug":"computerscare-i-love-cookies", diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp @@ -107,13 +107,6 @@ struct ComputerscareLaundrySoup : Module { ComputerscareLaundrySoup() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); for (int i = 0; i < numFields; i++) { - /*if (i < numFields - 1) { - currentTextFieldValue[i] = std::to_string(i + 1); - } - else { - currentTextFieldValue[i] = randomFormula(); - }*/ - manualSet[i] = false; inError[i] = false; @@ -121,8 +114,6 @@ struct ComputerscareLaundrySoup : Module { checkIfShouldChange(i); resetOneOfThem(i); - - LaundryPoly lp = LaundryPoly(currentFormula[i]); laundryPoly[i] = lp; channelCountEnum[i] = -1; @@ -340,12 +331,18 @@ void ComputerscareLaundrySoup::process(const ProcessArgs &args) { currentTextFieldValue[i] = i < numFields - 1 ? std::to_string(i + 1) : randomFormula(); manualSet[i] = true; } + for (int i = 0; i < numFields; i++) { + checkTextField(i); + checkChannelCount(i); + checkIfShouldChange(i); + } jsonLoaded = true; } - for (int i = 0; i < numFields; i++) { - - checkTextField(i); - checkChannelCount(i); + else { + for (int i = 0; i < numFields; i++) { + checkTextField(i); + checkChannelCount(i); + } } checkCounter = 0; } diff --git a/src/ComputerscarePatchSequencer.cpp b/src/ComputerscarePatchSequencer.cpp @@ -65,13 +65,14 @@ struct ComputerscarePatchSequencer : Module { int randomizationStepEnum = 0; //0: edit step, 1: active step, 2: all steps int randomizationOutputBoundsEnum = 1; //0: randomize exactly one per output, 1: randomize exactly one per output, 2: randomize 1 or more, 3: randomize 0 or more - int channelCount[numInputs]; + int channelCount[numOutputs]; + int channelCountEnum = -1; ComputerscarePatchSequencer() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configParam(STEPS_PARAM, 1.f, 16.f, 2.0f, "Number of Steps"); - for(int i = 0; i < numOutputs; i++) { - channelCount[i]=0; + for (int i = 0; i < numOutputs; i++) { + channelCount[i] = 0; } } void process(const ProcessArgs &args) override; @@ -79,15 +80,21 @@ struct ComputerscarePatchSequencer : Module { void updateChannelCount() { int currentMax; - for(int j = 0; j < numOutputs; j++) { - currentMax=0; - for(int i = 0; i < numInputs; i++) { - if (switch_states[address][i][j] && inputs[INPUT_JACKS+i].isConnected()) { - currentMax = std::max(currentMax,inputs[INPUT_JACKS+i].getChannels()); + + for (int j = 0; j < numOutputs; j++) { + if (channelCountEnum == -1) { + currentMax = 0; + for (int i = 0; i < numInputs; i++) { + if (switch_states[address][i][j] && inputs[INPUT_JACKS + i].isConnected()) { + currentMax = std::max(currentMax, inputs[INPUT_JACKS + i].getChannels()); + } } } - channelCount[j]=currentMax; - outputs[OUTPUTS+j].setChannels(currentMax); + else { + currentMax = channelCountEnum; + } + channelCount[j] = currentMax; + outputs[OUTPUTS + j].setChannels(currentMax); } } @@ -239,7 +246,7 @@ void ComputerscarePatchSequencer::process(const ProcessArgs &args) { } } if (counter > 512) { - updateChannelCount(); + updateChannelCount(); for (int i = 0 ; i < 10 ; i++) { for (int j = 0 ; j < 10 ; j++) @@ -334,31 +341,31 @@ struct NumberDisplayWidget3 : TransparentWidget { { // Background //if (module) { - NVGcolor backgroundColor = nvgRGB(0x00, 0x00, 0x00); + NVGcolor backgroundColor = nvgRGB(0x00, 0x00, 0x00); - nvgBeginPath(args.vg); - nvgRoundedRect(args.vg, 0.0, 0.0, box.size.x, box.size.y, 4.0); - nvgFillColor(args.vg, backgroundColor); - nvgFill(args.vg); + nvgBeginPath(args.vg); + nvgRoundedRect(args.vg, 0.0, 0.0, box.size.x, box.size.y, 4.0); + nvgFillColor(args.vg, backgroundColor); + nvgFill(args.vg); - // text - nvgFontSize(args.vg, 13); - nvgFontFaceId(args.vg, font->handle); - nvgTextLetterSpacing(args.vg, 2.5); + // text + nvgFontSize(args.vg, 13); + nvgFontFaceId(args.vg, font->handle); + nvgTextLetterSpacing(args.vg, 2.5); - std::stringstream to_display; - if(module) { - to_display << std::setw(3) << *value; - } - else { - to_display << std::setw(3) << "16"; - } + std::stringstream to_display; + if (module) { + to_display << std::setw(3) << *value; + } + else { + to_display << std::setw(3) << "16"; + } - Vec textPos = Vec(6.0f, 17.0f); - NVGcolor textColor = nvgRGB(0xC0, 0xE7, 0xDE); - nvgFillColor(args.vg, textColor); - nvgText(args.vg, textPos.x, textPos.y, to_display.str().c_str(), NULL); - // } + Vec textPos = Vec(6.0f, 17.0f); + NVGcolor textColor = nvgRGB(0xC0, 0xE7, 0xDE); + nvgFillColor(args.vg, textColor); + nvgText(args.vg, textPos.x, textPos.y, to_display.str().c_str(), NULL); + // } } }; @@ -488,6 +495,7 @@ struct ComputerscarePatchSequencerWidget : ModuleWidget { } json_object_set_new(rootJ, "buttons", button_statesJ); json_object_set_new(rootJ, "onlyRandomizeActive", json_boolean(fatherSon->onlyRandomizeActive)); + json_object_set_new(rootJ, "channelCountEnum", json_integer(fatherSon->channelCountEnum)); json_object_set_new(rootJ, "randomizationStepEnum", json_integer(fatherSon->getRandomizationStepEnum())); json_object_set_new(rootJ, "randomizationOutputBoundsEnum", json_integer(fatherSon->getRandomizationOutputBoundsEnum())); return rootJ; @@ -517,6 +525,9 @@ struct ComputerscarePatchSequencerWidget : ModuleWidget { json_t *randomizationStepEnumJ = json_object_get(rootJ, "randomizationStepEnum"); if (randomizationStepEnumJ) { fatherSon->setRandomizationStepEnum(json_integer_value(randomizationStepEnumJ)); } + json_t *channelCountEnumJ = json_object_get(rootJ, "channelCountEnum"); + if (channelCountEnumJ) { fatherSon->channelCountEnum = json_integer_value(channelCountEnumJ); } + json_t *randomizationOutputBoundsEnumJ = json_object_get(rootJ, "randomizationOutputBoundsEnum"); if (randomizationOutputBoundsEnumJ) { fatherSon->setRandomizationOutputBoundsEnum(json_integer_value(randomizationOutputBoundsEnumJ)); } @@ -562,6 +573,37 @@ struct WhichRandomizationOutputBoundsItem : MenuItem { MenuItem::step(); } }; + +struct FatherSonChannelItem : MenuItem { + ComputerscarePatchSequencer *module; + int channels; + void onAction(const event::Action &e) override { + module->channelCountEnum = channels; + } +}; + + +struct FatherSonChannelsItem : MenuItem { + ComputerscarePatchSequencer *module; + Menu *createChildMenu() override { + Menu *menu = new Menu; + for (int channels = -1; channels <= 16; channels++) { + FatherSonChannelItem *item = new FatherSonChannelItem; + if (channels < 0) { + item->text = "Automatic"; + } + else { + item->text = string::f("%d", channels); + } + item->rightText = CHECKMARK(module->channelCountEnum == channels); + item->module = module; + item->channels = channels; + menu->addChild(item); + } + return menu; + } +}; + void ComputerscarePatchSequencerWidget::appendContextMenu(Menu *menu) { ComputerscarePatchSequencer *patchSequencer = dynamic_cast<ComputerscarePatchSequencer *>(this->module); @@ -569,6 +611,14 @@ void ComputerscarePatchSequencerWidget::appendContextMenu(Menu *menu) MenuLabel *spacerLabel = new MenuLabel(); menu->addChild(spacerLabel); + FatherSonChannelsItem *channelsItem = new FatherSonChannelsItem; + channelsItem->text = "Output Polyphony"; + channelsItem->rightText = RIGHT_ARROW; + channelsItem->module = patchSequencer; + menu->addChild(channelsItem); + + menu->addChild(new MenuEntry); + MenuLabel *modeLabel = new MenuLabel(); modeLabel->text = "Randomization Options";