simple node note setting ui working!

This commit is contained in:
Sebastian
2024-10-20 02:01:30 +02:00
parent 32462a6574
commit 186c15fb54
2 changed files with 43 additions and 12 deletions
+21 -10
View File
@@ -225,7 +225,7 @@ int main(){
for(auto& n : nodes){
if(n.config){
n.config = !GuiWindowBox((Rectangle){n.position.x + 10, n.position.y + 10,240,300}, "config");
n.config = !GuiWindowBox((Rectangle){n.position.x + 10, n.position.y + 10,240,400}, "config");
int option = n.mode;
GuiComboBox((Rectangle){ n.position.x + 20, n.position.y + 40, 220, 20 }, "Round Robin;Random", &option);
n.mode = (Distribution)option;
@@ -244,19 +244,30 @@ int main(){
}
int y_channel = y_midi + 20 + i*20;
GuiLabel((Rectangle){n.position.x + 20, n.position.y + y_channel, 220, 20}, "CHANNEL");
GuiToggleGroup((Rectangle){n.position.x + 20, n.position.y + y_channel + 30, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &n.midi_channel);
if(GuiValueBox((Rectangle){n.position.x + 100, n.position.y + y_channel, 140, 20}, "CHANNEL", &n.midi_channel, 0, 15, n.gui_midi_channel_edit)) n.gui_midi_channel_edit = !n.gui_midi_channel_edit;
if(GuiValueBox((Rectangle){n.position.x + 100, n.position.y + y_channel + 20, 140, 20}, "NOTE", &n.midi_note, 0, 127, n.gui_midi_note_edit)) n.gui_midi_note_edit = !n.gui_midi_note_edit;
if(GuiValueBox((Rectangle){n.position.x + 100, n.position.y + y_channel + 40, 140, 20}, "VELOCITY", &n.midi_velocity, 0, 127, n.gui_midi_velocity_edit)) n.gui_midi_velocity_edit = !n.gui_midi_velocity_edit;
if(GuiValueBox((Rectangle){n.position.x + 100, n.position.y + y_channel + 60, 140, 20}, "GATE", &n.midi_gate, 0, 5000, n.gui_midi_gate_edit)) n.gui_midi_gate_edit = !n.gui_midi_gate_edit;
GuiLabel((Rectangle){n.position.x + 20, n.position.y + y_channel + 90, 100, 20}, "NOTE");
float v = n.midi_note;
GuiLabel((Rectangle){n.position.x + 210, n.position.y + y_channel + 90, 20, 20}, midi.midiNotes[(int)round(v)].c_str());
GuiLabel((Rectangle){n.position.x + 160, n.position.y + y_channel + 90, 40, 20}, std::format("{}",n.midi_note).c_str());
GuiSlider((Rectangle){n.position.x + 20, n.position.y + y_channel + 120, 220, 20}, "", "", &v, 0, 127);
n.midi_note = round(v);
float v = n.midi_channel;
GuiSlider((Rectangle){n.position.x + 100, n.position.y + y_channel + 80, 120, 20}, "CHANNEL", std::format("{}",(int)v).c_str(), &v, 0.0f, 15.0f);
n.midi_channel = (int)round(v);
GuiLabel((Rectangle){n.position.x + 20, n.position.y + y_channel + 150, 100, 20}, "VELOCITY");
v = n.midi_velocity;
GuiLabel((Rectangle){n.position.x + 210, n.position.y + y_channel + 150, 20, 20}, std::format("{}",n.midi_velocity).c_str());
GuiSlider((Rectangle){n.position.x + 20, n.position.y + y_channel + 180, 220, 20}, "", "", &v, 0, 127);
n.midi_velocity = round(v);
GuiToggleGroup((Rectangle){n.position.x + 20, n.position.y + y_channel + 100, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &n.midi_channel);
GuiLabel((Rectangle){n.position.x + 20, n.position.y + y_channel + 210, 100, 20}, "GATE");
v = n.midi_gate;
GuiLabel((Rectangle){n.position.x + 210, n.position.y + y_channel + 210, 20, 20}, std::format("{}",(float)n.midi_gate/1000.0f).c_str());
GuiSlider((Rectangle){n.position.x + 20, n.position.y + y_channel + 240, 220, 20}, "", "", &v, 0, 5000);
n.midi_gate = round(v);
GuiToggleGroup((Rectangle){n.position.x + 20, n.position.y + y_channel + 140, 25, 20}, "C-1;C#-1;D-1;D#-1;E-1;F-1;F#-1;G-1\nG#-1;A-1;A#-1;B-1;C0;C#0;D0;D#0\nE0;F0;F#0;G0;G#0;A0;A#0;B0\nC1;C#1;D1;D#1;E1;F1;F#1;G1\nG#1;A1;A#1;B1;C2;C#2;D2;D#2\nE2;F2;F#2;G2;G#2;A2;A#2;B2\nC3;C#3;D3;D#3;E3;F3;F#3;G3\nG#3;A3;A#3;B3;C4;C#4;D4;D#4\nE4;F4;F#4;G4;G#4;A4;A#4;B4\nC5;C#5;D5;D#5;E5;F5;F#5;G5\nG#5;A5;A#5;B5;C6;C#6;D6;D#6\nE6;F6;F#6;G6;G#6;A6;A#6;B6\nC7;C#7;D7;D#7;E7;F7;F#7;G7\nG#7;A7;A#7;B7;C8;C#8;D8;D#8\nE8;F8;F#8;G8;G#8;A8;A#8;B8\nC9;C#9;D9;D#9;E9;F9;F#9;G9\nG#9;A9;A#9;B9;C10", &n.midi_note);
//if(GuiValueBox((Rectangle){n.position.x + 100, n.position.y + y_channel + 40, 140, 20}, "VELOCITY", &n.midi_velocity, 0, 127, n.gui_midi_velocity_edit)) n.gui_midi_velocity_edit = !n.gui_midi_velocity_edit;
//if(GuiValueBox((Rectangle){n.position.x + 100, n.position.y + y_channel + 60, 140, 20}, "GATE", &n.midi_gate, 0, 5000, n.gui_midi_gate_edit)) n.gui_midi_gate_edit = !n.gui_midi_gate_edit;
}
}
+20
View File
@@ -30,6 +30,26 @@ class Midi {
}
}
std::vector<std::string> midiNotes = {
"C-1", "C#-1", "D-1", "D#-1", "E-1", "F-1", "F#-1", "G-1",
"G#-1", "A-1", "A#-1", "B-1", "C0", "C#0", "D0", "D#0",
"E0", "F0", "F#0", "G0", "G#0", "A0", "A#0", "B0",
"C1", "C#1", "D1", "D#1", "E1", "F1", "F#1", "G1",
"G#1", "A1", "A#1", "B1", "C2", "C#2", "D2", "D#2",
"E2", "F2", "F#2", "G2", "G#2", "A2", "A#2", "B2",
"C3", "C#3", "D3", "D#3", "E3", "F3", "F#3", "G3",
"G#3", "A3", "A#3", "B3", "C4", "C#4", "D4", "D#4",
"E4", "F4", "F#4", "G4", "G#4", "A4", "A#4", "B4",
"C5", "C#5", "D5", "D#5", "E5", "F5", "F#5", "G5",
"G#5", "A5", "A#5", "B5", "C6", "C#6", "D6", "D#6",
"E6", "F6", "F#6", "G6", "G#6", "A6", "A#6", "B6",
"C7", "C#7", "D7", "D#7", "E7", "F7", "F#7", "G7",
"G#7", "A7", "A#7", "B7", "C8", "C#8", "D8", "D#8",
"E8", "F8", "F#8", "G8", "G#8", "A8", "A#8", "B8",
"C9", "C#9", "D9", "D#9", "E9", "F9", "F#9", "G9",
"G#9", "A9", "A#9", "B9", "C10"
};
libremidi::observer obs;
std::map<int, std::shared_ptr<libremidi::midi_out>> midi_outs;