Some code semantics refactoring.
This commit is contained in:
parent
de403b37d7
commit
0f04e056b2
42 changed files with 3374 additions and 1357 deletions
|
|
@ -1,33 +1,35 @@
|
|||
#ifndef XTC_AUDIO_H
|
||||
#define XTC_AUDIO_H
|
||||
|
||||
#include "xtc_project.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct xtc_audio_plan xtc_audio_plan;
|
||||
typedef struct xtc_recorder xtc_recorder;
|
||||
|
||||
/* Control-thread WAV import: PCM16/24/32 or float32, mono/stereo downmixed to
|
||||
* mono, 1..768000 Hz. Absolute canonical references, <=511 bytes.
|
||||
* Adds a timeline source -> output route if no timeline source exists.
|
||||
* Transactional; track must exist. Duration rounds up to a musical tick. */
|
||||
xtc_result xtc_project_import_audio(xtc_project *project, uint64_t track,
|
||||
const char *path, uint64_t start_tick, uint64_t *out_clip);
|
||||
xtc_result xtc_project_import_audio(xtc_project *project, uint64_t track, const char *path, uint64_t start_tick,
|
||||
uint64_t *out_clip);
|
||||
/* Empty path makes a region silent; nonempty path must be absolute. Does not
|
||||
* open the file. Missing references survive save/load for later relinking. */
|
||||
xtc_result xtc_project_set_clip_asset(xtc_project *project, uint64_t clip, const char *path);
|
||||
/* Immutable/preloaded plan. At most 64 distinct assets, 16M mono frames/asset,
|
||||
* 64M total frames, 256 MiB file and 4096 chunk input limits. Missing/invalid assets become silence with explicit issues.
|
||||
* OOM/capacity fails creation. No file access during render. */
|
||||
xtc_result xtc_audio_plan_create(const xtc_project *project, unsigned int rate,
|
||||
xtc_audio_plan **out_plan);
|
||||
* 64M total frames, 256 MiB file and 4096 chunk input limits. Missing/invalid assets become silence with explicit
|
||||
* issues. OOM/capacity fails creation. No file access during render. */
|
||||
xtc_result xtc_audio_plan_create(const xtc_project *project, unsigned int rate, xtc_audio_plan **out_plan);
|
||||
void xtc_audio_plan_destroy(xtc_audio_plan *plan);
|
||||
size_t xtc_audio_plan_issues(const xtc_audio_plan *plan, const char **out_first_path);
|
||||
/* Single consumer; output replaced with overlap-summed mono at unity gain.
|
||||
* Linear rate conversion, no time stretching. Output must have frames floats. */
|
||||
/* Stereo outputs must be distinct; NULL right selects mono gain-only rendering. */
|
||||
xtc_result xtc_audio_plan_render_stereo(const xtc_audio_plan *, uint64_t, float *left, float *right, size_t);
|
||||
xtc_result xtc_audio_plan_render(const xtc_audio_plan *plan, uint64_t position,
|
||||
float *output, size_t frames);
|
||||
xtc_result xtc_audio_plan_render(const xtc_audio_plan *plan, uint64_t position, float *output, size_t frames);
|
||||
/* Control-thread creation opens a same-directory temporary float32 WAV.
|
||||
* Ring capacity 1..2097152 frames. One callback producer, one control consumer.
|
||||
* push accepts whole blocks; overflow is sticky and all later input is dropped.
|
||||
|
|
@ -35,14 +37,15 @@ xtc_result xtc_audio_plan_render(const xtc_audio_plan *plan, uint64_t position,
|
|||
* drains, finalizes and atomically renames even on overflow (partial recovery).
|
||||
* No source/recorder is freed until destroy, which also removes unfinished temp.
|
||||
* Counts and sticky error can be observed while producing. */
|
||||
xtc_result xtc_recorder_create(const char *path, unsigned int rate, size_t capacity,
|
||||
xtc_recorder **out_recorder);
|
||||
xtc_result xtc_recorder_create(const char *path, unsigned int rate, size_t capacity, xtc_recorder **out_recorder);
|
||||
void xtc_recorder_push(xtc_recorder *recorder, const float *input, size_t frames);
|
||||
xtc_result xtc_recorder_drain(xtc_recorder *recorder);
|
||||
xtc_result xtc_recorder_finish(xtc_recorder *recorder);
|
||||
xtc_result xtc_recorder_status(const xtc_recorder *recorder, uint64_t *out_frames);
|
||||
void xtc_recorder_destroy(xtc_recorder *recorder);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,20 +1,27 @@
|
|||
#ifndef XTC_BACKEND_H
|
||||
#define XTC_BACKEND_H
|
||||
|
||||
#include "xtc_engine.h"
|
||||
#include "xtc_audio.h"
|
||||
#include "xtc_midi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct xtc_backend xtc_backend;
|
||||
typedef enum { XTC_BACKEND_JACK = 1 } xtc_backend_kind;
|
||||
|
||||
typedef enum {
|
||||
XTC_BACKEND_JACK = 1
|
||||
} xtc_backend_kind;
|
||||
|
||||
typedef struct {
|
||||
xtc_backend_kind kind;
|
||||
const char *client_name; /* Borrowed for open only; nonempty. */
|
||||
size_t max_frames; /* 1..65536, at least the server's current block. */
|
||||
size_t channel_count; /* 1 mono or 2 stereo output; input/recording remain mono. */
|
||||
} xtc_backend_config;
|
||||
|
||||
typedef struct {
|
||||
float peak_left, peak_right; /* Last-block output peaks, zero while stopped. */
|
||||
unsigned int sample_rate;
|
||||
|
|
@ -23,7 +30,7 @@ typedef struct {
|
|||
unsigned int processed_blocks;
|
||||
unsigned int midi_dropped; /* Malformed/overflowed input; unsigned wrap. */
|
||||
unsigned int asset_issues; /* Unique missing/unreadable/unsupported assets. */
|
||||
uint64_t sample_position; /* Successful callback frames; retained across stop/submit. */
|
||||
uint64_t sample_position; /* Successful callback frames; retained across stop/submit. */
|
||||
unsigned int submitted_revision, active_revision;
|
||||
int running;
|
||||
int server_lost;
|
||||
|
|
@ -66,22 +73,21 @@ xtc_result xtc_backend_get_status(const xtc_backend *backend, xtc_backend_status
|
|||
/* Borrowed names valid until close. Direction is the client's own port. */
|
||||
/* Output channel 0 is legacy output, channel 1 is output_right in stereo. */
|
||||
xtc_result xtc_backend_output_name(const xtc_backend *, size_t channel, const char **out_name);
|
||||
xtc_result xtc_backend_port_name(const xtc_backend *backend, xtc_port_direction direction,
|
||||
const char **out_name);
|
||||
xtc_result xtc_backend_port_name(const xtc_backend *backend, xtc_port_direction direction, const char **out_name);
|
||||
/* Enumerates available mono audio ports (devices and software routes). Visitor
|
||||
* receives a borrowed name valid only during call; return nonzero to stop.
|
||||
* Control-thread only. JACK NULL list means no matching ports. */
|
||||
typedef int (*xtc_backend_port_visitor)(const char *name, void *context);
|
||||
xtc_result xtc_backend_visit_ports(xtc_backend *backend, xtc_port_direction direction,
|
||||
xtc_backend_port_visitor visitor, void *context);
|
||||
xtc_result xtc_backend_visit_ports(xtc_backend *backend, xtc_port_direction direction, xtc_backend_port_visitor visitor,
|
||||
void *context);
|
||||
/* Connect/disconnect this client's port with a remote opposite-direction port.
|
||||
* own_direction INPUT receives remote output; OUTPUT sends to remote input.
|
||||
* Explicit user choice only; no automatic physical routing. */
|
||||
xtc_result xtc_backend_connect(xtc_backend *backend, xtc_port_direction own_direction,
|
||||
const char *remote_name);
|
||||
xtc_result xtc_backend_disconnect(xtc_backend *backend, xtc_port_direction own_direction,
|
||||
const char *remote_name);
|
||||
xtc_result xtc_backend_connect(xtc_backend *backend, xtc_port_direction own_direction, const char *remote_name);
|
||||
xtc_result xtc_backend_disconnect(xtc_backend *backend, xtc_port_direction own_direction, const char *remote_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ typedef enum {
|
|||
XTC_NODE_OSCILLATOR,
|
||||
XTC_NODE_METER,
|
||||
XTC_NODE_OUTPUT,
|
||||
XTC_NODE_AUDIO, /* Timeline mix source, output only. */
|
||||
XTC_NODE_AUDIO, /* Timeline mix source, output only. */
|
||||
XTC_NODE_INSTRUMENT, /* Internal MIDI instrument, output only. */
|
||||
XTC_NODE_NATIVE /* Trusted source/effect; see xtc_native.h. */
|
||||
XTC_NODE_NATIVE /* Trusted source/effect; see xtc_native.h. */
|
||||
} xtc_node_type;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -48,18 +48,32 @@ typedef struct {
|
|||
* monotonically assigned identifiers; removed IDs are never reused. Output
|
||||
* parameters are written only on success, except create/compile/apply_edit
|
||||
* which set their output pointer to NULL on failure. */
|
||||
typedef struct { size_t id; xtc_node_type type; float value; } xtc_node_info;
|
||||
typedef struct {
|
||||
size_t id;
|
||||
xtc_node_type type;
|
||||
float value;
|
||||
} xtc_node_info;
|
||||
|
||||
typedef struct {
|
||||
size_t source_node, source_port, destination_node, destination_port;
|
||||
} xtc_connection_info;
|
||||
|
||||
typedef enum {
|
||||
XTC_EDIT_ADD_NODE = 1, XTC_EDIT_REMOVE_NODE,
|
||||
XTC_EDIT_CONNECT, XTC_EDIT_DISCONNECT
|
||||
XTC_EDIT_ADD_NODE = 1,
|
||||
XTC_EDIT_REMOVE_NODE,
|
||||
XTC_EDIT_CONNECT,
|
||||
XTC_EDIT_DISCONNECT
|
||||
} xtc_graph_edit_kind;
|
||||
|
||||
typedef struct {
|
||||
xtc_graph_edit_kind kind;
|
||||
|
||||
union {
|
||||
struct { xtc_node_type type; float value; } add;
|
||||
struct {
|
||||
xtc_node_type type;
|
||||
float value;
|
||||
} add;
|
||||
|
||||
size_t node_id;
|
||||
xtc_connection_info connection;
|
||||
} data;
|
||||
|
|
@ -76,22 +90,18 @@ xtc_result xtc_graph_require_output_nodes(xtc_graph *graph, int required);
|
|||
/* Transactional command: on success caller owns a new graph; source unchanged.
|
||||
* Failure sets *out_graph=NULL, leaves source and out_added_id unchanged.
|
||||
* out_added_id is optional and written only for successful ADD_NODE. */
|
||||
xtc_result xtc_graph_apply_edit(const xtc_graph *source, const xtc_graph_edit *edit,
|
||||
xtc_graph **out_graph, size_t *out_added_id);
|
||||
xtc_result xtc_graph_apply_edit(const xtc_graph *source, const xtc_graph_edit *edit, xtc_graph **out_graph,
|
||||
size_t *out_added_id);
|
||||
xtc_result xtc_graph_create(size_t max_nodes, xtc_graph **out_graph);
|
||||
void xtc_graph_destroy(xtc_graph *graph);
|
||||
xtc_result xtc_graph_add_gain(xtc_graph *graph, float gain, size_t *out_node_id);
|
||||
xtc_result xtc_graph_connect(xtc_graph *graph, size_t source_node,
|
||||
size_t destination_node);
|
||||
xtc_result xtc_graph_connect(xtc_graph *graph, size_t source_node, size_t destination_node);
|
||||
/* Port 0 is input; port 1 is output. Oscillators, audio sources and instruments have only output 1;
|
||||
* output nodes have only input 0. All ports carry mono audio. */
|
||||
xtc_result xtc_graph_get_port(const xtc_graph *graph, size_t node_id,
|
||||
size_t port_id, xtc_port_info *out_port);
|
||||
xtc_result xtc_graph_connect_ports(xtc_graph *graph, size_t source_node,
|
||||
size_t source_port, size_t destination_node,
|
||||
size_t destination_port);
|
||||
xtc_result xtc_graph_add_oscillator(xtc_graph *graph, float frequency,
|
||||
size_t *out_node_id);
|
||||
xtc_result xtc_graph_get_port(const xtc_graph *graph, size_t node_id, size_t port_id, xtc_port_info *out_port);
|
||||
xtc_result xtc_graph_connect_ports(xtc_graph *graph, size_t source_node, size_t source_port, size_t destination_node,
|
||||
size_t destination_port);
|
||||
xtc_result xtc_graph_add_oscillator(xtc_graph *graph, float frequency, size_t *out_node_id);
|
||||
xtc_result xtc_graph_add_meter(xtc_graph *graph, size_t *out_node_id);
|
||||
xtc_result xtc_graph_add_instrument(xtc_graph *graph, size_t *out_node_id);
|
||||
xtc_result xtc_graph_add_audio(xtc_graph *graph, size_t *out_node_id);
|
||||
|
|
@ -99,8 +109,7 @@ xtc_result xtc_graph_add_output(xtc_graph *graph, size_t *out_node_id);
|
|||
/* Compile copies graph state; caller owns the plan. Sample rate must be
|
||||
* finite and positive, oscillator frequencies <= Nyquist. max_frames: 1..65536.
|
||||
* Editing/destroying the graph never changes an existing plan. */
|
||||
xtc_result xtc_graph_compile(const xtc_graph *graph, double sample_rate,
|
||||
size_t max_frames, xtc_plan **out_plan);
|
||||
xtc_result xtc_graph_compile(const xtc_graph *graph, double sample_rate, size_t max_frames, xtc_plan **out_plan);
|
||||
void xtc_plan_destroy(xtc_plan *plan);
|
||||
/* Single processing owner, no concurrent calls (including meter reads/reset).
|
||||
* No allocation, I/O, locking or graph validation. NULL input means silence.
|
||||
|
|
@ -113,16 +122,15 @@ void xtc_plan_destroy(xtc_plan *plan);
|
|||
/* Stereo graph with paired source buffers and a mono external input duplicated
|
||||
* to both sides. Output buffers must be distinct and must not alias sources.
|
||||
* Stereo oscillator phase advances once per frame. NULL right selects mono. */
|
||||
xtc_result xtc_plan_process_stereo(xtc_plan *, const float *input,
|
||||
const float *audio_left, const float *audio_right, const float *midi_left, const float *midi_right,
|
||||
float *left, float *right, size_t frames);
|
||||
xtc_result xtc_plan_process_sources(xtc_plan *plan, const float *input, const float *timeline,
|
||||
const float *instrument, float *output, size_t frames);
|
||||
xtc_result xtc_plan_process_stereo(xtc_plan *, const float *input, const float *audio_left, const float *audio_right,
|
||||
const float *midi_left, const float *midi_right, float *left, float *right,
|
||||
size_t frames);
|
||||
xtc_result xtc_plan_process_sources(xtc_plan *plan, const float *input, const float *timeline, const float *instrument,
|
||||
float *output, size_t frames);
|
||||
/* timeline is a separate mono input for XTC_NODE_AUDIO, NULL means silence. */
|
||||
xtc_result xtc_plan_process_audio(xtc_plan *plan, const float *input, const float *timeline,
|
||||
float *output, size_t frames);
|
||||
xtc_result xtc_plan_process(xtc_plan *plan, const float *input, float *output,
|
||||
size_t frame_count);
|
||||
xtc_result xtc_plan_process_audio(xtc_plan *plan, const float *input, const float *timeline, float *output,
|
||||
size_t frames);
|
||||
xtc_result xtc_plan_process(xtc_plan *plan, const float *input, float *output, size_t frame_count);
|
||||
/* Resets oscillator phases and meters, without allocation. */
|
||||
xtc_result xtc_plan_reset(xtc_plan *plan);
|
||||
/* Last block absolute peak, valid for meter nodes only. */
|
||||
|
|
@ -130,9 +138,8 @@ xtc_result xtc_plan_meter_peak(const xtc_plan *plan, size_t node_id, float *out_
|
|||
xtc_result xtc_graph_validate(const xtc_graph *graph);
|
||||
/* Allocating compatibility helper: compiles at 48000 Hz and processes once.
|
||||
* Requires non-NULL input/output and finite input_gain. Not for callbacks. */
|
||||
xtc_result xtc_graph_process_offline(xtc_graph *graph, const float *input,
|
||||
float *output, size_t frame_count,
|
||||
float input_gain);
|
||||
xtc_result xtc_graph_process_offline(xtc_graph *graph, const float *input, float *output, size_t frame_count,
|
||||
float input_gain);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,50 @@
|
|||
#ifndef XTC_MIDI_H
|
||||
#define XTC_MIDI_H
|
||||
|
||||
#include "xtc_project.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XTC_PROJECT_MAX_NOTES 4096U
|
||||
#define XTC_MIDI_MAX_EVENTS 256U
|
||||
#define XTC_MIDI_VOICES 32U
|
||||
|
||||
typedef struct {
|
||||
uint64_t id, clip_id, start_tick, length_tick; /* Positions in clip source. */
|
||||
unsigned int pitch, velocity, channel; /* 0..127, 1..127, 0..15. */
|
||||
unsigned int pitch, velocity, channel; /* 0..127, 1..127, 0..15. */
|
||||
} xtc_note_info;
|
||||
typedef enum { XTC_MIDI_NOTE_ON = 1, XTC_MIDI_NOTE_OFF, XTC_MIDI_ALL_OFF } xtc_midi_type;
|
||||
|
||||
typedef enum {
|
||||
XTC_MIDI_NOTE_ON = 1,
|
||||
XTC_MIDI_NOTE_OFF,
|
||||
XTC_MIDI_ALL_OFF
|
||||
} xtc_midi_type;
|
||||
|
||||
typedef struct {
|
||||
unsigned int offset; /* Sample offset within THIS block, strictly < frames. */
|
||||
xtc_midi_type type;
|
||||
unsigned int channel, pitch, velocity;
|
||||
} xtc_midi_event;
|
||||
typedef struct xtc_midi_plan xtc_midi_plan;
|
||||
|
||||
/* Control-thread model APIs, stable note IDs; deletion cascades from clips/tracks.
|
||||
* MIDI clips cannot reference audio. Creation transactionally adds an instrument
|
||||
* source -> output route if no instrument exists. Other clip edits stay shared. */
|
||||
xtc_result xtc_project_add_midi_clip(xtc_project *project, uint64_t track,
|
||||
uint64_t start, uint64_t length, uint64_t *out_id);
|
||||
xtc_result xtc_project_add_midi_clip(xtc_project *project, uint64_t track, uint64_t start, uint64_t length,
|
||||
uint64_t *out_id);
|
||||
xtc_result xtc_project_note_count(const xtc_project *project, size_t *out_count);
|
||||
xtc_result xtc_project_get_note(const xtc_project *project, size_t index, xtc_note_info *out_note);
|
||||
xtc_result xtc_project_add_note(xtc_project *project, uint64_t clip, uint64_t start,
|
||||
uint64_t length, unsigned int pitch, unsigned int velocity, unsigned int channel, uint64_t *out_id);
|
||||
xtc_result xtc_project_edit_note(xtc_project *project, uint64_t id, uint64_t start,
|
||||
uint64_t length, unsigned int pitch, unsigned int velocity, unsigned int channel);
|
||||
xtc_result xtc_project_add_note(xtc_project *project, uint64_t clip, uint64_t start, uint64_t length,
|
||||
unsigned int pitch, unsigned int velocity, unsigned int channel, uint64_t *out_id);
|
||||
xtc_result xtc_project_edit_note(xtc_project *project, uint64_t id, uint64_t start, uint64_t length, unsigned int pitch,
|
||||
unsigned int velocity, unsigned int channel);
|
||||
xtc_result xtc_project_remove_note(xtc_project *project, uint64_t id);
|
||||
/* Complete 3-byte note on/off and CC120/123 only. Velocity-zero on -> off.
|
||||
* Unsupported messages return UNSUPPORTED; malformed supported messages INVALID.
|
||||
* Output unchanged on error. No running-status/SysEx/pedal/program/bend support. */
|
||||
xtc_result xtc_midi_decode(const unsigned char *bytes, size_t size, unsigned int offset,
|
||||
xtc_midi_event *out_event);
|
||||
xtc_result xtc_midi_decode(const unsigned char *bytes, size_t size, unsigned int offset, xtc_midi_event *out_event);
|
||||
/* Control-thread compile; immutable ranges plus exclusively audio-owned runtime.
|
||||
* Rejects >32 simultaneous scheduled notes. Separate 32 live voices steal oldest.
|
||||
* Constant-tempo sine instrument, velocity *0.1, above-Nyquist notes silent. */
|
||||
|
|
@ -50,10 +60,13 @@ void xtc_midi_plan_panic(xtc_midi_plan *plan, uint64_t position);
|
|||
* Renders [position,position+frames); discontinuity clears live voices, chases
|
||||
* scheduled notes at their correct phase. Note-off is immediate (no envelope). */
|
||||
/* Distinct stereo outputs; NULL right retains mono (gain only). */
|
||||
xtc_result xtc_midi_plan_render_stereo(xtc_midi_plan *, uint64_t, const xtc_midi_event *, size_t, float *left, float *right, size_t);
|
||||
xtc_result xtc_midi_plan_render(xtc_midi_plan *plan, uint64_t position,
|
||||
const xtc_midi_event *events, size_t count, float *output, size_t frames);
|
||||
xtc_result xtc_midi_plan_render_stereo(xtc_midi_plan *, uint64_t, const xtc_midi_event *, size_t, float *left,
|
||||
float *right, size_t);
|
||||
xtc_result xtc_midi_plan_render(xtc_midi_plan *plan, uint64_t position, const xtc_midi_event *events, size_t count,
|
||||
float *output, size_t frames);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,26 +1,33 @@
|
|||
#ifndef XTC_MIXER_H
|
||||
#define XTC_MIXER_H
|
||||
|
||||
#include "xtc_project.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XTC_MAX_AUTOMATION_POINTS 1024U
|
||||
#define XTC_HISTORY_EDITS 32U
|
||||
typedef enum { XTC_AUTOMATION_GAIN = 0, XTC_AUTOMATION_PAN = 1 } xtc_automation_parameter;
|
||||
|
||||
typedef enum {
|
||||
XTC_AUTOMATION_GAIN = 0,
|
||||
XTC_AUTOMATION_PAN = 1
|
||||
} xtc_automation_parameter;
|
||||
|
||||
typedef struct {
|
||||
uint64_t track_id, tick;
|
||||
xtc_automation_parameter parameter;
|
||||
float value;
|
||||
} xtc_automation_point;
|
||||
|
||||
/* 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,
|
||||
* holds first/last outside the lane. Duplicate track/parameter/tick replaces. */
|
||||
xtc_result xtc_project_set_mix(xtc_project *, uint64_t track, float gain, float pan, int mute,
|
||||
int solo);
|
||||
xtc_result xtc_project_set_mix(xtc_project *, uint64_t track, float gain, float pan, int mute, int solo);
|
||||
xtc_result xtc_project_set_automation(xtc_project *, const xtc_automation_point *);
|
||||
xtc_result xtc_project_remove_automation(xtc_project *, uint64_t track, xtc_automation_parameter,
|
||||
uint64_t tick);
|
||||
xtc_result xtc_project_remove_automation(xtc_project *, uint64_t track, xtc_automation_parameter, uint64_t tick);
|
||||
xtc_result xtc_project_automation_count(const xtc_project *, size_t *);
|
||||
xtc_result xtc_project_get_automation(const xtc_project *, size_t, xtc_automation_point *);
|
||||
/* Control-thread snapshot history; 32 edits plus baseline, no assets/DSP/GUI.
|
||||
|
|
@ -29,12 +36,15 @@ xtc_result xtc_project_get_automation(const xtc_project *, size_t, xtc_automatio
|
|||
* Allocation ID high-water marks survive checkout/branching.
|
||||
* Reset by creating a new history for New/Open. */
|
||||
typedef struct xtc_history xtc_history;
|
||||
|
||||
xtc_result xtc_history_create(const xtc_project *, xtc_history **);
|
||||
void xtc_history_destroy(xtc_history *);
|
||||
xtc_result xtc_history_record(xtc_history *, const xtc_project *);
|
||||
xtc_result xtc_history_checkout(const xtc_history *, int redo, xtc_project **);
|
||||
xtc_result xtc_history_accept(xtc_history *, int redo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
#ifndef XTC_NATIVE_H
|
||||
#define XTC_NATIVE_H
|
||||
|
||||
#include "xtc_midi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XTC_NATIVE_ABI_VERSION 1U
|
||||
#define XTC_NATIVE_ID_BYTES 64U
|
||||
typedef enum { XTC_NATIVE_EFFECT = 1, XTC_NATIVE_SOURCE, XTC_NATIVE_INSTRUMENT } xtc_native_kind;
|
||||
|
||||
typedef enum {
|
||||
XTC_NATIVE_EFFECT = 1,
|
||||
XTC_NATIVE_SOURCE,
|
||||
XTC_NATIVE_INSTRUMENT
|
||||
} xtc_native_kind;
|
||||
|
||||
typedef struct {
|
||||
const float *input; /* NULL is silence; may equal output. Borrowed for call. */
|
||||
float *output; /* Write every frame, including silence. */
|
||||
|
|
@ -15,6 +24,7 @@ typedef struct {
|
|||
const xtc_midi_event *events; /* Instruments only, sorted block offsets. */
|
||||
size_t event_count;
|
||||
} xtc_native_block;
|
||||
|
||||
typedef struct {
|
||||
unsigned int abi_version;
|
||||
size_t struct_size; /* Must equal sizeof(xtc_native_descriptor) for ABI 1. */
|
||||
|
|
@ -29,11 +39,12 @@ typedef struct {
|
|||
void (*destroy)(void *state);
|
||||
} xtc_native_descriptor;
|
||||
typedef struct xtc_native xtc_native;
|
||||
|
||||
/* Descriptors are copied; callback code must remain loaded through destruction.
|
||||
* Trusted statically linked C code, not a sandbox or stable shared-library ABI. */
|
||||
xtc_result xtc_native_validate(const xtc_native_descriptor *);
|
||||
xtc_result xtc_native_create(const xtc_native_descriptor *, double rate, size_t max_frames,
|
||||
float parameter, xtc_native **out_processor);
|
||||
xtc_result xtc_native_create(const xtc_native_descriptor *, double rate, size_t max_frames, float parameter,
|
||||
xtc_native **out_processor);
|
||||
void xtc_native_destroy(xtc_native *);
|
||||
void xtc_native_reset(xtc_native *);
|
||||
/* Bounded, single-owner, realtime-safe host path (callbacks must obey contract).
|
||||
|
|
@ -46,11 +57,11 @@ xtc_result xtc_native_process(xtc_native *, const xtc_native_block *);
|
|||
* source buffer through xtc_plan_process_sources/stereo. Graph add returns
|
||||
* UNSUPPORTED for instrument descriptors (no event port in current topology).
|
||||
* Native graphs are session-only: project save returns UNSUPPORTED. */
|
||||
xtc_result xtc_graph_add_native(xtc_graph *, const xtc_native_descriptor *, float parameter,
|
||||
size_t *out_id);
|
||||
xtc_result xtc_graph_get_native(const xtc_graph *, size_t node_id,
|
||||
xtc_native_descriptor *out_descriptor);
|
||||
xtc_result xtc_graph_add_native(xtc_graph *, const xtc_native_descriptor *, float parameter, size_t *out_id);
|
||||
xtc_result xtc_graph_get_native(const xtc_graph *, size_t node_id, xtc_native_descriptor *out_descriptor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
#ifndef XTC_PROJECT_H
|
||||
#define XTC_PROJECT_H
|
||||
|
||||
#include "xtc_engine.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XTC_PROJECT_MAX_TRACKS 64U
|
||||
#define XTC_PROJECT_MAX_CLIPS 1024U
|
||||
#define XTC_PROJECT_NAME_BYTES 64U
|
||||
|
|
@ -11,9 +14,14 @@ extern "C" {
|
|||
#define XTC_TICKS_PER_QUARTER 960U
|
||||
#define XTC_PROJECT_MAX_TICK UINT64_C(38400000)
|
||||
typedef struct xtc_project xtc_project;
|
||||
typedef struct { uint64_t id; char name[XTC_PROJECT_NAME_BYTES];
|
||||
float gain, pan; int mute, solo;
|
||||
|
||||
typedef struct {
|
||||
uint64_t id;
|
||||
char name[XTC_PROJECT_NAME_BYTES];
|
||||
float gain, pan;
|
||||
int mute, solo;
|
||||
} xtc_track_info;
|
||||
|
||||
/* Arrangement region: empty asset_path means silent metadata.
|
||||
* All musical positions are integer ticks, constant tempo and 4/4 meter. */
|
||||
typedef struct {
|
||||
|
|
@ -22,6 +30,7 @@ typedef struct {
|
|||
char asset_path[XTC_ASSET_PATH_BYTES];
|
||||
int midi; /* 0 silent/audio region, 1 MIDI clip; no asset path in MIDI. */
|
||||
} xtc_clip_info;
|
||||
|
||||
/* Single control-thread ownership. Names: nonempty UTF-8, <=63 bytes, no ASCII controls.
|
||||
* IDs are monotonic, never reused, UINT64_MAX reserved. Snapshots are copies. */
|
||||
xtc_result xtc_project_create(xtc_project **out_project);
|
||||
|
|
@ -34,12 +43,12 @@ xtc_result xtc_project_find_clip(const xtc_project *project, uint64_t id, xtc_cl
|
|||
xtc_result xtc_project_add_track(xtc_project *project, const char *name, uint64_t *out_id);
|
||||
/* Removing a track also removes its clips. */
|
||||
xtc_result xtc_project_remove_track(xtc_project *project, uint64_t id);
|
||||
xtc_result xtc_project_add_clip(xtc_project *project, uint64_t track_id, const char *name,
|
||||
uint64_t start_tick, uint64_t length_tick, uint64_t *out_id);
|
||||
xtc_result xtc_project_add_clip(xtc_project *project, uint64_t track_id, const char *name, uint64_t start_tick,
|
||||
uint64_t length_tick, uint64_t *out_id);
|
||||
xtc_result xtc_project_remove_clip(xtc_project *project, uint64_t id);
|
||||
/* Atomic move/trim: source bounds remain unchanged, no destructive edits. */
|
||||
xtc_result xtc_project_edit_clip(xtc_project *project, uint64_t id, uint64_t track_id,
|
||||
uint64_t start_tick, uint64_t length_tick, uint64_t offset_tick);
|
||||
xtc_result xtc_project_edit_clip(xtc_project *project, uint64_t id, uint64_t track_id, uint64_t start_tick,
|
||||
uint64_t length_tick, uint64_t offset_tick);
|
||||
/* Borrowed opaque graph valid until project mutation/destruction. set_graph
|
||||
* copies before replacing; max 64 nodes, preserving IDs, edges and output policy. */
|
||||
const xtc_graph *xtc_project_graph(const xtc_project *project);
|
||||
|
|
@ -49,16 +58,18 @@ unsigned int xtc_project_tempo(const xtc_project *project);
|
|||
xtc_result xtc_project_set_tempo(xtc_project *project, unsigned int milli_bpm);
|
||||
/* Floor conversion, no accumulated drift. Rate: 1..768000. Tick <= MAX_TICK.
|
||||
* Excess sample/tick positions return capacity; outputs unchanged on error. */
|
||||
xtc_result xtc_project_tick_to_sample(const xtc_project *project, uint64_t tick,
|
||||
unsigned int sample_rate, uint64_t *out_sample);
|
||||
xtc_result xtc_project_sample_to_tick(const xtc_project *project, uint64_t sample,
|
||||
unsigned int sample_rate, uint64_t *out_tick);
|
||||
xtc_result xtc_project_tick_to_sample(const xtc_project *project, uint64_t tick, unsigned int sample_rate,
|
||||
uint64_t *out_sample);
|
||||
xtc_result xtc_project_sample_to_tick(const xtc_project *project, uint64_t sample, unsigned int sample_rate,
|
||||
uint64_t *out_tick);
|
||||
/* Control-thread I/O. Versioned, bounded format; see docs/PROJECT_FORMAT.md.
|
||||
* Load is transactional. Save fsyncs a same-directory temporary and renames it;
|
||||
* failures before rename preserve the previous destination. No asset I/O. */
|
||||
xtc_result xtc_project_save(const xtc_project *project, const char *path);
|
||||
xtc_result xtc_project_load(xtc_project *project, const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#ifndef XTC_REALTIME_H
|
||||
#define XTC_REALTIME_H
|
||||
|
||||
#include "xtc_engine.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct xtc_realtime xtc_realtime;
|
||||
|
||||
typedef struct {
|
||||
unsigned int processed_blocks; /* Wraps modulo UINT_MAX + 1. */
|
||||
xtc_result last_result;
|
||||
|
|
@ -15,8 +18,7 @@ typedef struct {
|
|||
/* Control thread only. A single control producer and single audio consumer.
|
||||
* C99 with GCC/Clang lock-free __atomic builtins is required; unsupported
|
||||
* targets return XTC_ERR_UNSUPPORTED. No ownership is shared with callers. */
|
||||
xtc_result xtc_realtime_create(double sample_rate, size_t max_frames,
|
||||
xtc_realtime **out_engine);
|
||||
xtc_result xtc_realtime_create(double sample_rate, size_t max_frames, xtc_realtime **out_engine);
|
||||
/* Requires the audio consumer to have stopped and joined. */
|
||||
void xtc_realtime_destroy(xtc_realtime *engine);
|
||||
/* Compiles/copies a graph. One pending plan allowed; full mailbox returns
|
||||
|
|
@ -24,23 +26,23 @@ void xtc_realtime_destroy(xtc_realtime *engine);
|
|||
xtc_result xtc_realtime_submit(xtc_realtime *engine, const xtc_graph *graph);
|
||||
/* Frees acknowledged retired state, never the audio thread's active plan. */
|
||||
void xtc_realtime_collect(xtc_realtime *engine);
|
||||
xtc_result xtc_realtime_get_status(const xtc_realtime *engine,
|
||||
xtc_realtime_status *out_status);
|
||||
xtc_result xtc_realtime_get_status(const xtc_realtime *engine, xtc_realtime_status *out_status);
|
||||
/* Audio consumer only. Adopts at most one plan per block, without allocation,
|
||||
* freeing, locks or I/O. No plan means silence. On failure writes silence.
|
||||
* frame_count must be <= configured max_frames and output must hold it.
|
||||
* Oversized buffers are silenced too; callers must bound their own frame count.
|
||||
* NULL input means silence. Zero frames is a no-op. */
|
||||
xtc_result xtc_realtime_process_stereo(xtc_realtime *, const float *input,
|
||||
const float *audio_left, const float *audio_right, const float *midi_left, const float *midi_right,
|
||||
float *left, float *right, size_t frames);
|
||||
xtc_result xtc_realtime_process_stereo(xtc_realtime *, const float *input, const float *audio_left,
|
||||
const float *audio_right, const float *midi_left, const float *midi_right,
|
||||
float *left, float *right, size_t frames);
|
||||
xtc_result xtc_realtime_process_sources(xtc_realtime *engine, const float *input, const float *timeline,
|
||||
const float *instrument, float *output, size_t frames);
|
||||
xtc_result xtc_realtime_process_audio(xtc_realtime *engine, const float *input, const float *timeline,
|
||||
float *output, size_t frames);
|
||||
xtc_result xtc_realtime_process(xtc_realtime *engine, const float *input,
|
||||
float *output, size_t frame_count);
|
||||
const float *instrument, float *output, size_t frames);
|
||||
xtc_result xtc_realtime_process_audio(xtc_realtime *engine, const float *input, const float *timeline, float *output,
|
||||
size_t frames);
|
||||
xtc_result xtc_realtime_process(xtc_realtime *engine, const float *input, float *output, size_t frame_count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue