Browse Source

Bi-polar CCs options added in MIDICCToCV

pull/386/head
MarcBoule 7 years ago
parent
commit
512f853367
3 changed files with 60 additions and 4 deletions
  1. +1
    -1
      ext/oui-blendish
  2. +58
    -3
      src/core/MidiCCToCV.cpp
  3. +1
    -0
      src/core/core.hpp

+ 1
- 1
ext/oui-blendish

@@ -1 +1 @@
Subproject commit df38de6d065cd93bcbd998aa76bdac063e748573
Subproject commit ac99b8dd4d36ac314dad6d700701e39484c60e06

+ 58
- 3
src/core/MidiCCToCV.cpp View File

@@ -35,11 +35,15 @@ struct MIDICCToCVInterface : MidiIO, Module {
};

CCValue cc[NUM_OUTPUTS];
bool rowIsBipol[NUM_OUTPUTS/4] = {}; //-5V:5V when true, 0V:10V when false. 4 columns of CCs is hardcoded, same as in MIDICCToCVWidget()

MIDICCToCVInterface() : MidiIO(), Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
for (int i = 0; i < NUM_OUTPUTS; i++) {
cc[i].num = i;
}
for (int i = 0; i < (NUM_OUTPUTS/4); i++) {
rowIsBipol[i] = false;
}
}

~MIDICCToCVInterface() {}
@@ -59,6 +63,15 @@ struct MIDICCToCVInterface : MidiIO, Module {
json_object_set_new(rootJ, ("ccVal" + std::to_string(i)).c_str(), json_integer(cc[i].val));
}
}
// rowIsBipol
json_t *rowIsBipolsJ = json_array();
for (int i = 0; i < (NUM_OUTPUTS/4); i++) {
json_t *rowIsBipolJ = json_boolean(rowIsBipol[i]);
json_array_append_new(rowIsBipolsJ, rowIsBipolJ);
}
json_object_set_new(rootJ, "rowIsBipol", rowIsBipolsJ);

return rootJ;
}

@@ -71,13 +84,22 @@ struct MIDICCToCVInterface : MidiIO, Module {
cc[i].numInited = true;
}

// rowIsBipol (must be done before getting ccVal)
json_t *rowIsBipolsJ = json_object_get(rootJ, "rowIsBipol");
if (rowIsBipolsJ) {
for (int i = 0; i < (NUM_OUTPUTS/4); i++) {
json_t *rowIsBipolJ = json_array_get(rowIsBipolsJ, i);
if (rowIsBipolJ)
rowIsBipol[i] = json_boolean_value(rowIsBipolJ);
}
}

json_t *ccValJ = json_object_get(rootJ, ("ccVal" + std::to_string(i)).c_str());
if (ccValJ) {
cc[i].val = json_integer_value(ccValJ);
cc[i].tSmooth.set((cc[i].val / 127.0 * 10.0), (cc[i].val / 127.0 * 10.0));
cc[i].tSmooth.set((cc[i].val / 127.0 * 10.0)-(rowIsBipol[i/4]?5.0:0.0), (cc[i].val / 127.0 * 10.0)-(rowIsBipol[i/4]?5.0:0.0));
cc[i].resetSync();
}

}
}

@@ -105,7 +127,7 @@ void MIDICCToCVInterface::step() {
lights[i].setBrightness(cc[i].sync / 127.0);

if (cc[i].changed) {
cc[i].tSmooth.set(outputs[i].value, (cc[i].val / 127.0 * 10.0), int(engineGetSampleRate() / 32));
cc[i].tSmooth.set(outputs[i].value, (cc[i].val / 127.0 * 10.0)-(rowIsBipol[i/4]?5.0:0.0), int(engineGetSampleRate() / 32));
cc[i].changed = false;
}

@@ -319,3 +341,36 @@ void MIDICCToCVWidget::step() {

ModuleWidget::step();
}

struct MIDICCToCVRowBipolModeItem : MenuItem {
bool *rowIsBipol;
void onAction(EventAction &e) override {
*rowIsBipol = (*rowIsBipol) ? false : true; // Toggle bi-pol setting
}
void step() override {
rightText = (*rowIsBipol) ? "✔" : "";
}
};

Menu *MIDICCToCVWidget::createContextMenu() {
Menu *menu = ModuleWidget::createContextMenu();

MIDICCToCVInterface *midiCCToCV = dynamic_cast<MIDICCToCVInterface*>(module);
assert(midiCCToCV);

MenuLabel *spacerLabel = new MenuLabel();
menu->pushChild(spacerLabel);
MenuLabel *bipolarLabel = new MenuLabel();
bipolarLabel->text = "Bi-polar CVs";
menu->pushChild(bipolarLabel);

for (int i = 0; i < (MIDICCToCVInterface::NUM_OUTPUTS/4); i++) {
MIDICCToCVRowBipolModeItem *rowIsBipolItem = new MIDICCToCVRowBipolModeItem();
rowIsBipolItem->text = ("Row " + std::to_string(i)).c_str();
rowIsBipolItem->rowIsBipol = &(midiCCToCV->rowIsBipol[i]);
menu->pushChild(rowIsBipolItem);
}

return menu;
}

+ 1
- 0
src/core/core.hpp View File

@@ -20,6 +20,7 @@ struct MidiToCVWidget : ModuleWidget {
struct MIDICCToCVWidget : ModuleWidget {
MIDICCToCVWidget();
void step() override;
Menu *createContextMenu() override;
};

struct MIDIClockToCVWidget : ModuleWidget {


Loading…
Cancel
Save