feat: add bounded audio sample editor with waveform selection and source statistics

This commit is contained in:
Johannes Findeisen 2026-11-06 01:01:37 +01:00
commit 7a04c6d922
12 changed files with 364 additions and 8 deletions

21
include/xtc/xtc_sample.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef XTC_SAMPLE_H
#define XTC_SAMPLE_H
#include "xtc_audio.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Control-thread sample editor snapshots. Same WAV mono downmix as playback.
* <=4194304 source frames. No file writes or realtime use. Ranges are half-open,
* nonempty native source frames; failures preserve outputs. */
#define XTC_SAMPLE_MAX_FRAMES 4194304U
typedef struct xtc_sample xtc_sample;
typedef struct { float minimum,maximum; double mean,rms; } xtc_sample_stats;
xtc_result xtc_sample_load(const char *path,xtc_sample **out);
void xtc_sample_destroy(xtc_sample *sample);
xtc_result xtc_sample_info(const xtc_sample *sample,unsigned int *rate,size_t *frames);
xtc_result xtc_sample_read(const xtc_sample *sample,size_t frame,float *out);
xtc_result xtc_sample_analyze(const xtc_sample *sample,size_t begin,size_t end,xtc_sample_stats *out);
#ifdef __cplusplus
}
#endif
#endif