#pragma once #include #include "cJSON.h" #include "esp_err.h" // Sequence playback, as main's util/sequence_playback.py: one sequence plays at a time in a zone. // Each lane is a list of {preset_id, beats} steps sent to the lane's groups; a step lasts its number // of beats. Beats come from the mic's beat detector while audio timing is on and the tempo is locked, // otherwise from a clock at settings.audio_simulated_bpm (default 120). // Start the beat task (after beat_start) esp_err_t seqplay_init(void); // Start sequence seq_id in zone_id. While another sequence plays, the switch waits for the next beat // (or downbeat, settings.sequence_switch_wait) and *queued is set. ESP_ERR_NOT_FOUND: no such sequence // in the profile; ESP_ERR_INVALID_ARG: no zone (msg says which); ESP_ERR_INVALID_SIZE: no steps. // Call with the store locked. esp_err_t seqplay_start(const char *seq_id, const char *zone_id, const char *profile_id, const char **msg); // Stop; with clear, the zone's drivers drop their presets void seqplay_stop(bool clear); // Stop when seq_id is the one playing (it was edited or deleted) void seqplay_stop_if(const char *seq_id); // Align beat counters: "step" restarts the current step's beat count, "pass" restarts the sequence. // False when nothing plays. bool seqplay_sync(const char *mode); // Playback snapshot (main's playback_status) and the queued start (pending_play_status); caller owns them cJSON *seqplay_status(void); cJSON *seqplay_pending(void); // "6/6" from the last sequence that ran to its end ("" otherwise) const char *seqplay_done_readout(void); // Use the mic's beats for timing (main's audio start/stop); off falls back to the clock void seqplay_set_audio(bool on); bool seqplay_audio(void); // The start-switch wait in effect: "downbeat" (saved, and the mic is timing) or "beat" const char *seqplay_switch_wait(void); // The clock's bar position (1..4) and how many beats it has ticked void seqplay_clock(int *bar_beat, uint32_t *tick);