store equalizer - release

This commit is contained in:
Philippe G
2021-06-29 12:51:36 -07:00
parent afaa5323d7
commit 192cb975e2
3 changed files with 26 additions and 3 deletions

View File

@@ -8,11 +8,12 @@
*
*/
#include "nvs_utilities.h"
#include "squeezelite.h"
#include "equalizer.h"
#include "esp_equalizer.h"
#define EQ_BANDS 10
#define EQ_BANDS 10
static log_level loglevel = lINFO;
@@ -22,6 +23,20 @@ static struct {
bool update;
} equalizer = { .update = true };
/****************************************************************************************
* initialize equalizer
*/
void equalizer_init(void) {
s8_t *gain = get_nvs_value_alloc(NVS_TYPE_BLOB, "equalizer");
if (!gain) gain = calloc(EQ_BANDS, sizeof(*gain));
equalizer_update(gain);
free(gain);
LOG_INFO("initializing equalizer");
}
/****************************************************************************************
* open equalizer
*/
@@ -68,10 +83,13 @@ void equalizer_close(void) {
* update equalizer gain
*/
void equalizer_update(s8_t *gain) {
store_nvs_value_len(NVS_TYPE_BLOB, "equalizer", gain, EQ_BANDS * sizeof(*gain));
for (int i = 0; i < EQ_BANDS; i++) equalizer.gain[i] = gain[i];
equalizer.update = true;
}
/****************************************************************************************
* process equalizer
*/

View File

@@ -10,6 +10,7 @@
#pragma once
void equalizer_init(void);
void equalizer_open(u32_t sample_rate);
void equalizer_close(void);
void equalizer_update(s8_t *gain);

View File

@@ -73,11 +73,15 @@ void output_init_embedded(log_level level, char *device, unsigned output_buf_siz
slimp_handler_chain = slimp_handler;
slimp_handler = handler;
// init equalizer before backends
equalizer_init();
memset(&output, 0, sizeof(output));
output_init_common(level, device, output_buf_size, rates, idle);
output.start_frames = FRAME_BLOCK;
output.rate_delay = rate_delay;
if (strcasestr(device, "BT ") || !strcasecmp(device, "BT")) {
LOG_INFO("init Bluetooth");
close_cb = &output_close_bt;