From b9a7c2f7a9f0fc0075b2edeb054e1e086d4c0e27 Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Wed, 13 May 2026 00:42:05 +0800 Subject: [PATCH] audio: add boost. --- audio.cpp | 46 +++++++++++++++++++++++++++++++++++++++++----- menu.cpp | 6 ++++-- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/audio.cpp b/audio.cpp index 5fbe716..ad70709 100644 --- a/audio.cpp +++ b/audio.cpp @@ -22,6 +22,7 @@ static uint8_t vol_att = 0; static uint8_t corevol_att = 0; unsigned long vol_set_timeout = 0; static int has_filter = 0; +static int has_boost = 0; static char filter_cfg_path[1024] = {}; static char filter_cfg[1024] = {}; @@ -31,6 +32,8 @@ static void setFilter() fileTYPE f = {}; has_filter = spi_uio_cmd(UIO_SET_AFILTER); + has_boost = (has_filter & 2) && !is_menu(); + if (!has_boost) corevol_att &= 7; if (!has_filter) return; snprintf(filter_cfg_path, sizeof(filter_cfg_path), AFILTER_DIR"/%s", filter_cfg + 1); @@ -140,8 +143,11 @@ int get_volume() int get_core_volume() { + int boost = corevol_att & 0x60; + if (boost > 0x40) boost = 0x40; corevol_att &= 7; if (corevol_att > 6) corevol_att = 6; + corevol_att |= boost; return corevol_att; } @@ -182,12 +188,42 @@ void set_core_volume(int cmd) { vol_set_timeout = GetTimer(1000); - corevol_att &= 7; - if (cmd < 0 && corevol_att < 6) corevol_att += 1; - if (cmd > 0 && corevol_att > 0) corevol_att -= 1; + if (has_boost) + { + int boost = corevol_att & 0x60; + corevol_att &= 7; + if (cmd < 0) + { + if (boost) + { + corevol_att = 0; + boost -= 0x20; + } + else if (corevol_att < 6) corevol_att += 1; + } - if (has_filter) setFilter(); - else send_volume(); + if (cmd > 0) + { + if (boost || !corevol_att) + { + boost += 0x20; + if (boost > 0x40) boost = 0x40; + } + else if (corevol_att > 0) corevol_att -= 1; + } + + corevol_att |= boost; + setFilter(); + } + else + { + corevol_att &= 7; + if (cmd < 0 && corevol_att < 6) corevol_att += 1; + if (cmd > 0 && corevol_att > 0) corevol_att -= 1; + + if (has_filter) setFilter(); + else send_volume(); + } } void save_volume() diff --git a/menu.cpp b/menu.cpp index 89a6af7..de14583 100644 --- a/menu.cpp +++ b/menu.cpp @@ -3984,10 +3984,12 @@ void HandleUI(void) { strcpy(s, " Core Volume: "); if (audio_filter_en() >= 0) s[4] = 0x1b; - memset(s + strlen(s), 0, 10); + memset(s + strlen(s), 0, 11); char *bar = s + strlen(s); memset(bar, 0x8C, 8); - memset(bar, 0x7f, 8 - m); + memset(bar, 0x7f, 8 - (m & 7)); + if (m & 0x60) bar[8] = '+'; + if (m & 0x40) bar[9] = '+'; } OsdWrite(12, s, menusub == 1);