Browse Source

Update MIDI interfaces to current API

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
162e1dff35
8 changed files with 72 additions and 72 deletions
  1. +1
    -1
      ext/osdialog
  2. +18
    -18
      src/core/MidiCCToCV.cpp
  3. +8
    -8
      src/core/MidiClockToCV.cpp
  4. +4
    -4
      src/core/MidiIO.cpp
  5. +11
    -11
      src/core/MidiIO.hpp
  6. +5
    -5
      src/core/MidiToCV.cpp
  7. +18
    -18
      src/core/MidiTriggerToCV.cpp
  8. +7
    -7
      src/core/QuadMidiToCV.cpp

+ 1
- 1
ext/osdialog

@@ -1 +1 @@
Subproject commit 015d020615e8169d2f227ad385c5f2aa1e091fd1
Subproject commit 4dd22f56d6b733c8de13d6e8b12f13390aa5782e

+ 18
- 18
src/core/MidiCCToCV.cpp View File

@@ -44,13 +44,13 @@ struct MIDICCToCVInterface : MidiIO, Module {

}

void step();
void step() override;

void processMidi(std::vector<unsigned char> msg);

void resetMidi();
void resetMidi() override;

json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object();
addBaseJson(rootJ);
for (int i = 0; i < NUM_OUTPUTS; i++) {
@@ -62,7 +62,7 @@ struct MIDICCToCVInterface : MidiIO, Module {
return rootJ;
}

void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
baseFromJson(rootJ);
for (int i = 0; i < NUM_OUTPUTS; i++) {
json_t *ccNumJ = json_object_get(rootJ, ("ccNum" + std::to_string(i)).c_str());
@@ -79,7 +79,7 @@ struct MIDICCToCVInterface : MidiIO, Module {
}
}

void reset() {
void reset() override {
resetMidi();
}

@@ -155,15 +155,15 @@ void MIDICCToCVInterface::processMidi(std::vector<unsigned char> msg) {
}

struct CCTextField : TextField {
void onTextChange();
void onTextChange() override;

void draw(NVGcontext *vg);
void draw(NVGcontext *vg) override;

void onMouseDownOpaque(int button);
void onMouseDown(EventMouseDown &e) override;

void onMouseUpOpaque(int button);
void onMouseUp(EventMouseUp &e) override;

void onMouseLeave();
void onMouseLeave(EventMouseLeave &e) override;

int num;

@@ -185,20 +185,20 @@ void CCTextField::draw(NVGcontext *vg) {
TextField::draw(vg);
}

void CCTextField::onMouseUpOpaque(int button) {
if (button == 1) {
module->onFocus[num] = false;
void CCTextField::onMouseDown(EventMouseDown &e) {
if (e.button == 1) {
module->onFocus[num] = true;
}

}

void CCTextField::onMouseDownOpaque(int button) {
if (button == 1) {
module->onFocus[num] = true;
void CCTextField::onMouseUp(EventMouseUp &e) {
if (e.button == 1) {
module->onFocus[num] = false;
}

}

void CCTextField::onMouseLeave() {
void CCTextField::onMouseLeave(EventMouseLeave &e) {
module->onFocus[num] = false;
}



+ 8
- 8
src/core/MidiClockToCV.cpp View File

@@ -41,15 +41,15 @@ struct MIDIClockToCVInterface : MidiIO, Module {
~MIDIClockToCVInterface() {
}

void step();
void step() override;

void processMidi(std::vector<unsigned char> msg);

void onDeviceChange();
void onDeviceChange() override;

void resetMidi();
void resetMidi() override;

json_t *toJson() {
json_t *toJson() override{
json_t *rootJ = json_object();
addBaseJson(rootJ);
json_object_set_new(rootJ, "clock1ratio", json_integer(clock1ratio));
@@ -57,7 +57,7 @@ struct MIDIClockToCVInterface : MidiIO, Module {
return rootJ;
}

void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override{
baseFromJson(rootJ);
json_t *c1rJ = json_object_get(rootJ, "clock1ratio");
if (c1rJ) {
@@ -183,7 +183,7 @@ struct ClockRatioItem : MenuItem {
int ratio;
int *clockRatio;

void onAction() {
void onAction(EventAction &e) override {
*clockRatio = ratio;
}
};
@@ -199,7 +199,7 @@ struct ClockRatioChoice : ChoiceButton {
const std::vector<std::string> ratioNames_short = {"1:4 ratio", "1:3 ratio", "1:2 ratio", "2:3 ratio", "1:1 ratio",
"4:3", "2:1 ratio", "4:1 ratio", "8:1 ratio"};

void onAction() {
void onAction(EventAction &e) override {
Menu *menu = gScene->createMenu();
menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round();
menu->box.size.x = box.size.x;
@@ -213,7 +213,7 @@ struct ClockRatioChoice : ChoiceButton {
}
}

void step() {
void step() override {
text = ratioNames_short[*clockRatio];
}
};


+ 4
- 4
src/core/MidiIO.cpp View File

@@ -175,12 +175,12 @@ void MidiIO::close() {
}


void MidiItem::onAction() {
void MidiItem::onAction(EventAction &e) {
midiModule->resetMidi(); // reset Midi values
midiModule->openDevice(text);
}

void MidiChoice::onAction() {
void MidiChoice::onAction(EventAction &e) {
Menu *menu = gScene->createMenu();
menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round();
menu->box.size.x = box.size.x;
@@ -210,12 +210,12 @@ void MidiChoice::step() {
text = ellipsize(name, 15);
}

void ChannelItem::onAction() {
void ChannelItem::onAction(EventAction &e) {
midiModule->resetMidi(); // reset Midi values
midiModule->setChannel(channel);
}

void ChannelChoice::onAction() {
void ChannelChoice::onAction(EventAction &e) {
Menu *menu = gScene->createMenu();
menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round();
menu->box.size.x = box.size.x;


+ 11
- 11
src/core/MidiIO.hpp View File

@@ -101,59 +101,59 @@ public:
struct MidiItem : MenuItem {
MidiIO *midiModule;

void onAction();
void onAction(EventAction &e) override;
};

struct MidiChoice : ChoiceButton {
MidiIO *midiModule;

void onAction();
void onAction(EventAction &e) override;

void step();
void step() override;
};

struct ChannelItem : MenuItem {
MidiIO *midiModule;
int channel;

void onAction();
void onAction(EventAction &e) override;
};

struct ChannelChoice : ChoiceButton {
MidiIO *midiModule;

void onAction();
void onAction(EventAction &e) override;

void step();
void step() override;
};


struct MidiToCVWidget : ModuleWidget {
MidiToCVWidget();

void step();
void step() override;
};

struct MIDICCToCVWidget : ModuleWidget {
MIDICCToCVWidget();

void step();
void step() override;
};

struct MIDIClockToCVWidget : ModuleWidget {
MIDIClockToCVWidget();

void step();
void step() override;
};

struct MIDITriggerToCVWidget : ModuleWidget {
MIDITriggerToCVWidget();

void step();
void step() override;
};

struct QuadMidiToCVWidget : ModuleWidget {
QuadMidiToCVWidget();

void step();
void step() override;
};

+ 5
- 5
src/core/MidiToCV.cpp View File

@@ -50,7 +50,7 @@ struct MIDIToCVInterface : MidiIO, Module {
~MIDIToCVInterface() {
};

void step();
void step() override;

void pressNote(int note);

@@ -58,21 +58,21 @@ struct MIDIToCVInterface : MidiIO, Module {

void processMidi(std::vector<unsigned char> msg);

json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object();
addBaseJson(rootJ);
return rootJ;
}

void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
baseFromJson(rootJ);
}

void reset() {
void reset() override {
resetMidi();
}

void resetMidi();
void resetMidi() override;

};



+ 18
- 18
src/core/MidiTriggerToCV.cpp View File

@@ -38,13 +38,13 @@ struct MIDITriggerToCVInterface : MidiIO, Module {
~MIDITriggerToCVInterface() {
}

void step();
void step() override;

void processMidi(std::vector<unsigned char> msg);

void resetMidi();
void resetMidi() override;

virtual json_t *toJson() {
virtual json_t *toJson() override {
json_t *rootJ = json_object();
addBaseJson(rootJ);
for (int i = 0; i < NUM_OUTPUTS; i++) {
@@ -53,7 +53,7 @@ struct MIDITriggerToCVInterface : MidiIO, Module {
return rootJ;
}

void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
baseFromJson(rootJ);
for (int i = 0; i < NUM_OUTPUTS; i++) {
json_t *ccNumJ = json_object_get(rootJ, std::to_string(i).c_str());
@@ -65,7 +65,7 @@ struct MIDITriggerToCVInterface : MidiIO, Module {
}
}

void reset() final {
void reset() override {
resetMidi();
}

@@ -136,15 +136,15 @@ void MIDITriggerToCVInterface::processMidi(std::vector<unsigned char> msg) {
}

struct TriggerTextField : TextField {
void onTextChange();
void onTextChange() override;

void draw(NVGcontext *vg);
void draw(NVGcontext *vg) override;

void onMouseDownOpaque(int button);
void onMouseDown(EventMouseDown &e) override;

void onMouseUpOpaque(int button);
void onMouseUp(EventMouseUp &e) override;

void onMouseLeave();
void onMouseLeave(EventMouseLeave &e) override;


int *triggerNum;
@@ -185,20 +185,20 @@ void TriggerTextField::onTextChange() {
};
}

void TriggerTextField::onMouseUpOpaque(int button) {
if (button == 1) {
*onFocus = false;
void TriggerTextField::onMouseDown(EventMouseDown &e) {
if (e.button == 1) {
*onFocus = true;
}

}

void TriggerTextField::onMouseDownOpaque(int button) {
if (button == 1) {
*onFocus = true;
void TriggerTextField::onMouseUp(EventMouseUp &e) {
if (e.button == 1) {
*onFocus = false;
}

}

void TriggerTextField::onMouseLeave() {
void TriggerTextField::onMouseLeave(EventMouseLeave &e) {
*onFocus = false;
}



+ 7
- 7
src/core/QuadMidiToCV.cpp View File

@@ -59,25 +59,25 @@ struct QuadMIDIToCVInterface : MidiIO, Module {
~QuadMIDIToCVInterface() {
};

void step();
void step() override;

void processMidi(std::vector<unsigned char> msg);

json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object();
addBaseJson(rootJ);
return rootJ;
}

void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
baseFromJson(rootJ);
}

void reset() {
void reset() override {
resetMidi();
}

void resetMidi();
void resetMidi() override;

};

@@ -246,7 +246,7 @@ struct ModeItem : MenuItem {
int mode;
QuadMIDIToCVInterface *module;

void onAction() {
void onAction(EventAction &e) {
module->setMode(mode);
}
};
@@ -256,7 +256,7 @@ struct ModeChoice : ChoiceButton {
const std::vector<std::string> modeNames = {"ROTATE", "RESET", "REASSIGN"};


void onAction() {
void onAction(EventAction &e) {
Menu *menu = gScene->createMenu();
menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round();
menu->box.size.x = box.size.x;


Loading…
Cancel
Save