From e21e2cf7f9c79e1942431c47fdb8286533043321 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 4 Sep 2024 15:07:42 -0500 Subject: [PATCH] Equalizer: change gain to int8 and memcmp-based update check --- components/squeezelite/equalizer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/squeezelite/equalizer.c b/components/squeezelite/equalizer.c index d2d717bd3..fb8a90237 100644 --- a/components/squeezelite/equalizer.c +++ b/components/squeezelite/equalizer.c @@ -22,7 +22,8 @@ static EXT_RAM_ATTR struct { void *handle; float loudness, volume; uint32_t samplerate; - float gain[EQ_BANDS], loudness_gain[EQ_BANDS]; + int8_t gain[EQ_BANDS]; + float loudness_gain[EQ_BANDS]; bool update; } equalizer; @@ -151,6 +152,8 @@ void equalizer_set_gain(int8_t *gain) { char config[EQ_BANDS * 4 + 1] = { }; int n = 0; + if (memcmp(equalizer.gain, gain, EQ_BANDS) != 0) equalizer.update = true; + for (int i = 0; i < EQ_BANDS; i++) { equalizer.gain[i] = gain[i]; n += sprintf(config + n, "%d,", gain[i]); @@ -159,8 +162,6 @@ void equalizer_set_gain(int8_t *gain) { config[n-1] = '\0'; config_set_value(NVS_TYPE_STR, "equalizer", config); - equalizer.update = true; - LOG_INFO("equalizer gain %s", config); #else LOG_INFO("no equalizer with 32 bits samples");