in between working states, switchting to multi midi out per node

This commit is contained in:
Sebastian
2024-10-19 17:41:31 +02:00
parent 0d942b6677
commit ee8d50fc0a
7 changed files with 104 additions and 43 deletions
+30 -13
View File
@@ -53,6 +53,7 @@ enum States {IDLE, CONFIG};
struct AppState{
int width;
int height;
int gui_selected_midi_out;
States state;
} app;
@@ -195,36 +196,52 @@ int main(){
midi.note(s.next->midi_out, 1, 50, 50, 500);
s.last = s.next;
s.next = n;
//std::cout << s.last << " " << s.next << std::endl;
//midi_out.send_message(libremidi::channel_events::control_change(2, 10, 50));
}
}
s.draw(&mouse_pos);
}
midi.update();
EndMode2D();
GuiWindowBox((Rectangle){0,0,280,600}, "config");
if(GuiButton((Rectangle){20, 60, 240, 20}, "button")){
signals.emplace_back(Signal(nodes.front().position.x + 1, nodes.front().position.y + 1, 5.0f, 2.0f)); // position + 1 or else it does not render. why? no idea!
signals.back().next = &nodes[0];
signals.back().last = &nodes[0];
// Main Config Window
GuiWindowBox((Rectangle){0,0,280,(float)app.height}, "config");
{
GuiLabel((Rectangle){20, 60, 240, 20}, "MIDI OUT");
int i = 0;
for(auto& mo : midi.midi_out_ports){
GuiCheckBox((Rectangle){20, 80 + i*20.0f, 20, 20}, mo.port.port_name.c_str(), &mo.enabled);
i++;
}
if(GuiButton((Rectangle){20, 100 + (float)midi.midi_out_ports.size()*20, 240, 20}, "OPEN PORT")) midi.open_midi_out(app.gui_selected_midi_out);
if(GuiButton((Rectangle){20, 60, 240, 20}, "ADD SIGNAL")){
signals.emplace_back(Signal(nodes.front().position.x + 1, nodes.front().position.y + 1, 5.0f, 2.0f)); // position + 1 or else it does not render. why? no idea!
signals.back().next = &nodes[0];
signals.back().last = &nodes[0];
}
}
for(auto& n : nodes){
if(n.config){
n.config = !GuiWindowBox((Rectangle){n.position.x + 10, n.position.y + 10,240,300}, "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;
std::string toggle_out_ports = "";
int i = 0;
for(auto& mo : midi.midi_out_ports){
toggle_out_ports += mo.port_name + "\n";
GuiCheckBox((Rectangle){20, 80 + i*20.0f, 20, 20}, mo.port.port_name.c_str(), &mo.enabled);
i++;
}
std::string toggle_out_ports = "";
for(auto& mo : midi.midi_outs){
toggle_out_ports += midi.midi_out_ports[mo.first].port.port_name + "\n";
}
toggle_out_ports = toggle_out_ports.substr(0, toggle_out_ports.size()-2);
GuiLabel((Rectangle){n.position.x + 20, n.position.y + 60, 220, 20}, "MIDI OUT");
GuiToggleGroup((Rectangle){n.position.x + 20, n.position.y + 80, 220, 20}, toggle_out_ports.c_str(), &n.midi_out);
if(GuiButton((Rectangle){n.position.x + 20, n.position.y + 100 + midi.midi_out_ports.size()*20, 220, 20}, "OPEN PORT")) midi.open_midi_out(n.midi_out);
}
}