summaryrefslogtreecommitdiff
path: root/src/fruits/cmc/ui/util
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-08-26 17:58:15 -0400
committerAndrew Opalach <andrew@akon.city> 2026-08-26 17:58:15 -0400
commitb112da5b9825262b3b779bd699a4cf4bca8b6d01 (patch)
tree7742d66d3aac6bc007c638377f81da738e9886be /src/fruits/cmc/ui/util
parent197d41a3e23cab35848f623c6133baccc62aacbe (diff)
downloadcamu-b112da5b9825262b3b779bd699a4cf4bca8b6d01.tar.gz
camu-b112da5b9825262b3b779bd699a4cf4bca8b6d01.tar.bz2
camu-b112da5b9825262b3b779bd699a4cf4bca8b6d01.zip
Rough cmc UI tweaking
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fruits/cmc/ui/util')
-rw-r--r--src/fruits/cmc/ui/util/waveform.c34
1 files changed, 26 insertions, 8 deletions
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 <al/log.h>
#include <al/math.h>
+#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 <nnwt/file.h>
#include <nnwt/net.h>
+#include <nnwt/time.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
-#include <stb_image_write.h>
+//#include <stb_image_write.h>
// 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);