|
@@ -76,25 +76,28 @@ struct CcChoice : LedDisplayChoice { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void step() override { |
|
|
void step() override { |
|
|
|
|
|
int cc; |
|
|
if (!module) { |
|
|
if (!module) { |
|
|
text = string::f("%d", id); |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
cc = id; |
|
|
} |
|
|
} |
|
|
if (module->learningId == id) { |
|
|
|
|
|
if (0 <= focusCc) |
|
|
|
|
|
text = string::f("%d", focusCc); |
|
|
|
|
|
else |
|
|
|
|
|
text = "--"; |
|
|
|
|
|
|
|
|
else if (module->learningId == id) { |
|
|
|
|
|
cc = focusCc; |
|
|
color.a = 0.5; |
|
|
color.a = 0.5; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
text = string::f("%d", module->learnedCcs[id]); |
|
|
|
|
|
|
|
|
cc = module->learnedCcs[id]; |
|
|
color.a = 1.0; |
|
|
color.a = 1.0; |
|
|
|
|
|
|
|
|
// HACK |
|
|
|
|
|
if (APP->event->selectedWidget == this) |
|
|
|
|
|
|
|
|
// Cancel focus if no longer learning |
|
|
|
|
|
if (APP->event->getSelectedWidget() == this) |
|
|
APP->event->setSelected(NULL); |
|
|
APP->event->setSelected(NULL); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set text |
|
|
|
|
|
if (cc < 0) |
|
|
|
|
|
text = "--"; |
|
|
|
|
|
else |
|
|
|
|
|
text = string::f("%d", cc); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onSelect(const event::Select& e) override { |
|
|
void onSelect(const event::Select& e) override { |
|
@@ -117,14 +120,14 @@ struct CcChoice : LedDisplayChoice { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onSelectText(const event::SelectText& e) override { |
|
|
void onSelectText(const event::SelectText& e) override { |
|
|
int c = e.codepoint - '0'; |
|
|
|
|
|
if (0 <= c && c <= 9) { |
|
|
|
|
|
|
|
|
int c = e.codepoint; |
|
|
|
|
|
if ('0' <= c && c <= '9') { |
|
|
if (focusCc < 0) |
|
|
if (focusCc < 0) |
|
|
focusCc = 0; |
|
|
focusCc = 0; |
|
|
focusCc = focusCc * 10 + c; |
|
|
|
|
|
|
|
|
focusCc = focusCc * 10 + (c - '0'); |
|
|
} |
|
|
} |
|
|
if (focusCc >= 128) |
|
|
if (focusCc >= 128) |
|
|
focusCc = 0; |
|
|
|
|
|
|
|
|
focusCc = -1; |
|
|
e.consume(this); |
|
|
e.consume(this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -143,6 +146,7 @@ template <class TModule> |
|
|
struct NoteChoice : LedDisplayChoice { |
|
|
struct NoteChoice : LedDisplayChoice { |
|
|
TModule* module; |
|
|
TModule* module; |
|
|
int id; |
|
|
int id; |
|
|
|
|
|
int focusNote; |
|
|
|
|
|
|
|
|
NoteChoice() { |
|
|
NoteChoice() { |
|
|
box.size.y = mm2px(6.666); |
|
|
box.size.y = mm2px(6.666); |
|
@@ -159,34 +163,40 @@ struct NoteChoice : LedDisplayChoice { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void step() override { |
|
|
void step() override { |
|
|
|
|
|
int note; |
|
|
if (!module) { |
|
|
if (!module) { |
|
|
text = "C4"; |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
note = id + 36; |
|
|
} |
|
|
} |
|
|
if (module->learningId == id) { |
|
|
|
|
|
text = "--"; |
|
|
|
|
|
|
|
|
else if (module->learningId == id) { |
|
|
|
|
|
note = focusNote; |
|
|
color.a = 0.5; |
|
|
color.a = 0.5; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
uint8_t note = module->learnedNotes[id]; |
|
|
|
|
|
static const char* noteNames[] = { |
|
|
|
|
|
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" |
|
|
|
|
|
}; |
|
|
|
|
|
int oct = note / 12 - 1; |
|
|
|
|
|
int semi = note % 12; |
|
|
|
|
|
text = string::f("%s%d", noteNames[semi], oct); |
|
|
|
|
|
|
|
|
note = module->learnedNotes[id]; |
|
|
color.a = 1.0; |
|
|
color.a = 1.0; |
|
|
|
|
|
|
|
|
// HACK |
|
|
|
|
|
if (APP->event->selectedWidget == this) |
|
|
|
|
|
|
|
|
// Cancel focus if no longer learning |
|
|
|
|
|
if (APP->event->getSelectedWidget() == this) |
|
|
APP->event->setSelected(NULL); |
|
|
APP->event->setSelected(NULL); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set text |
|
|
|
|
|
if (note < 0) { |
|
|
|
|
|
text = "--"; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
static const char* noteNames[12] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; |
|
|
|
|
|
int oct = note / 12 - 1; |
|
|
|
|
|
int semi = note % 12; |
|
|
|
|
|
text = string::f("%s%d", noteNames[semi], oct); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onSelect(const event::Select& e) override { |
|
|
void onSelect(const event::Select& e) override { |
|
|
if (!module) |
|
|
if (!module) |
|
|
return; |
|
|
return; |
|
|
module->learningId = id; |
|
|
module->learningId = id; |
|
|
|
|
|
focusNote = -1; |
|
|
e.consume(this); |
|
|
e.consume(this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -194,9 +204,43 @@ struct NoteChoice : LedDisplayChoice { |
|
|
if (!module) |
|
|
if (!module) |
|
|
return; |
|
|
return; |
|
|
if (module->learningId == id) { |
|
|
if (module->learningId == id) { |
|
|
|
|
|
if (0 <= focusNote && focusNote < 128) { |
|
|
|
|
|
module->learnedNotes[id] = focusNote; |
|
|
|
|
|
} |
|
|
module->learningId = -1; |
|
|
module->learningId = -1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void onSelectText(const event::SelectText& e) override { |
|
|
|
|
|
int c = e.codepoint; |
|
|
|
|
|
if ('a' <= c && c <= 'g') { |
|
|
|
|
|
static const int majorNotes[7] = {9, 11, 0, 2, 4, 5, 7}; |
|
|
|
|
|
focusNote = majorNotes[c - 'a']; |
|
|
|
|
|
} |
|
|
|
|
|
else if (c == '#') { |
|
|
|
|
|
if (focusNote >= 0) { |
|
|
|
|
|
focusNote += 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if ('0' <= c && c <= '9') { |
|
|
|
|
|
if (focusNote >= 0) { |
|
|
|
|
|
focusNote = focusNote % 12; |
|
|
|
|
|
focusNote += 12 * (c - '0' + 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (focusNote >= 128) |
|
|
|
|
|
focusNote = -1; |
|
|
|
|
|
e.consume(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void onSelectKey(const event::SelectKey& e) override { |
|
|
|
|
|
if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && e.action == GLFW_PRESS && (e.mods & RACK_MOD_MASK) == 0) { |
|
|
|
|
|
event::Deselect eDeselect; |
|
|
|
|
|
onDeselect(eDeselect); |
|
|
|
|
|
APP->event->selectedWidget = NULL; |
|
|
|
|
|
e.consume(this); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|