Files
aes67-ESP32-P4/main/project_cfg.c
T
bsncubed 122e46e862 Pink noise as a source (mode "pink")
Core: aes67_tx_pink_noise(), a ready-made TX source: xorshift32 white noise
through Paul Kellet's pink filter, -18 dBFS RMS (peaks about -6 dBFS), same
on L and R. The player uses it like the tone (straight to TX, no volume or
gain). Checked on the board: -18 dBFS RMS, octave bands 63 Hz-4 kHz flat
within +-0.4 dB, L = R.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 23:37:05 +10:00

40 lines
1.7 KiB
C

// Project config: defaults over the core groups and the "source" group.
#include "project_cfg.h"
#include "aes67_cfg.h"
#include "esp_err.h"
#include "player.h"
static const char SOURCE_DEFAULTS[] =
"{\"mode\":\"spotify\",\"spotify_name\":\"P4 AES67\",\"spotify_bitrate\":320,\"hls_url\":\"\","
"\"autoplay\":false,\"gain_db\":0,\"failover_delay_s\":5,\"failover_on_pause\":false,"
"\"spotify_client_id\":\"\",\"spotify_client_secret\":\"\"}";
static bool source_validate(const cJSON *g, char *err, size_t n)
{
static const char *const modes[] = { "spotify", "hls", "auto", "tone", "pink", "off", NULL };
static const double bitrates[] = { 96, 160, 320 };
return cfg_check_enum(g, "mode", modes, err, n) &&
cfg_check_str(g, "spotify_name", 1, 63, err, n) &&
cfg_check_num_in(g, "spotify_bitrate", bitrates, 3, err, n) &&
cfg_check_str(g, "hls_url", 0, 255, err, n) &&
cfg_check_str(g, "spotify_client_id", 0, 64, err, n) &&
cfg_check_str(g, "spotify_client_secret", 0, 64, err, n) &&
cfg_check_num(g, "gain_db", -60, 12, err, n) &&
cfg_check_int(g, "failover_delay_s", 0, 3600, err, n);
}
void project_cfg_defaults(void)
{
// Same as PROJECT.def in web/index.html.
ESP_ERROR_CHECK(cfg_override_defaults("aes67", "{\"name\":\"P4 AES67\"}"));
ESP_ERROR_CHECK(cfg_override_defaults("net", "{\"hostname\":\"p4-aes67\"}"));
}
void project_cfg_register(void)
{
ESP_ERROR_CHECK(cfg_register("source", SOURCE_DEFAULTS, source_validate, player_apply));
// Each user's own Spotify developer app (developer.spotify.com); the secret is write-only.
ESP_ERROR_CHECK(cfg_mark_secret("source", "spotify_client_secret"));
}