Phase 24: add mix buses, coherent peak meters and master clipping indicators

This commit is contained in:
Johannes Findeisen 2026-10-27 16:15:34 +01:00
commit 2fd7724065
32 changed files with 632 additions and 61 deletions

View file

@ -9,6 +9,17 @@
extern "C" {
#endif
/* Control-consumed interval maxima; quantized to 1e-6 linear, capped at 1000.
* Track tap is post-track controls/solo, pre-bus; bus tap is post-bus controls,
* both before the modular graph. Master is post-graph and transport envelope.
* Readers consume maxima, so use one control-thread reader at UI refresh rate. */
typedef struct { uint64_t id; float left, right; } xtc_track_peak;
typedef struct {
size_t count;
xtc_track_peak tracks[XTC_PROJECT_MAX_TRACKS];
float master_left, master_right;
} xtc_meter_snapshot;
typedef struct xtc_backend xtc_backend;
typedef enum {
@ -229,6 +240,8 @@ xtc_result xtc_backend_connect(xtc_backend *backend, xtc_port_direction own_dire
*/
xtc_result xtc_backend_disconnect(xtc_backend *backend, xtc_port_direction own_direction, const char *remote_name);
xtc_result xtc_backend_read_meters(xtc_backend *backend, xtc_meter_snapshot *out);
#ifdef __cplusplus
}
#endif

View file

@ -21,6 +21,18 @@ typedef struct {
float value;
} xtc_automation_point;
/* Buses share the 64 track/automation capacities. A bus cannot contain clips
* or feed another bus. Deleting a bus returns its member tracks to master.
* Solo is inclusive: a solo bus admits all its members, a solo track admits
* itself through its bus; bus mute always wins at the bus output. */
xtc_result xtc_project_add_bus(xtc_project *project, const char *name, uint64_t *out_id);
xtc_result xtc_project_route_track(xtc_project *project, uint64_t track, uint64_t bus_or_master);
/* UI/control-thread sample peak display, dBFS floor -90; instant attack,
* 20 dB/s release, sticky >=1 clip indication. No loudness/true-peak estimate. */
typedef struct { float db; int clipped; } xtc_peak_meter;
void xtc_peak_meter_reset(xtc_peak_meter *meter);
xtc_result xtc_peak_meter_update(xtc_peak_meter *meter, float linear_peak, double seconds);
/* Gain 0..4, pan -1..1, mute/solo 0 or 1. Track audio and scheduled MIDI only.
* Linear pan: center unity on both outputs; hard pan attenuates opposite side.
* Automation replaces the corresponding static value, linear between points,

View file

@ -7,7 +7,7 @@
extern "C" {
#endif
#define XTC_PROJECT_FORMAT_VERSION 8U
#define XTC_PROJECT_FORMAT_VERSION 9U
#define XTC_PROJECT_MAX_TRACKS 64U
#define XTC_PROJECT_MAX_CLIPS 1024U
#define XTC_PROJECT_NAME_BYTES 64U
@ -27,6 +27,8 @@ typedef struct {
char name[XTC_PROJECT_NAME_BYTES];
float gain, pan;
int mute, solo;
int is_bus; /* One-level summing bus; no clips, routes only to master. */
uint64_t bus_id; /* UINT64_MAX = master, otherwise an existing bus ID. */
} xtc_track_info;
/* Arrangement region: empty asset_path means silent metadata.