aboutsummaryrefslogtreecommitdiff
path: root/src/program.c
diff options
context:
space:
mode:
authorbonmas14 <bonmas14@gmail.com>2025-09-21 23:12:28 +0300
committerbonmas14 <bonmas14@gmail.com>2025-09-21 23:12:28 +0300
commite9ecc6b4df41ced1b9dd39ad638435945d1a6374 (patch)
tree10b96db62df38aa269d1cc47d7f5be2d1d4513da /src/program.c
parentb30d161ea14254173912fbb2afd296168f2561d8 (diff)
downloadc_wizard-e9ecc6b4df41ced1b9dd39ad638435945d1a6374.tar.gz
c_wizard-e9ecc6b4df41ced1b9dd39ad638435945d1a6374.zip
v1.2 ui for settings changingHEADmain
Diffstat (limited to 'src/program.c')
-rw-r--r--src/program.c98
1 files changed, 84 insertions, 14 deletions
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;
+
+ font = GetFontDefault();
BeginDrawing();
- ClearBackground(CLITERAL(Color) {0x1c, 0x1c, 0x1c, 0xff});
+ ClearBackground(BACKGROUND_COLOR);
- text = ">> drag and drop files here <<";
- font = GetFontDefault();
+ switch (state.status) {
+ case STATUS_IDLE:
+ {
+ x = rect.x = window_width / 4;
- size = MeasureTextEx(font, text, 24, 1);
+ width = rect.width = window_width / 2;
+ height = rect.height = window_height / 15;
+ rect.height -= PADDING_PX / 2;
+ rect.y = PADDING_PX / 2;
- pos.x = window_width / 2 - size.x / 2;
- pos.y = window_height / 2 - size.y / 2;
+ rect.width = window_width;
+ rect.x = 0;
+ GuiLabel(rect, "Pitch buffer settings");
+ rect.x = x;
+ rect.width = width;
- DrawTextEx(font, text, pos, 24, 1, WHITE);
+ 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);
- for (i = 0; i < state.path_list.count; i++) {
- text = GetFileNameWithoutExt(state.path_list.paths[i]);
+ rect.y += height;
+ rect.width = window_width;
+ rect.x = 0;
+ GuiLabel(rect, "Ks processing buffer settings");
+ rect.x = x;
+ rect.width = width;
- text = TextFormat("[%s] %s", i < state.index ? "DONE" : "----", text);
- size = MeasureTextEx(font, text, 24, 1);
+ 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;
- pos.x = size.y;
- pos.y = size.y * (i + 1);
+ 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);
- DrawTextEx(font, text, pos, 24, 1, WHITE);
+ 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);
+
+ for (i = 0; i < state.path_list.count; i++) {
+ if (i < state.index) continue;
+
+ text = GetFileNameWithoutExt(state.path_list.paths[i]);
+
+ text = TextFormat("%s", text);
+ size = MeasureTextEx(font, text, 24, 1);
+
+ pos.x = size.y;
+ pos.y = size.y * ((i - state.index) + 1);
+
+ DrawTextEx(font, text, pos, 24, 1, WHITE);
+ }
+ } break;
}
EndDrawing();