Phase 1 plus some refactoring.
This commit is contained in:
parent
71f7b4d96b
commit
8075e1b79d
17 changed files with 465 additions and 266 deletions
|
|
@ -11,13 +11,13 @@ extern "C" {
|
|||
#define XTC_VERSION_MINOR 1
|
||||
#define XTC_VERSION_PATCH 0
|
||||
|
||||
typedef struct xt_app xt_app;
|
||||
typedef struct xtc_app xtc_app;
|
||||
|
||||
/* Creates an application context. On success, *out_app is caller-owned. */
|
||||
xt_result xt_app_create(xt_app **out_app);
|
||||
xtc_result xtc_app_create(xtc_app **out_app);
|
||||
|
||||
/* Destroys an application context; NULL is accepted. */
|
||||
void xt_app_destroy(xt_app *app);
|
||||
void xtc_app_destroy(xtc_app *app);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,33 +7,81 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct xt_graph xt_graph;
|
||||
typedef struct xtc_graph xtc_graph;
|
||||
|
||||
typedef enum {
|
||||
XT_SIGNAL_AUDIO = 1,
|
||||
XT_SIGNAL_EVENT = 2,
|
||||
XT_SIGNAL_CONTROL = 3
|
||||
} xt_signal_type;
|
||||
XTC_SIGNAL_AUDIO = 1,
|
||||
XTC_SIGNAL_EVENT = 2,
|
||||
XTC_SIGNAL_CONTROL = 3
|
||||
} xtc_signal_type;
|
||||
|
||||
typedef enum {
|
||||
XT_PORT_INPUT = 1,
|
||||
XT_PORT_OUTPUT = 2
|
||||
} xt_port_direction;
|
||||
XTC_PORT_INPUT = 1,
|
||||
XTC_PORT_OUTPUT = 2
|
||||
} xtc_port_direction;
|
||||
|
||||
typedef struct {
|
||||
float *samples;
|
||||
size_t frame_count;
|
||||
size_t channel_count;
|
||||
} xt_audio_buffer;
|
||||
} xtc_audio_buffer;
|
||||
|
||||
/* Graph API is intentionally small in this first scaffold. */
|
||||
xt_result xt_graph_create(size_t max_nodes, xt_graph **out_graph);
|
||||
void xt_graph_destroy(xt_graph *graph);
|
||||
xt_result xt_graph_add_gain(xt_graph *graph, float gain, size_t *out_node_id);
|
||||
xt_result xt_graph_connect(xt_graph *graph, size_t source_node,
|
||||
typedef struct xtc_plan xtc_plan;
|
||||
|
||||
typedef enum {
|
||||
XTC_NODE_GAIN = 1,
|
||||
XTC_NODE_OSCILLATOR,
|
||||
XTC_NODE_METER,
|
||||
XTC_NODE_OUTPUT
|
||||
} xtc_node_type;
|
||||
|
||||
typedef struct {
|
||||
xtc_port_direction direction;
|
||||
xtc_signal_type signal_type;
|
||||
size_t channel_count;
|
||||
} xtc_port_info;
|
||||
|
||||
/* Control-thread API. Limits: 256 nodes, mono audio only. IDs are stable
|
||||
* insertion indexes. Output parameters are written only on success, except
|
||||
* create/compile which set their output pointer to NULL on failure. */
|
||||
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);
|
||||
xt_result xt_graph_validate(const xt_graph *graph);
|
||||
xt_result xt_graph_process_offline(xt_graph *graph, const float *input,
|
||||
/* Port 0 is input; port 1 is output. Oscillators 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_add_meter(xtc_graph *graph, size_t *out_node_id);
|
||||
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);
|
||||
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.
|
||||
* output must hold frame_count floats; input may equal output. On invalid
|
||||
* arguments output and DSP state are unchanged. Zero frames is a no-op.
|
||||
* Sums explicit output nodes; if absent, sums terminal nodes for compatibility.
|
||||
* Unconnected gain/meter/output inputs receive external input. */
|
||||
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. */
|
||||
xtc_result xtc_plan_meter_peak(const xtc_plan *plan, size_t node_id, float *out_peak);
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct xt_project xt_project;
|
||||
typedef struct xtc_project xtc_project;
|
||||
|
||||
/* Project persistence is not implemented in this scaffold yet. */
|
||||
xt_result xt_project_create(xt_project **out_project);
|
||||
void xt_project_destroy(xt_project *project);
|
||||
xt_result xt_project_save(const xt_project *project, const char *path);
|
||||
xt_result xt_project_load(xt_project *project, const char *path);
|
||||
xtc_result xtc_project_create(xtc_project **out_project);
|
||||
void xtc_project_destroy(xtc_project *project);
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef enum {
|
||||
XT_OK = 0,
|
||||
XT_ERR_INVALID_ARGUMENT,
|
||||
XT_ERR_OUT_OF_MEMORY,
|
||||
XT_ERR_NOT_FOUND,
|
||||
XT_ERR_INVALID_STATE,
|
||||
XT_ERR_IO,
|
||||
XT_ERR_UNSUPPORTED,
|
||||
XT_ERR_CAPACITY,
|
||||
XT_ERR_GRAPH_CYCLE
|
||||
} xt_result;
|
||||
XTC_OK = 0,
|
||||
XTC_ERR_INVALID_ARGUMENT,
|
||||
XTC_ERR_OUT_OF_MEMORY,
|
||||
XTC_ERR_NOT_FOUND,
|
||||
XTC_ERR_INVALID_STATE,
|
||||
XTC_ERR_IO,
|
||||
XTC_ERR_UNSUPPORTED,
|
||||
XTC_ERR_CAPACITY,
|
||||
XTC_ERR_GRAPH_CYCLE
|
||||
} xtc_result;
|
||||
|
||||
const char *xt_result_string(xt_result result);
|
||||
const char *xtc_result_string(xtc_result result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue