From e9ecc6b4df41ced1b9dd39ad638435945d1a6374 Mon Sep 17 00:00:00 2001 From: bonmas14 Date: Sun, 21 Sep 2025 23:12:28 +0300 Subject: v1.2 ui for settings changing --- src/program.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 15 deletions(-) (limited to 'src/program.c') diff --git a/src/program.c b/src/program.c index 89901a9..3da1f14 100644 --- a/src/program.c +++ b/src/program.c @@ -1,10 +1,16 @@ #define LPC_STATIC_DECL #define LPC_ENC_DEC_IMPLEMENTATION #include "lpc10_enc_dec.h" +#include "blissful_orange.h" #define MAX_SAMPLES_UPDATE 512 #define SAMPLE_RATE 8000 +#define PADDING_PX 10 +#define FONT_SIZE 24 + +#define BACKGROUND_COLOR CLITERAL(Color) {0x1c, 0x1c, 0x1c, 0xff} + // AudioStream audio_stream; typedef enum { @@ -24,6 +30,10 @@ Program_State state; void program_init(void) { state.status = STATUS_IDLE; state.settings = LPC_DEFAULT_SETTINGS; + + SetWindowMinSize(WINDOW_WIDTH, WINDOW_HEIGHT); + GuiLoadStyleBlissfulOrange(); + GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); } void program_deinit(void) { @@ -103,30 +113,90 @@ void program_render(void) { Vector2 pos, size; const char *text; u64 i; + Rectangle rect; + s32 x, height, width; - BeginDrawing(); - ClearBackground(CLITERAL(Color) {0x1c, 0x1c, 0x1c, 0xff}); - - text = ">> drag and drop files here <<"; font = GetFontDefault(); - size = MeasureTextEx(font, text, 24, 1); + BeginDrawing(); + ClearBackground(BACKGROUND_COLOR); - pos.x = window_width / 2 - size.x / 2; - pos.y = window_height / 2 - size.y / 2; + switch (state.status) { + case STATUS_IDLE: + { + x = rect.x = window_width / 4; + + width = rect.width = window_width / 2; + height = rect.height = window_height / 15; + rect.height -= PADDING_PX / 2; + rect.y = PADDING_PX / 2; + + rect.width = window_width; + rect.x = 0; + GuiLabel(rect, "Pitch buffer settings"); + rect.x = x; + rect.width = width; + + rect.y += height; + GuiSlider(rect, "Low-cut", TextFormat("%.0f", state.settings.pitch_low_cut), &state.settings.pitch_low_cut, 1.0f, 500.0f); + rect.y += height; + GuiSlider(rect, "High-cut", TextFormat("%.0f", state.settings.pitch_high_cut), &state.settings.pitch_high_cut, 100.0f, 1000.0f); + rect.y += height; + GuiSlider(rect, "Q-Factor", TextFormat("%.2f", state.settings.pitch_q_factor), &state.settings.pitch_q_factor, 0.01f, 8.0f); + + rect.y += height; + rect.width = window_width; + rect.x = 0; + GuiLabel(rect, "Ks processing buffer settings"); + rect.x = x; + rect.width = width; + + rect.y += height; + GuiSlider(rect, "Low-cut", TextFormat("%.0f", state.settings.processing_low_cut), &state.settings.processing_low_cut, 1.0f, 500.0f); + rect.y += height; + GuiSlider(rect, "High-cut", TextFormat("%.0f", state.settings.processing_high_cut), &state.settings.processing_high_cut, 100.0f, 4000.0f); + rect.y += height; + GuiSlider(rect, "Q-Factor", TextFormat("%.2f", state.settings.processing_q_factor), &state.settings.processing_q_factor, 0.01f, 8.0f); + rect.y += height; + + rect.y += height; + GuiSlider(rect, "Unvoiced thresh.", TextFormat("%.2f", state.settings.unvoiced_thresh), &state.settings.unvoiced_thresh, -1.0f, 1.0f); + rect.y += height; + GuiSlider(rect, "Unvoiced RMS mult.", TextFormat("%.2f", state.settings.unvoiced_rms_multiply), &state.settings.unvoiced_rms_multiply, 0.0f, 8.0f); + + rect.y += height; + GuiToggle(rect, "Pre Emphasis", (bool*)&state.settings.do_pre_emphasis); + rect.y += height; + GuiSlider(rect, "Alpha", TextFormat("%.6f", state.settings.pre_emphasis_alpha), &state.settings.pre_emphasis_alpha, -1.0f, 1.0f); + + rect.y += height * 2; + rect.width = window_width; + rect.x = 0; + GuiLabel(rect, "Drag and drop files you need to convert"); + } break; + case STATUS_CONVERTING: + { + text = "---- PROCESSING ----"; + size = MeasureTextEx(font, text, 24, 1); + pos.x = window_width / 2 - size.x / 2; + pos.y = window_height / 2 - size.y / 2; - DrawTextEx(font, text, pos, 24, 1, WHITE); + DrawTextEx(font, text, pos, 24, 1, WHITE); - for (i = 0; i < state.path_list.count; i++) { - text = GetFileNameWithoutExt(state.path_list.paths[i]); + for (i = 0; i < state.path_list.count; i++) { + if (i < state.index) continue; - text = TextFormat("[%s] %s", i < state.index ? "DONE" : "----", text); - size = MeasureTextEx(font, text, 24, 1); + text = GetFileNameWithoutExt(state.path_list.paths[i]); - pos.x = size.y; - pos.y = size.y * (i + 1); + text = TextFormat("%s", text); + size = MeasureTextEx(font, text, 24, 1); - DrawTextEx(font, text, pos, 24, 1, WHITE); + pos.x = size.y; + pos.y = size.y * ((i - state.index) + 1); + + DrawTextEx(font, text, pos, 24, 1, WHITE); + } + } break; } EndDrawing(); -- cgit v1.2.3-70-g09d2