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

View file

@ -1,10 +1,26 @@
#include "xtc/xtc_plugin.h"
#include "xtc/xtc_tempo.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
static void tap_tests(void)
{
xtc_tap_tempo s={0},before;unsigned int tempo=999;
assert(xtc_tap_tempo_push(&s,0,&tempo)==XTC_ERR_NOT_FOUND && tempo==999);
assert(xtc_tap_tempo_push(&s,.5,&tempo)==XTC_OK && tempo==120000);
before=s;assert(xtc_tap_tempo_push(&s,.55,&tempo)==XTC_ERR_INVALID_ARGUMENT && !memcmp(&s,&before,sizeof(s)) && tempo==120000);
assert(xtc_tap_tempo_push(&s,NAN,&tempo)==XTC_ERR_INVALID_ARGUMENT && !memcmp(&s,&before,sizeof(s)));
assert(xtc_tap_tempo_push(&s,.4,&tempo)==XTC_ERR_INVALID_ARGUMENT && !memcmp(&s,&before,sizeof(s)));
assert(xtc_tap_tempo_push(&s,1,&tempo)==XTC_OK && xtc_tap_tempo_push(&s,1.5,&tempo)==XTC_OK && xtc_tap_tempo_push(&s,2,&tempo)==XTC_OK);
assert(xtc_tap_tempo_push(&s,2.25,&tempo)==XTC_OK && tempo==137143);
assert(xtc_tap_tempo_push(&s,10,&tempo)==XTC_ERR_NOT_FOUND && tempo==137143 && !s.count);
assert(xtc_tap_tempo_push(&s,10.25,&tempo)==XTC_OK && tempo==240000);
xtc_tap_tempo_reset(&s);assert(!s.started && !s.count);
}
int main(void)
{
tap_tests();
xtc_track_chain c={0},out={0};
c.output_gain=.8f;c.count=1;c.slots[0].enabled=1;c.slots[0].wet=.4f;
assert(xtc_plugin_probe_format(XTC_PLUGIN_BUILTIN,XTC_BUILTIN_PATH,2,48000,&c.slots[0].plugin)==XTC_OK);