Begin midi engine

This commit is contained in:
2026-02-25 12:16:31 -05:00
parent 789e2b678b
commit 6656b6d0b2
7 changed files with 118 additions and 18 deletions

View File

@@ -3,6 +3,7 @@
// [h]
#include "platform/platform.h"
#include "renderer/renderer.h"
#include "midi/midi.h"
#include "imgui.h"
#include "imgui_internal.h"
#include <iostream>
@@ -10,6 +11,7 @@
// [cpp]
#include "platform/platform_win32.cpp"
#include "renderer/renderer_dx12.cpp"
#include "midi/midi_win32.cpp"
#include "menus.cpp"
#include "theme.cpp"
@@ -26,8 +28,9 @@ static void build_default_layout(ImGuiID dockspace_id) {
ImGui::DockBuilderDockWindow("Browser", left);
ImGui::DockBuilderDockWindow("Main", center);
ImGui::DockBuilderDockWindow("Properties", right);
ImGui::DockBuilderDockWindow("Log", bottom);
ImGui::DockBuilderDockWindow("Properties", right);
ImGui::DockBuilderDockWindow("MIDI Devices", right);
ImGui::DockBuilderDockWindow("Log", bottom);
ImGui::DockBuilderFinish(dockspace_id);
}
@@ -57,15 +60,18 @@ int main(int argc, char **argv) {
return 1;
}
MidiEngine *midi = midi_create();
setup_theme();
setup_menus(window);
int32_t last_w = w, last_h = h;
bool show_demo = true;
bool show_browser = true;
bool show_props = true;
bool show_log = true;
bool first_frame = true;
bool show_demo = true;
bool show_browser = true;
bool show_props = true;
bool show_log = true;
bool show_midi_devices = true;
bool first_frame = true;
while (platform_poll_events(window)) {
int32_t menu_cmd = platform_poll_menu_command(window);
@@ -74,7 +80,8 @@ int main(int argc, char **argv) {
case MENU_VIEW_BROWSER: show_browser = !show_browser; break;
case MENU_VIEW_PROPERTIES:show_props = !show_props; break;
case MENU_VIEW_LOG: show_log = !show_log; break;
case MENU_VIEW_DEMO: show_demo = !show_demo; break;
case MENU_VIEW_DEMO: show_demo = !show_demo; break;
case MENU_VIEW_MIDI_DEVICES: show_midi_devices = !show_midi_devices; break;
default: break;
}
platform_get_size(window, &w, &h);
@@ -117,6 +124,21 @@ int main(int argc, char **argv) {
ImGui::End();
}
// MIDI Devices panel
if (show_midi_devices) {
ImGui::Begin("MIDI Devices", &show_midi_devices);
if (ImGui::Button("Refresh"))
midi_refresh_devices(midi);
ImGui::Separator();
for (int32_t i = 0; i < midi_get_device_count(midi); i++) {
MidiDeviceInfo *dev = midi_get_device(midi, i);
ImGui::Text("[%s] %s", dev->is_input ? "IN" : "OUT", dev->name);
}
if (midi_get_device_count(midi) == 0)
ImGui::TextDisabled("No MIDI devices found");
ImGui::End();
}
// Bottom panel
if (show_log) {
ImGui::Begin("Log", &show_log);
@@ -132,6 +154,7 @@ int main(int argc, char **argv) {
renderer_end_frame(renderer);
}
midi_destroy(midi);
renderer_destroy(renderer);
platform_destroy_window(window);
return 0;