feat(v2): ESP32-S3 controller with Ethernet, I2S mic beat detection and ESP-NOW
New ESP-IDF project in v2/ that replaces the Pi and the UART bridge: - W5500 Ethernet, INMP441 beat/tempo detector (from esp32-eth), ESP-NOW master - LittleFS data store and a JSON API over the Pi's db/*.json collections, with /db import and export; web UI minified and gzipped at build time - Zone play/stop as 0x4C GROUP_CMD, preset push/send as CMD (binary v2 envelope, byte-identical to src/util/binary_envelope.py), sequencer and scenes, driver registration from the boot hello - Reliable bulk link: acks with retransmit, fragments, state-version digest and resync; beat frames sent twice with a lead so drivers fire together - Bench tooling: lossy-link mode, synthetic beats with echo measurement, USB and logic-analyzer latency scripts, and docs/BENCH_TEST.md Needs the matching led-driver changes (p2p branch) to receive the link and beat frames. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7336c7fb22
commit
a94d6a7de5
37 files changed
+5109
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
|
||||
typedef struct {
|
||||
float bpm; // 0 until a tempo has been found
|
||||
float confidence; // 0..1, how periodic the onsets are
|
||||
bool locked; // beats are being emitted
|
||||
uint32_t beat_count;
|
||||
int64_t last_beat_us; // esp_timer time of the last beat, 0 if none
|
||||
int meter; // beats per bar, 3 or 4
|
||||
int bar_beat; // 1..meter of the last beat (best guess), 0 early on
|
||||
bool bar_sure; // bar_beat is reliable, downbeats are being flashed
|
||||
uint32_t downbeat_count;
|
||||
uint32_t onset_count;
|
||||
int64_t last_onset_us;
|
||||
} beat_info_t;
|
||||
|
||||
// Event codes posted to subscriber queues
|
||||
typedef enum {
|
||||
BEAT_EVENT_ONSET,
|
||||
BEAT_EVENT_BEAT,
|
||||
} beat_event_t;
|
||||
|
||||
// Set up the detector and beat LED; call before feeding audio
|
||||
esp_err_t beat_start(float sample_rate);
|
||||
|
||||
// Feed DC-free mono samples at full scale +/-1 (called from the mic task)
|
||||
void beat_feed(const float *x, size_t n);
|
||||
|
||||
void beat_get_info(beat_info_t *out);
|
||||
|
||||
// The user tapped beat 1 just now: correct the bar position to match
|
||||
void beat_tap(void);
|
||||
|
||||
// Have beat_event_t values posted (without blocking) to a queue of
|
||||
// beat_event_t. Returns ESP_ERR_NO_MEM when all subscriber slots are taken.
|
||||
esp_err_t beat_subscribe(QueueHandle_t q);
|
||||
void beat_unsubscribe(QueueHandle_t q);
|
||||
|
||||
// Called from the audio task the moment a beat is emitted, before any queue
|
||||
// fan-out, so the radio can send it with minimal delay. Must not block.
|
||||
typedef void (*beat_cb_t)(const beat_info_t *info, float bpm, bool downbeat);
|
||||
void beat_set_callback(beat_cb_t cb);
|
||||
Reference in new issue
Block a user