From 9847614871e861c216425b95a8300dba37b0f6e6 Mon Sep 17 00:00:00 2001 From: grm Date: Sun, 2 Mar 2025 13:53:54 +0200 Subject: Also improve midi and add tt for templating --- src/synth_gui.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'src/synth_gui.c') diff --git a/src/synth_gui.c b/src/synth_gui.c index 43cfda1..d1dc78e 100644 --- a/src/synth_gui.c +++ b/src/synth_gui.c @@ -708,17 +708,21 @@ void get_nth_entry(const char *str, int n, char *result) { } char *soundcards = NULL; +char *midi_devices = NULL; void draw_audiomidisetup(synth_t *synth, const char *midi_devices) { static int edit_midi = 0; static int edit_sound = 0; - static int pick = 0; + static int midi_pick = 0; + static int soundcard_pick = 0; if (synth->gui.audiomidi_initialized == 0) { soundcards = get_soundcards(); - pick = 0; + midi_devices = get_midi_devices(); + soundcard_pick = 0; + midi_pick = 0; synth->gui.audiomidi_initialized = 1; printf("================ AUDIOMIDISETUP GUI INITIALIZED!\n"); } @@ -734,38 +738,38 @@ draw_audiomidisetup(synth_t *synth, const char *midi_devices) if (GuiButton((Rectangle){WIDTH - 100 - 50, 50 + 24 + 6 + 24 + 6 + 24 + 6 + 24 + 6, 100, 24}, "apply")) { - if (pick != 0) { - get_nth_entry(soundcards, pick, synth->soundcard.name); - printf("CHANGING TO %s\n", synth->soundcard.name); + if (soundcard_pick != 0) { + get_nth_entry(soundcards, soundcard_pick, synth->soundcard.name); + printf("[AUDIO] CHANGING TO %s\n", synth->soundcard.name); change_soundcard(synth); } + if (midi_pick != 0) { + get_nth_entry(midi_devices, midi_pick, synth->midi_device.name); + printf("[MIDI] CHANGING TO %s\n", synth->midi_device.name); + change_midi_device(synth); + } synth->gui.screen = SCREEN_MAIN; } - // audio dev + // midi dev if (GuiDropdownBox((Rectangle){WIDTH - 300 - 50, 12 + 24 + 6, 300, 24}, - soundcards, &pick, edit_sound)) { - edit_sound = !edit_sound; + midi_devices, &midi_pick, edit_midi)) { + edit_midi = !edit_midi; } - /* if (old_soundcard_id != synth->soundcard_id) { */ - /* old_soundcard_id = synth->soundcard_id; */ - /* get_nth_entry(soundcards, pick, synth->soundcard_name); */ - /* } */ - // midi dev + // audio dev if (GuiDropdownBox((Rectangle){WIDTH - 300 - 50, - 12, 200, + 12, 300, 24}, - midi_devices, &synth->midi_device_id, edit_midi)) { - edit_midi = !edit_midi; + soundcards, &soundcard_pick, edit_sound)) { + edit_sound = !edit_sound; } /* if (old_midi_device_id != synth->midi_device_id) { */ /* old_midi_device_id = synth->midi_device_id; */ - /* change_midi_device(synth); */ /* } */ @@ -778,6 +782,7 @@ draw_main(synth_t *synth) { if (synth->gui.audiomidi_initialized != 0) { if (soundcards) free(soundcards); + if (midi_devices) free(midi_devices); synth->gui.audiomidi_initialized = 0; } BeginDrawing(); @@ -891,7 +896,6 @@ rayrun(synth_t *synth){ draw_audiomidisetup(synth, midi_devices); //---------------------------------------------------------------------------------- - current_time = Pa_GetStreamTime(synth->stream); //printf("%f :: %ld\n", current_time - prev_time, phase); -- cgit v1.2.3