From b112da5b9825262b3b779bd699a4cf4bca8b6d01 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 26 Aug 2026 17:58:15 -0400 Subject: Rough cmc UI tweaking Signed-off-by: Andrew Opalach --- src/fruits/cmc/ui/util/waveform.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/fruits/cmc/ui/util') diff --git a/src/fruits/cmc/ui/util/waveform.c b/src/fruits/cmc/ui/util/waveform.c index 624069e..f43890d 100644 --- a/src/fruits/cmc/ui/util/waveform.c +++ b/src/fruits/cmc/ui/util/waveform.c @@ -1,18 +1,21 @@ #include #include +#include "../../util/color_palette.h" + #include "waveform.h" #define WITHIN_RMS(low, high, rms) \ ((low >= 0 && low <= rms) || (high < 0 && high >= -rms) || (low < 0 && high > 0 && rms > 0)) -//#define OUTPUT_WAVEFORM_PNG +#define OUTPUT_WAVEFORM_PNG //#define WAVEFORM_REFERENCE_MODE #ifdef OUTPUT_WAVEFORM_PNG #include #include +#include #define STB_IMAGE_WRITE_IMPLEMENTATION -#include +//#include // min/max: #BC615E, #F4EAE0 // rms: #FF928F, #E4CAAF @@ -21,9 +24,10 @@ // rms: #f44f7a, #c84064 // extra: #f6ac7f, #F5F4FA, #5b524b // left channel: n == 0, right channel: n == 1. -#define COLOR_FOR_PIXEL(n, rms) rms ? \ - n == 0 ? nn_htonl(0xe4caaf99) : nn_htonl(0xff928fff) : \ - n == 0 ? nn_htonl(0xf4eae099) : nn_htonl(0xbc615eff) +static u32 color1, color2, color3, color4; +#define COLOR_FOR_PIXEL(n, rms) ((rms) ? \ + ((n == 0) ? color1 : color3) : \ + ((n == 0) ? color2 : color4)) // ss: current sample, ns: next sample. #define HIT_WAVE(low, high, ss, ns) \ @@ -33,6 +37,11 @@ static void test_write_bitmap(struct cmc_list_entry *entry, u32 width, u32 heigh { f64 start = nn_get_tick(); + color1 = nn_htonl((global_color_palette.colors[CAMU_COLOR5] << 8) | 0xFF); + color2 = nn_htonl((global_color_palette.colors[CAMU_COLOR2] << 8) | 0xFF); + color3 = nn_htonl((global_color_palette.colors[CAMU_COLOR3] << 8) | 0xFF); + color4 = nn_htonl((global_color_palette.colors[CAMU_COLOR1] << 8) | 0xFF); + *rgba = al_calloc(width * height, 4); u32 channels = entry->raw.fmt.channel_count; @@ -72,7 +81,12 @@ static void test_write_bitmap(struct cmc_list_entry *entry, u32 width, u32 heigh for (u32 j = 0; j < height; j++) { low = steps[j + 1], high = steps[j]; if (low < max && high >= min) { - (*rgba)[j * width + i] = COLOR_FOR_PIXEL(n, WITHIN_RMS(low, high, rms)); + bool in_rms = WITHIN_RMS(low, high, rms); + u32 *out = *rgba + (j * width + i); + if (n == 1 && *out == COLOR_FOR_PIXEL(0, true) && !in_rms) { + continue; + } + *out = COLOR_FOR_PIXEL(n, in_rms); } } #else @@ -82,7 +96,12 @@ static void test_write_bitmap(struct cmc_list_entry *entry, u32 width, u32 heigh for (u32 j = 0; j < height; j++) { low = steps[j + 1], high = steps[j]; if (HIT_WAVE(low, high, ss, ns)) { - (*rgba)[j * width + i] = COLOR_FOR_PIXEL(n, WITHIN_RMS(low, high, rms)); + bool in_rms = WITHIN_RMS(low, high, rms); + u32 *out = *rgba + (j * width + i); + if (n == 1 && *out == COLOR_FOR_PIXEL(0, true) && !in_rms) { + continue; + } + *out = COLOR_FOR_PIXEL(n, in_rms); } } } @@ -93,7 +112,6 @@ static void test_write_bitmap(struct cmc_list_entry *entry, u32 width, u32 heigh log_info("generating waveform took: %.2fs.", nn_get_tick() - start); //stbi_write_png("./waveform.png", width, height, 4, *rgba, width * 4); - /* struct nn_file file; nn_file_open(&file, &al_str_c("./raw_samples.raw"), NNWT_FILE_CREATE); -- cgit v1.2.3-101-g0448