@@ -143,6 +143,22 @@ struct CV_Gate : Module { | |||||
}; | }; | ||||
struct CV_GateVelocityItem : MenuItem { | |||||
CV_Gate *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->velocityMode ^= true; | |||||
} | |||||
}; | |||||
struct CV_GatePanicItem : MenuItem { | |||||
CV_Gate *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->midiOutput.panic(); | |||||
} | |||||
}; | |||||
struct CV_GateWidget : ModuleWidget { | struct CV_GateWidget : ModuleWidget { | ||||
CV_GateWidget(CV_Gate *module) { | CV_GateWidget(CV_Gate *module) { | ||||
setModule(module); | setModule(module); | ||||
@@ -182,17 +198,15 @@ struct CV_GateWidget : ModuleWidget { | |||||
void appendContextMenu(Menu *menu) override { | void appendContextMenu(Menu *menu) override { | ||||
CV_Gate *module = dynamic_cast<CV_Gate*>(this->module); | CV_Gate *module = dynamic_cast<CV_Gate*>(this->module); | ||||
struct VelocityItem : MenuItem { | |||||
CV_Gate *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->velocityMode ^= true; | |||||
} | |||||
}; | |||||
menu->addChild(new MenuEntry); | menu->addChild(new MenuEntry); | ||||
VelocityItem *velocityItem = createMenuItem<VelocityItem>("Velocity mode", CHECKMARK(module->velocityMode)); | |||||
CV_GateVelocityItem *velocityItem = createMenuItem<CV_GateVelocityItem>("Velocity mode", CHECKMARK(module->velocityMode)); | |||||
velocityItem->module = module; | velocityItem->module = module; | ||||
menu->addChild(velocityItem); | menu->addChild(velocityItem); | ||||
CV_GatePanicItem *panicItem = new CV_GatePanicItem; | |||||
panicItem->text = "Panic"; | |||||
panicItem->module = module; | |||||
menu->addChild(panicItem); | |||||
} | } | ||||
}; | }; | ||||
@@ -313,6 +313,14 @@ struct CV_MIDI : Module { | |||||
}; | }; | ||||
struct CV_MIDIPanicItem : MenuItem { | |||||
CV_MIDI *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->midiOutput.panic(); | |||||
} | |||||
}; | |||||
struct CV_MIDIWidget : ModuleWidget { | struct CV_MIDIWidget : ModuleWidget { | ||||
CV_MIDIWidget(CV_MIDI *module) { | CV_MIDIWidget(CV_MIDI *module) { | ||||
setModule(module); | setModule(module); | ||||
@@ -342,6 +350,17 @@ struct CV_MIDIWidget : ModuleWidget { | |||||
midiWidget->midiIO = &module->midiOutput; | midiWidget->midiIO = &module->midiOutput; | ||||
addChild(midiWidget); | addChild(midiWidget); | ||||
} | } | ||||
void appendContextMenu(Menu *menu) override { | |||||
CV_MIDI *module = dynamic_cast<CV_MIDI*>(this->module); | |||||
menu->addChild(new MenuEntry); | |||||
CV_MIDIPanicItem *panicItem = new CV_MIDIPanicItem; | |||||
panicItem->text = "Panic"; | |||||
panicItem->module = module; | |||||
menu->addChild(panicItem); | |||||
} | |||||
}; | }; | ||||
@@ -507,7 +507,7 @@ struct PolyModeItem : MenuItem { | |||||
}; | }; | ||||
struct PanicItem : MenuItem { | |||||
struct MIDI_CVPanicItem : MenuItem { | |||||
MIDI_CV *module; | MIDI_CV *module; | ||||
void onAction(const event::Action &e) override { | void onAction(const event::Action &e) override { | ||||
module->panic(); | module->panic(); | ||||
@@ -566,7 +566,7 @@ struct MIDI_CVWidget : ModuleWidget { | |||||
polyModeItem->module = module; | polyModeItem->module = module; | ||||
menu->addChild(polyModeItem); | menu->addChild(polyModeItem); | ||||
PanicItem *panicItem = new PanicItem; | |||||
MIDI_CVPanicItem *panicItem = new MIDI_CVPanicItem; | |||||
panicItem->text = "Panic"; | panicItem->text = "Panic"; | ||||
panicItem->module = module; | panicItem->module = module; | ||||
menu->addChild(panicItem); | menu->addChild(panicItem); | ||||
@@ -32,14 +32,20 @@ struct MIDI_Gate : Module { | |||||
void onReset() override { | void onReset() override { | ||||
for (int i = 0; i < 16; i++) { | for (int i = 0; i < 16; i++) { | ||||
gates[i] = false; | |||||
gateTimes[i] = 0.f; | |||||
learnedNotes[i] = i + 36; | learnedNotes[i] = i + 36; | ||||
} | } | ||||
learningId = -1; | learningId = -1; | ||||
panic(); | |||||
midiInput.reset(); | midiInput.reset(); | ||||
} | } | ||||
void panic() { | |||||
for (int i = 0; i < 16; i++) { | |||||
gates[i] = false; | |||||
gateTimes[i] = 0.f; | |||||
} | |||||
} | |||||
void pressNote(uint8_t note, uint8_t vel) { | void pressNote(uint8_t note, uint8_t vel) { | ||||
// Learn | // Learn | ||||
if (learningId >= 0) { | if (learningId >= 0) { | ||||
@@ -144,6 +150,22 @@ struct MIDI_Gate : Module { | |||||
}; | }; | ||||
struct MIDI_GateVelocityItem : MenuItem { | |||||
MIDI_Gate *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->velocityMode ^= true; | |||||
} | |||||
}; | |||||
struct MIDI_GatePanicItem : MenuItem { | |||||
MIDI_Gate *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->panic(); | |||||
} | |||||
}; | |||||
struct MIDI_GateWidget : ModuleWidget { | struct MIDI_GateWidget : ModuleWidget { | ||||
MIDI_GateWidget(MIDI_Gate *module) { | MIDI_GateWidget(MIDI_Gate *module) { | ||||
setModule(module); | setModule(module); | ||||
@@ -183,17 +205,15 @@ struct MIDI_GateWidget : ModuleWidget { | |||||
void appendContextMenu(Menu *menu) override { | void appendContextMenu(Menu *menu) override { | ||||
MIDI_Gate *module = dynamic_cast<MIDI_Gate*>(this->module); | MIDI_Gate *module = dynamic_cast<MIDI_Gate*>(this->module); | ||||
struct VelocityItem : MenuItem { | |||||
MIDI_Gate *module; | |||||
void onAction(const event::Action &e) override { | |||||
module->velocityMode ^= true; | |||||
} | |||||
}; | |||||
menu->addChild(new MenuEntry); | menu->addChild(new MenuEntry); | ||||
VelocityItem *velocityItem = createMenuItem<VelocityItem>("Velocity mode", CHECKMARK(module->velocityMode)); | |||||
MIDI_GateVelocityItem *velocityItem = createMenuItem<MIDI_GateVelocityItem>("Velocity mode", CHECKMARK(module->velocityMode)); | |||||
velocityItem->module = module; | velocityItem->module = module; | ||||
menu->addChild(velocityItem); | menu->addChild(velocityItem); | ||||
MIDI_GatePanicItem *panicItem = new MIDI_GatePanicItem; | |||||
panicItem->text = "Panic"; | |||||
panicItem->module = module; | |||||
menu->addChild(panicItem); | |||||
} | } | ||||
}; | }; | ||||