// 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 #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 //manifest.json (a JSON array of // {file, title, show?, emoji?}). out[i].file is filled with the ABSOLUTE path // "//"; 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