diff --git a/gui.c b/gui.c index 023714c..ba84fa7 100644 --- a/gui.c +++ b/gui.c @@ -35,13 +35,11 @@ static mu_Context *ctx = NULL; static int running = 1; /* engine state */ -static jack_client_t *client = NULL; +static Engine *g_engine = NULL; static int active = 0; static float bpm = 120.0f; static int loop_length = 8; /* beats */ static int current_beat = 0; -static float *buffer = NULL; -static int buffer_size = 0; /* --------------------------------------------------------------------------- * drawing helpers (stubs for microui) @@ -68,9 +66,9 @@ static void gui_update(void) if (mu_button(ctx, active ? "Stop" : "Play")) { active = !active; if (active) { - engine_start(client); + engine_start(g_engine); } else { - engine_stop(client); + engine_stop(g_engine); } } if (mu_button(ctx, "Reset")) { @@ -84,14 +82,14 @@ static void gui_update(void) mu_layout_row(ctx, 2, (int[]) { 60, -1 }, 0); mu_label(ctx, "BPM:"); if (mu_slider(ctx, &bpm, 20.0f, 300.0f, 0, "%.0f", 0)) { - engine_set_bpm(client, bpm); + engine_set_bpm(g_engine, bpm); } /* loop length */ mu_layout_row(ctx, 2, (int[]) { 60, -1 }, 0); mu_label(ctx, "Length:"); if (mu_slider(ctx, (float*)&loop_length, 1.0f, 64.0f, 0, "%.0f", 0)) { - engine_set_loop_length(client, loop_length); + engine_set_loop_length(g_engine, loop_length); } /* beat indicator */ @@ -124,11 +122,9 @@ static void gui_update(void) /* --------------------------------------------------------------------------- * main loop * ------------------------------------------------------------------------- */ -int gui_main(jack_client_t *jack_client, float *audio_buffer, int buf_size) +int gui_main(Engine *engine) { - client = jack_client; - buffer = audio_buffer; - buffer_size = buf_size; + g_engine = engine; /* initialise microui */ ctx = malloc(sizeof(mu_Context)); @@ -186,7 +182,7 @@ int gui_main(jack_client_t *jack_client, float *audio_buffer, int buf_size) } /* update engine state */ - current_beat = engine_get_current_beat(client); + current_beat = engine_get_current_beat(g_engine); /* render GUI */ gui_update(); diff --git a/gui.h b/gui.h index 8fb4063..3dbce9e 100644 --- a/gui.h +++ b/gui.h @@ -1,8 +1,8 @@ #ifndef GUI_H #define GUI_H -#include +#include "engine.h" -int gui_main(jack_client_t *client, float *audio_buffer, int buf_size); +int gui_main(Engine *engine); #endif /* GUI_H */ diff --git a/test_gui.c b/test_gui.c index bb5f802..86cf2d4 100644 --- a/test_gui.c +++ b/test_gui.c @@ -45,7 +45,7 @@ int main(void) int ret = gui_main(client, buffer, buffer_size); /* cleanup */ - engine_cleanup(client); + engine_cleanup(g_engine); free(buffer); jack_client_close(client);