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

View file

@ -7,7 +7,7 @@
typedef struct {
uint64_t sample, tick;
size_t track;
unsigned int parameter;
unsigned int parameter, step;
float value;
} xtc_mix_point;

View file

@ -55,7 +55,7 @@ xtc_result xtc_project_set_mix(xtc_project *p, uint64_t id, float gain, float pa
xtc_result xtc_project_set_automation(xtc_project *p, const xtc_automation_point *a)
{
size_t i;
if (!p || !a || !isfinite(a->value) || a->tick > XTC_PROJECT_MAX_TICK ||
if (!p || !a || a->step > 1 || !isfinite(a->value) || a->tick > XTC_PROJECT_MAX_TICK ||
(a->parameter != XTC_AUTOMATION_GAIN && a->parameter != XTC_AUTOMATION_PAN) ||
a->value < (a->parameter == XTC_AUTOMATION_GAIN ? 0 : -1) ||
a->value > (a->parameter == XTC_AUTOMATION_GAIN ? 4 : 1))

View file

@ -63,6 +63,7 @@ xtc_result xtc_mix_prepare(const xtc_project *p, unsigned int rate, xtc_mix_snap
return XTC_ERR_INVALID_STATE;
b->tick = a->tick;
b->value = a->value;
b->step = a->step;
r = xtc_project_tick_to_sample(p, a->tick, rate, &b->sample);
if (r != XTC_OK)
return r;
@ -102,8 +103,8 @@ static float value(const xtc_mix_snapshot *m, size_t track, unsigned int param,
}
if (!low)
return p[0].value;
if (low == count)
return p[count - 1].value;
if (low == count || p[low-1].step)
return p[low - 1].value;
return (float)(p[low - 1].value + ((double)sample - (double)p[low - 1].sample) /
(double)(p[low].sample - p[low - 1].sample) *
(p[low].value - p[low - 1].value));