Profiles, presets and sequences export and import as main's bundles. Zones carry group_ids, preset_group_ids, sequence_ids, content_kind and brightness; profiles seed rainbow as colour_cycle, and deleting a profile also deletes its sequences. Groups, zones and sequences written by older versions are migrated at boot. /api/audio (status, event stream, start/stop, reset, anchor-bar, devices) maps main's audio detector onto the mic's beat detector. Audio start/stop picks whether mic beats or the BPM clock time sequences; the clock's beats also go to the drivers while the mic is off. /ws now greets from a post-handshake callback (httpd does not call the handler for the upgrade). The web UI is main's, plus v2's outputs editor, list search and hostname/static IP settings; the bridge, Wi-Fi AP and led-tool parts are gone. API tests follow main's behaviour (119 pass on the board). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.0 KiB
C
45 lines
2.0 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#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);
|