feat(transport): set project tempo by tapping a pulse (phase 97)

This commit is contained in:
Johannes Findeisen 2026-11-06 02:09:02 +01:00
commit b7a4a1acd4
9 changed files with 92 additions and 5 deletions

18
include/xtc/xtc_tempo.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef XTC_TEMPO_H
#define XTC_TEMPO_H
#include "xtc_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Control-thread estimator, four rolling intervals, 20..300 BPM. Zero initialize
* or reset before use. Caller supplies monotonic seconds; no clock or I/O here. */
typedef struct {double last,intervals[4];unsigned int count,head,started;} xtc_tap_tempo;
void xtc_tap_tempo_reset(xtc_tap_tempo *state);
/* First tap or gap >3s primes/restarts and returns NOT_FOUND without changing
* out. Invalid arguments/too-fast/backward timestamps preserve state and out.
* Success returns rounded milli-BPM and updates state. */
xtc_result xtc_tap_tempo_push(xtc_tap_tempo *state,double seconds,unsigned int *out);
#ifdef __cplusplus
}
#endif
#endif