computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 482ea0f1cb99437d23be9b5f514ad3b0be0faf9b
parent 8c458bafa8185228d4c8b6a4718dd9263202f161
Author: Adam M <[email protected]>
Date:   Tue, 30 Jul 2019 23:22:47 -0500

Merge branch 'master' into folypace

Diffstat:
Mplugin.json | 6+++---
Msrc/ComputerscareDebug.cpp | 37+++++++++++++++++++++++++++++--------
Msrc/ComputerscareILoveCookies.cpp | 36++++++++++++++++++++++++++----------
Msrc/ComputerscareLaundrySoup.cpp | 16++++++++++++++++
Msrc/ComputerscareOhPeas.cpp | 19+++++++++++++++++--
Msrc/ComputerscareRolyPouter.cpp | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 158 insertions(+), 23 deletions(-)

diff --git a/plugin.json b/plugin.json @@ -1,5 +1,6 @@ { "slug": "computerscare", + "version": "1.0.2", "name": "computerscare", "brand": "computerscare", "author": "computerscare", @@ -8,7 +9,7 @@ "pluginUrl": "https://github.com/freddyz/computerscare-vcv-modules", "authorUrl": "https://github.com/freddyz/computerscare-vcv-modules", "sourceUrl": "https://github.com/freddyz/computerscare-vcv-modules", - "version": "1.0.0", + "manualUrl": "https://github.com/freddyz/computerscare-vcv-modules", "modules": [ {"slug":"computerscare-knolypobs", "name":"Knoly Pobs", @@ -46,8 +47,7 @@ "name":"I Love Cookies", "description":"Text-based CV and signal sequencer", "tags":["Sequencer","Utility","Random"] - } - , + }, {"slug":"computerscare-roly-pouter", "name":"Roly Pouter", diff --git a/src/ComputerscareDebug.cpp b/src/ComputerscareDebug.cpp @@ -89,7 +89,7 @@ struct ComputerscareDebug : Module { outputRanges[5][0] = -10.f; outputRanges[5][1] = 10.f; - stepCounter=0; + stepCounter = 0; //params[MANUAL_TRIGGER].randomizable=false; //params[MANUAL_CLEAR_TRIGGER].randomizable=false; @@ -134,9 +134,9 @@ void ComputerscareDebug::process(const ProcessArgs &args) { logLines[0] = inputs[VAL_INPUT].getVoltage(inputChannel); } else if (inputMode == INTERNAL_MODE) { - printf("%f, %f\n",min,spread); + printf("%f, %f\n", min, spread); for (int i = 0; i < 16; i++) { - logLines[i] = min+spread*random::uniform(); + logLines[i] = min + spread * random::uniform(); } } } @@ -152,7 +152,7 @@ void ComputerscareDebug::process(const ProcessArgs &args) { } else if (inputMode == INTERNAL_MODE) { for (int i = 0; i < 16; i++) { - logLines[i] = min+spread*random::uniform(); + logLines[i] = min + spread * random::uniform(); } } } @@ -174,7 +174,7 @@ void ComputerscareDebug::process(const ProcessArgs &args) { else if (inputMode == INTERNAL_MODE) { for (int i = 0; i < 16; i++) { if (clockTriggers[i].process(inputs[TRG_INPUT].getVoltage(i) / 2.f) || manualClockTrigger.process(params[MANUAL_TRIGGER].getValue()) ) { - logLines[i] = min+spread*random::uniform(); + logLines[i] = min + spread * random::uniform(); } } } @@ -195,7 +195,7 @@ void ComputerscareDebug::process(const ProcessArgs &args) { thisVal = ""; for ( unsigned int a = 0; a < NUM_LINES; a = a + 1 ) - { + { thisVal += a > 0 ? "\n" : ""; thisVal += logLines[a] >= 0 ? "+" : ""; thisVal += std::to_string(logLines[a]).substr(0, 10); @@ -203,7 +203,7 @@ void ComputerscareDebug::process(const ProcessArgs &args) { } strValue = thisVal; } - + } struct HidableSmallSnapKnob : SmallSnapKnob { @@ -343,16 +343,37 @@ struct ComputerscareDebugWidget : ModuleWidget { { json_t *rootJ = ModuleWidget::toJson(); json_object_set_new(rootJ, "outputRange", json_integer(debug->outputRangeEnum)); + + json_t *sequencesJ = json_array(); + + for (int i = 0; i < 16; i++) { + json_t *sequenceJ = json_real(debug->logLines[i]); + json_array_append_new(sequencesJ, sequenceJ); + } + json_object_set_new(rootJ, "lines", sequencesJ); return rootJ; } void fromJson(json_t *rootJ) override { + float val; ModuleWidget::fromJson(rootJ); // button states json_t *outputRangeEnumJ = json_object_get(rootJ, "outputRange"); if (outputRangeEnumJ) { debug->outputRangeEnum = json_integer_value(outputRangeEnumJ); } + json_t *sequencesJ = json_object_get(rootJ, "lines"); + + if (sequencesJ) { + for (int i = 0; i < 16; i++) { + json_t *sequenceJ = json_array_get(sequencesJ, i); + if (sequenceJ) + val = json_real_value(sequenceJ); + debug->logLines[i] = val; + } + } + + } void appendContextMenu(Menu *menu) override; ComputerscareDebug *debug; @@ -362,7 +383,7 @@ struct DebugOutputRangeItem : MenuItem { int outputRangeEnum; void onAction(const event::Action &e) override { debug->outputRangeEnum = outputRangeEnum; - printf("outputRangeEnum %i\n",outputRangeEnum); + printf("outputRangeEnum %i\n", outputRangeEnum); } void step() override { rightText = CHECKMARK(debug->outputRangeEnum == outputRangeEnum); diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp @@ -156,14 +156,14 @@ struct ComputerscareILoveCookies : Module { } void wiggleKnobs() { - /*for (int i = 0; i < numKnobs; i++) { + for (int i = 0; i < numKnobs; i++) { float prev = params[KNOB_PARAM + i].getValue(); if (random::uniform() < 0.7) { float rv = (10 * random::uniform() + 2 * prev) / 3; - this->smallLetterKnobs[i]->setValue(rv); - params[KNOB_PARAM + i].getValue() = rv; + params[KNOB_PARAM+i].setValue(rv); } - }*/ + } + } void randomizeTextFields() { std::string mainlookup = knoblookup; @@ -475,7 +475,7 @@ struct CookiesCurrentStepDisplay : SmallLetterDisplay //this->setNumDivisionsString(); if (module) { - //this->currentWorkingStepDisplays[i]->value = this->newABS[i].getWorkingStepDisplay(); + //this->currentWorkingStepDisplays[i]->value = this->newABS[i].getWorkingStepDisplay(); value = module->newABS[index].getWorkingStepDisplay(); @@ -577,17 +577,17 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { //individual reset input addInput(createInput<InPort>(mm2px(Vec(12 + xStart, verticalStart + verticalSpacing * i - 10)), module, ComputerscareILoveCookies::RESET_INPUT + i)); - + //sequence input field textField = new CookiesTF2(i); textField->box.pos = mm2px(Vec(1 + xStart, verticalStart + verticalSpacing * i)); - textField->box.size = mm2px(Vec(63, 7)); + textField->box.size = mm2px(Vec(63, 7)); textField->multiline = false; textField->color = nvgRGB(0xC0, 0xE7, 0xDE); textField->module = module; addChild(textField); cookiesTextFields[i] = textField; - //module->textFields[i] = textField; + //module->textFields[i] = textField; //active/total steps display cookiesSmallDisplay = new CookiesSmallDisplay(i); @@ -609,7 +609,7 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { addChild(currentWorkingStepDisplay); currentWorkingStepDisplays[i] = currentWorkingStepDisplay; - // module->currentWorkingStepDisplays[i] = currentWorkingStepDisplay; + // module->currentWorkingStepDisplays[i] = currentWorkingStepDisplay; addParam(createParam<ComputerscareInvisibleButton>(mm2px(Vec(21 + xStart, verticalStart - 9.9 + verticalSpacing * i)), module, ComputerscareILoveCookies::INDIVIDUAL_RESET_PARAM + i)); } @@ -642,6 +642,22 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { cookies->currentFormula[i] = val; } } + else { + json_t *textJLegacy = json_object_get(rootJ, "data"); + if (textJLegacy) { + json_t *seqJLegacy = json_object_get(textJLegacy, "sequences"); + + if (seqJLegacy) { + for (int i = 0; i < numFields; i++) { + json_t *sequenceJ = json_array_get(seqJLegacy, i); + if (sequenceJ) + val = json_string_value(sequenceJ); + cookiesTextFields[i]->text = val; + cookies->currentFormula[i] = val; + } + } + } + } } ComputerscareILoveCookies *cookies; @@ -655,7 +671,7 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { CookiesSmallDisplay* cookiesSmallDisplays[numFields]; SmallLetterDisplay* smallLetterDisplay; - + CookiesCurrentStepDisplay* currentWorkingStepDisplay; CookiesCurrentStepDisplay* currentWorkingStepDisplays[numFields]; diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp @@ -423,6 +423,22 @@ struct ComputerscareLaundrySoupWidget : ModuleWidget { laundry->currentFormula[i] = val; } } + else { + json_t *textJLegacy = json_object_get(rootJ, "data"); + if (textJLegacy) { + json_t *seqJLegacy = json_object_get(textJLegacy, "sequences"); + + if (seqJLegacy) { + for (int i = 0; i < numFields; i++) { + json_t *sequenceJ = json_array_get(seqJLegacy, i); + if (sequenceJ) + val = json_string_value(sequenceJ); + laundryTextFields[i]->text = val; + laundry->currentFormula[i] = val; + } + } + } + } } ComputerscareLaundrySoup *laundry; diff --git a/src/ComputerscareOhPeas.cpp b/src/ComputerscareOhPeas.cpp @@ -427,14 +427,29 @@ struct ComputerscareOhPeasWidget : ModuleWidget void fromJson(json_t *rootJ) override { + std::string val; ModuleWidget::fromJson(rootJ); // text + json_t *textJ = json_object_get(rootJ, "sequences"); if (textJ) textFieldTemp->text = json_string_value(textJ); - - //module->setQuant(); + + json_t *textJLegacy = json_object_get(rootJ, "data"); + if (textJLegacy) { + json_t *seqJLegacy = json_object_get(textJLegacy, "sequences"); + + if (seqJLegacy) { + json_t *theSequence = json_array_get(seqJLegacy, 0); + if (theSequence) { + val = json_string_value(theSequence); + printf("yep there is json from Rack 0.6 %s\n", val.c_str()); + textFieldTemp->text = val; + + } + } + } } diff --git a/src/ComputerscareRolyPouter.cpp b/src/ComputerscareRolyPouter.cpp @@ -36,6 +36,11 @@ struct ComputerscareRolyPouter : Module { } } + void setAll(int setVal) { + for(int i = 0; i < 16; i++) { + params[KNOB + i].setValue(setVal); + } + } void process(const ProcessArgs &args) override { counter++; int inputChannels = inputs[POLY_INPUT].getChannels(); @@ -146,7 +151,69 @@ struct ComputerscareRolyPouterWidget : ModuleWidget { } PouterSmallDisplay* pouterSmallDisplay; SmallLetterDisplay* outputChannelLabel; + + void addMenuItems(ComputerscareRolyPouter *pouter, Menu *menu); + void appendContextMenu(Menu *menu) override; +}; +struct ssmi : MenuItem +{ + ComputerscareRolyPouter *pouter; + ComputerscareRolyPouterWidget *pouterWidget; + int mySetVal = 1; + ssmi(int setVal) + { + mySetVal=setVal; + //scale = scaleInput; + } + + void onAction(const event::Action &e) override + { + pouter->setAll(mySetVal); + + // peas->setQuant(); + } }; +void ComputerscareRolyPouterWidget::addMenuItems(ComputerscareRolyPouter *pouter, Menu *menu) +{ + for(int i = 1; i < 17; i++) { + ssmi *menuItem = new ssmi(i); + menuItem->text = "Set all to ch. "+std::to_string(i); + menuItem->pouter = pouter; + menuItem->pouterWidget = this; + menu->addChild(menuItem); + } + +} +void ComputerscareRolyPouterWidget::appendContextMenu(Menu *menu) +{ + ComputerscareRolyPouter *pouter = dynamic_cast<ComputerscareRolyPouter *>(this->module); + + MenuLabel *spacerLabel = new MenuLabel(); + menu->addChild(spacerLabel); + + + MenuLabel *modeLabel = new MenuLabel(); + modeLabel->text = "Presets"; + menu->addChild(modeLabel); + + addMenuItems(pouter, menu); + /*scaleItemAdd(peas, menu, "212212", "Natural Minor"); + scaleItemAdd(peas, menu, "2232", "Major Pentatonic"); + scaleItemAdd(peas, menu, "3223", "Minor Pentatonic"); + scaleItemAdd(peas, menu, "32113", "Blues"); + scaleItemAdd(peas, menu, "11111111111", "Chromatic"); + scaleItemAdd(peas, menu, "212213", "Harmonic Minor"); + scaleItemAdd(peas, menu, "22222", "Whole-Tone"); + scaleItemAdd(peas, menu, "2121212", "Whole-Half Diminished"); + + scaleItemAdd(peas, menu, "43", "Major Triad"); + scaleItemAdd(peas, menu, "34", "Minor Triad"); + scaleItemAdd(peas, menu, "33", "Diminished Triad"); + scaleItemAdd(peas, menu, "434", "Major 7 Tetrachord"); + scaleItemAdd(peas, menu, "433", "Dominant 7 Tetrachord"); + scaleItemAdd(peas, menu, "343", "Minor 7 Tetrachord"); + scaleItemAdd(peas, menu, "334", "Minor 7 b5 Tetrachord");*/ +} Model *modelComputerscareRolyPouter = createModel<ComputerscareRolyPouter, ComputerscareRolyPouterWidget>("computerscare-roly-pouter");