Phase 26: add common parameter targets, step automation and MIDI control mapping

This commit is contained in:
Johannes Findeisen 2026-10-27 16:37:59 +01:00
commit 901a536f10
38 changed files with 740 additions and 67 deletions

40
include/xtc/xtc_control.h Normal file
View file

@ -0,0 +1,40 @@
#ifndef XTC_CONTROL_H
#define XTC_CONTROL_H
#include "xtc_mixer.h"
#include "xtc_plugin.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Stable owner ID + parameter ID, never a dense list index or pointer.
* TRACK includes mix buses: parameters 0 gain / 1 pan.
* PLUGIN owner is a graph node; parameter is its actual LADSPA port.
* LIVE owner is MIDI channel 0..15; parameters 0 volume / 1 pan / 2 sustain.
* Live metadata describes reset defaults, not callback-owned current values. */
typedef enum { XTC_PARAMETER_TRACK = 1, XTC_PARAMETER_PLUGIN, XTC_PARAMETER_LIVE } xtc_parameter_kind;
typedef struct { xtc_parameter_kind kind; uint64_t owner; unsigned int parameter; } xtc_parameter_key;
typedef struct {
xtc_parameter_info info;
unsigned int flags; /* XTC_PLUGIN_* hint flags; units empty if unspecified. */
float value; /* Static configuration; automation may override it. */
int automated;
} xtc_parameter_state;
/* Control thread only. Plugin metadata executes trusted module discovery.
* Failure leaves output/model unchanged. Setter changes static configuration,
* never erases a lane. Compile/publish snapshots before callback use. */
xtc_result xtc_project_parameter(const xtc_project *project, xtc_parameter_key key, double rate, xtc_parameter_state *out);
xtc_result xtc_project_set_parameter(xtc_project *project, xtc_parameter_key key, double rate, float value);
/* Absolute ticks; step 0 linear / 1 hold for segment starting at this point.
* Integer/toggle plugin controls require hold. Live automation is unsupported.
* Remove ignores value/step and fails NOT_FOUND when no point exists. */
xtc_result xtc_project_automate(xtc_project *project, xtc_parameter_key key, double rate,
uint64_t tick, unsigned int step, float value, int remove);
#define XTC_CC_DISABLED 128U
/* Per-channel bindings in order volume, pan, sustain. Defaults 7,10,64.
* Enabled controllers must be distinct and <=127; 120/123 are reserved panic.
* No learn/capture. Copied into MIDI plans; never read from model in callback. */
xtc_result xtc_project_get_control_map(const xtc_project *project, unsigned int channel, unsigned int out[3]);
xtc_result xtc_project_set_control_map(xtc_project *project, unsigned int channel, const unsigned int controllers[3]);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -124,11 +124,12 @@ xtc_result xtc_project_edit_note(xtc_project *project, uint64_t id, uint64_t sta
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_remove_note(xtc_project *project, uint64_t id);
/* Complete 3-byte note on/off and CC7/10/64/120/123. Velocity-zero on -> off.
/* Complete 3-byte note on/off and CC0..127. Velocity-zero on -> off.
* CC120/123 decode to ALL_OFF; other CCs are interpreted by prepared bindings.
* Unsupported messages return UNSUPPORTED; malformed supported messages INVALID.
* Output unchanged on error. No running-status/SysEx/program/bend support. */
/**
* @brief Decodes a complete note or all-notes-off MIDI message into a block event.
* @brief Decodes a complete note, controller or all-notes-off MIDI message into a block event.
*
* @param bytes Borrowed MIDI message bytes.
* @param size Number of message bytes.

View file

@ -19,6 +19,7 @@ typedef struct {
uint64_t track_id, tick;
xtc_automation_parameter parameter;
float value;
unsigned int step; /* 0 linear, 1 hold; mode starts at this point. */
} xtc_automation_point;
/* Buses share the 64 track/automation capacities. A bus cannot contain clips
@ -35,7 +36,7 @@ xtc_result xtc_peak_meter_update(xtc_peak_meter *meter, float linear_peak, doubl
/* 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,
* Automation replaces the corresponding static value, linear/hold per point,
* holds first/last outside the lane. Duplicate track/parameter/tick replaces. */
/**
* @brief Sets a track's gain, pan, mute, and solo controls after validation.

View file

@ -7,7 +7,7 @@
extern "C" {
#endif
#define XTC_PROJECT_FORMAT_VERSION 9U
#define XTC_PROJECT_FORMAT_VERSION 10U
#define XTC_PROJECT_MAX_TRACKS 64U
#define XTC_PROJECT_MAX_CLIPS 1024U
#define XTC_PROJECT_NAME_BYTES 64U