mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 03:57:07 +03:00
store equalizer - release
This commit is contained in:
@@ -7,13 +7,14 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "nvs_utilities.h"
|
||||||
#include "squeezelite.h"
|
#include "squeezelite.h"
|
||||||
#include "equalizer.h"
|
#include "equalizer.h"
|
||||||
#include "esp_equalizer.h"
|
#include "esp_equalizer.h"
|
||||||
|
|
||||||
#define EQ_BANDS 10
|
|
||||||
|
|
||||||
|
#define EQ_BANDS 10
|
||||||
|
|
||||||
static log_level loglevel = lINFO;
|
static log_level loglevel = lINFO;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@@ -21,6 +22,20 @@ static struct {
|
|||||||
float gain[EQ_BANDS];
|
float gain[EQ_BANDS];
|
||||||
bool update;
|
bool update;
|
||||||
} equalizer = { .update = true };
|
} 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
|
* open equalizer
|
||||||
@@ -68,10 +83,13 @@ void equalizer_close(void) {
|
|||||||
* update equalizer gain
|
* update equalizer gain
|
||||||
*/
|
*/
|
||||||
void equalizer_update(s8_t *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];
|
for (int i = 0; i < EQ_BANDS; i++) equalizer.gain[i] = gain[i];
|
||||||
equalizer.update = true;
|
equalizer.update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* process equalizer
|
* process equalizer
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
void equalizer_init(void);
|
||||||
void equalizer_open(u32_t sample_rate);
|
void equalizer_open(u32_t sample_rate);
|
||||||
void equalizer_close(void);
|
void equalizer_close(void);
|
||||||
void equalizer_update(s8_t *gain);
|
void equalizer_update(s8_t *gain);
|
||||||
|
|||||||
@@ -73,11 +73,15 @@ void output_init_embedded(log_level level, char *device, unsigned output_buf_siz
|
|||||||
slimp_handler_chain = slimp_handler;
|
slimp_handler_chain = slimp_handler;
|
||||||
slimp_handler = handler;
|
slimp_handler = handler;
|
||||||
|
|
||||||
|
// init equalizer before backends
|
||||||
|
equalizer_init();
|
||||||
|
|
||||||
memset(&output, 0, sizeof(output));
|
memset(&output, 0, sizeof(output));
|
||||||
output_init_common(level, device, output_buf_size, rates, idle);
|
output_init_common(level, device, output_buf_size, rates, idle);
|
||||||
output.start_frames = FRAME_BLOCK;
|
output.start_frames = FRAME_BLOCK;
|
||||||
output.rate_delay = rate_delay;
|
output.rate_delay = rate_delay;
|
||||||
|
|
||||||
|
|
||||||
if (strcasestr(device, "BT ") || !strcasecmp(device, "BT")) {
|
if (strcasestr(device, "BT ") || !strcasecmp(device, "BT")) {
|
||||||
LOG_INFO("init Bluetooth");
|
LOG_INFO("init Bluetooth");
|
||||||
close_cb = &output_close_bt;
|
close_cb = &output_close_bt;
|
||||||
|
|||||||
Reference in New Issue
Block a user