Files
lisael-box/main/audio/sd_player.h
T
Clément Saillant e35058f53d chore(box): commit firmware base + feature docs
Backfills the working firmware that had stayed uncommitted across the
build sessions, so the branch is self-contained.

- audio: audio_player, radio_pipeline, sd_player, calm_tone, aac_player
- net: podcast (RSS), udp_log
- modes: balloons, plus calm/games/radio tweaks
- ui: fonts header, icons; build files (CMakeLists, idf_component.yml,
  sdkconfig.defaults)
- docs/superpowers: Histoires design + plan

Note: sdkconfig stays gitignored (Wi-Fi creds + tuned LFN/FS/mbedtls
settings); a fresh checkout must reconfigure those.
2026-06-15 00:20:47 +02:00

53 lines
1.8 KiB
C

// microSD sound-clip player (ESP-ADF fatfs pipeline) for Lisael Box.
//
// Plays a single MP3 file from the microSD card:
// fatfs_stream -> mp3_decoder -> i2s_stream (to ES8311)
//
// Also parses /sdcard/sounds/manifest.json into a small in-RAM list used by the
// "boite a sons" UI grid.
#pragma once
#include <stdbool.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LISAEL_SD_MAX_SOUNDS 32
typedef struct {
char file[64]; // basename, e.g. "miaou.mp3" (under /sdcard/sounds/)
char title[48]; // display title, e.g. "Le chat"
char emoji[8]; // single emoji used as the button icon, e.g. "🐱"
} lisael_sound_t;
// Mount the microSD card via the BSP (FATFS). Idempotent.
esp_err_t lisael_sd_mount(void);
// Parse /sdcard/sounds/manifest.json. Returns count placed into `out` (up to
// LISAEL_SD_MAX_SOUNDS). Returns -1 on error (no card / no manifest).
int lisael_sd_load_manifest(lisael_sound_t *out, int max);
// Generic: parse <MOUNT>/<subdir>/manifest.json (a JSON array of
// {file, title, show?, emoji?}). out[i].file is filled with the ABSOLUTE path
// "<MOUNT>/<subdir>/<file>"; when "show" is present, out[i].title is composed as
// "show — title". Returns count (>=0), or -1 on error. Used for both the sound
// clips ("sounds") and the downloaded podcast episodes ("podcasts").
int lisael_sd_load_manifest_dir(const char *subdir, lisael_sound_t *out, int max);
// Play an absolute SD path (e.g. "/sdcard/sounds/miaou.mp3"). Stops other audio.
esp_err_t lisael_sd_play_file(const char *abs_path);
// Convenience: play a basename under /sdcard/sounds/.
esp_err_t lisael_sd_play_sound(const char *basename);
// Stop the SD pipeline.
void lisael_sd_stop(void);
bool lisael_sd_is_playing(void);
#ifdef __cplusplus
}
#endif