Added tons of documentation headers to functions in source files.

This commit is contained in:
Johannes Findeisen 2026-10-27 01:58:27 +01:00
commit 4eb2080933
43 changed files with 3953 additions and 43 deletions

View file

@ -17,8 +17,32 @@ typedef struct {
int any_solo;
} xtc_mix_snapshot;
xtc_result xtc_mix_prepare(const xtc_project *, unsigned int rate, xtc_mix_snapshot *);
size_t xtc_mix_track(const xtc_mix_snapshot *, uint64_t id);
/**
* @brief Builds a render-ready snapshot from a project's mix and automation.
*
* @param project Project to snapshot; borrowed and not modified.
* @param rate Sample rate used for automation tick conversion.
* @param m Receives the snapshot.
* @return XTC_OK on success, or a validation/conversion error.
*/
xtc_result xtc_mix_prepare(const xtc_project * project, unsigned int rate, xtc_mix_snapshot * m);
/**
* @brief Finds the dense index of a snapshot track by stable identifier.
*
* @param m Mixer snapshot.
* @param id Stable identifier of the object to find or edit.
* @return Dense track index, or SIZE_MAX if absent.
*/
size_t xtc_mix_track(const xtc_mix_snapshot * m, uint64_t id);
/* side 0/1 stereo, 2 mono (gain only). */
float xtc_mix_level(const xtc_mix_snapshot *, size_t track, uint64_t sample, unsigned int side);
/**
* @brief Evaluates track gain, pan, mute, solo, and automation at a sample position.
*
* @param m Mixer snapshot.
* @param track Dense snapshot track index.
* @param sample Absolute sample position.
* @param side Output side: 0 for left, 1 for right, 2 for mono gain only.
* @return Linear level for the chosen side, or zero for an absent or inaudible track.
*/
float xtc_mix_level(const xtc_mix_snapshot * m, size_t track, uint64_t sample, unsigned int side);
#endif

View file

@ -2,6 +2,13 @@
#include <math.h>
#include <string.h>
/**
* @brief Finds the dense index of a project track by stable ID.
*
* @param p Project to search; must not be NULL.
* @param id Stable track identifier.
* @return Dense track index, or SIZE_MAX when no track has the ID.
*/
static size_t find_track(const xtc_project *p, uint64_t id)
{
size_t i;
@ -11,6 +18,17 @@ static size_t find_track(const xtc_project *p, uint64_t id)
return SIZE_MAX;
}
/**
* @brief Sets a track's gain, pan, mute, and solo controls after validation.
*
* @param p Project model; borrowed for this call.
* @param id Stable identifier of the object to find or edit.
* @param gain Linear gain, 0 to 4 for track controls.
* @param pan Pan position from -1 (left) to 1 (right).
* @param mute Track mute flag, 0 or 1.
* @param solo Track solo flag, 0 or 1.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_set_mix(xtc_project *p, uint64_t id, float gain, float pan, int mute, int solo)
{
size_t i;
@ -27,6 +45,13 @@ xtc_result xtc_project_set_mix(xtc_project *p, uint64_t id, float gain, float pa
return XTC_OK;
}
/**
* @brief Inserts an automation point, replacing any point at the same track, parameter, and tick.
*
* @param p Project model; borrowed for this call.
* @param a Automation point to read or update.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_set_automation(xtc_project *p, const xtc_automation_point *a)
{
size_t i;
@ -49,6 +74,15 @@ xtc_result xtc_project_set_automation(xtc_project *p, const xtc_automation_point
return XTC_OK;
}
/**
* @brief Removes the automation point at the specified track, parameter, and tick.
*
* @param p Project model; borrowed for this call.
* @param id Stable identifier of the object to find or edit.
* @param param Automation lane selector.
* @param tick Musical position in ticks.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_remove_automation(xtc_project *p, uint64_t id, xtc_automation_parameter param, uint64_t tick)
{
size_t i;
@ -63,6 +97,13 @@ xtc_result xtc_project_remove_automation(xtc_project *p, uint64_t id, xtc_automa
return XTC_OK;
}
/**
* @brief Copies the number of automation points in the project.
*
* @param p Project model; borrowed for this call.
* @param n Receives the item count.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_automation_count(const xtc_project *p, size_t *n)
{
if (!p || !n)
@ -71,6 +112,14 @@ xtc_result xtc_project_automation_count(const xtc_project *p, size_t *n)
return XTC_OK;
}
/**
* @brief Copies an automation point selected by dense list index.
*
* @param p Project model; borrowed for this call.
* @param i Zero-based index in the dense list.
* @param a Automation point to read or update.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_get_automation(const xtc_project *p, size_t i, xtc_automation_point *a)
{
if (!p || !a)

View file

@ -2,6 +2,13 @@
#include <stdlib.h>
#include <string.h>
/**
* @brief Finds the dense index of a snapshot track by stable ID.
*
* @param m Snapshot to search; must not be NULL.
* @param id Stable track identifier.
* @return Dense track index, or SIZE_MAX when the ID is absent.
*/
size_t xtc_mix_track(const xtc_mix_snapshot *m, uint64_t id)
{
size_t i;
@ -11,6 +18,13 @@ size_t xtc_mix_track(const xtc_mix_snapshot *m, uint64_t id)
return SIZE_MAX;
}
/**
* @brief Orders automation points by track, parameter, then musical tick.
*
* @param left Borrowed sort element to compare.
* @param right Borrowed sort element to compare.
* @return Negative, zero, or positive according to track, parameter, and tick ordering.
*/
static int compare(const void *left, const void *right)
{
const xtc_mix_point *a = left, *b = right;
@ -21,6 +35,14 @@ static int compare(const void *left, const void *right)
return a->tick < b->tick ? -1 : a->tick != b->tick;
}
/**
* @brief Copies track controls and compiles sorted automation lanes into sample positions.
*
* @param p Project model; borrowed for this call.
* @param rate Sample rate in hertz.
* @param m Mixer snapshot.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_mix_prepare(const xtc_project *p, unsigned int rate, xtc_mix_snapshot *m)
{
size_t i;
@ -55,6 +77,15 @@ xtc_result xtc_mix_prepare(const xtc_project *p, unsigned int rate, xtc_mix_snap
return XTC_OK;
}
/**
* @brief Evaluates a static mixer value or linearly interpolates its automation lane.
*
* @param m Mixer snapshot.
* @param track Dense snapshot track index.
* @param param Automation lane selector.
* @param sample Absolute sample position.
* @return Interpolated automation value, or the track control when its lane is empty.
*/
static float value(const xtc_mix_snapshot *m, size_t track, unsigned int param, uint64_t sample)
{
size_t low = 0, high = m->lengths[track][param], count = high;
@ -77,6 +108,15 @@ static float value(const xtc_mix_snapshot *m, size_t track, unsigned int param,
(p[low].value - p[low - 1].value));
}
/**
* @brief Evaluates track gain, pan, mute, solo, and automation at a sample position.
*
* @param m Mixer snapshot.
* @param track Dense snapshot track index.
* @param sample Absolute sample position.
* @param side Output side: 0 for left, 1 for right, 2 for mono gain only.
* @return Linear level for the chosen side, or zero for an absent or inaudible track.
*/
float xtc_mix_level(const xtc_mix_snapshot *m, size_t track, uint64_t sample, unsigned int side)
{
float gain, pan;