57 lines
2.3 KiB
C
57 lines
2.3 KiB
C
#ifndef XTC_MIX_INTERNAL_H
|
|
#define XTC_MIX_INTERNAL_H
|
|
|
|
#include "../project/project_internal.h"
|
|
#include "xtc/xtc_audio.h"
|
|
|
|
typedef struct {
|
|
uint64_t sample, tick;
|
|
size_t track;
|
|
unsigned int parameter, step;
|
|
float value;
|
|
} xtc_mix_point;
|
|
|
|
typedef struct {
|
|
xtc_track_info tracks[XTC_PROJECT_MAX_TRACKS];
|
|
size_t count, offsets[XTC_PROJECT_MAX_TRACKS][2], lengths[XTC_PROJECT_MAX_TRACKS][2];
|
|
xtc_mix_point points[XTC_MAX_AUTOMATION_POINTS];
|
|
int any_solo;
|
|
size_t bus[XTC_PROJECT_MAX_TRACKS];
|
|
} xtc_mix_snapshot;
|
|
|
|
/**
|
|
* @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). */
|
|
/**
|
|
* @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 xtc_mix_leaf_level(const xtc_mix_snapshot *m, size_t track, uint64_t sample, unsigned int side);
|
|
/* Borrowed control-installed scratch: 2*track_count channels, stride frames.
|
|
* Clear once per callback before audio+MIDI rendering. No pointer changes active. */
|
|
void xtc_audio_plan_monitor(xtc_audio_plan *plan, float *samples, size_t stride);
|
|
void xtc_midi_plan_monitor(xtc_midi_plan *plan, float *samples, size_t stride);
|
|
void xtc_mix_monitor(const xtc_mix_snapshot *mix, float *samples, size_t stride, size_t track,
|
|
uint64_t position, size_t frame, float sample, int stereo);
|
|
#endif
|