1
0
Fork 0
forked from hanez/xtc

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

130
src/control/model.c Normal file
View file

@ -0,0 +1,130 @@
#include "xtc/xtc_control.h"
#include "../project/project_internal.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
xtc_result xtc_project_get_control_map(const xtc_project *p, unsigned int channel, unsigned int out[3])
{
size_t i;
if (!p || !out || channel > 15) return XTC_ERR_INVALID_ARGUMENT;
for (i = 0; i < 3; ++i) out[i] = p->control_map[channel][i];
return XTC_OK;
}
xtc_result xtc_project_set_control_map(xtc_project *p, unsigned int channel, const unsigned int cc[3])
{
size_t i, j;
if (!p || !cc || channel > 15) return XTC_ERR_INVALID_ARGUMENT;
for (i = 0; i < 3; ++i) {
if (cc[i] > XTC_CC_DISABLED || cc[i] == 120 || cc[i] == 123) return XTC_ERR_INVALID_ARGUMENT;
for (j = 0; j < i; ++j) if (cc[i] != XTC_CC_DISABLED && cc[i] == cc[j]) return XTC_ERR_INVALID_ARGUMENT;
}
for (i = 0; i < 3; ++i) p->control_map[channel][i] = (unsigned char)cc[i];
return XTC_OK;
}
xtc_result xtc_project_parameter(const xtc_project *p, xtc_parameter_key key, double rate, xtc_parameter_state *out)
{
xtc_parameter_state state = {0};
size_t i;
if (!p || !out || !isfinite(rate) || rate < 1 || rate > 768000) return XTC_ERR_INVALID_ARGUMENT;
state.info.id = key.parameter;
if (key.kind == XTC_PARAMETER_TRACK) {
xtc_track_info track;
xtc_result r = XTC_ERR_NOT_FOUND;
if (key.parameter > 1) return XTC_ERR_NOT_FOUND;
for (i = 0; i < p->track_count; ++i) if (p->tracks[i].id == key.owner) { track = p->tracks[i]; r = XTC_OK; break; }
if (r != XTC_OK) return r;
snprintf(state.info.name,sizeof(state.info.name),"%s",key.parameter ? "Pan" : "Gain");
snprintf(state.info.unit,sizeof(state.info.unit),"%s",key.parameter ? "balance" : "linear");
state.info.minimum = key.parameter ? -1 : 0;
state.info.maximum = key.parameter ? 1 : 4;
state.info.default_value = key.parameter ? 0 : 1;
state.value = key.parameter ? track.pan : track.gain;
state.flags = XTC_PLUGIN_BOUNDED_BELOW | XTC_PLUGIN_BOUNDED_ABOVE;
for (i = 0; i < p->automation_count; ++i)
if (p->automation[i].track_id == key.owner && (unsigned int)p->automation[i].parameter == key.parameter) state.automated = 1;
} else if (key.kind == XTC_PARAMETER_PLUGIN) {
xtc_plugin_spec spec;
xtc_plugin_details details;
xtc_result r;
if (key.owner > SIZE_MAX) return XTC_ERR_NOT_FOUND;
r = xtc_graph_get_plugin(p->graph,(size_t)key.owner,&spec);
if (r != XTC_OK) return r;
r = xtc_plugin_describe(&spec,rate,&details);
if (r != XTC_OK) return r;
for (i = 0; i < spec.control_count && spec.ports[i] != key.parameter; ++i) {}
if (i == spec.control_count) return XTC_ERR_NOT_FOUND;
state.info = details.parameters[i]; state.flags = details.flags[i]; state.value = spec.values[i];
for (i = 0; i < spec.point_count; ++i) if (spec.points[i].port == key.parameter) state.automated = 1;
} else if (key.kind == XTC_PARAMETER_LIVE) {
if (key.owner > 15 || key.parameter > 2) return XTC_ERR_NOT_FOUND;
snprintf(state.info.name,sizeof(state.info.name),"%s",key.parameter == 0 ? "Live volume" : key.parameter == 1 ? "Live pan" : "Live sustain");
snprintf(state.info.unit,sizeof(state.info.unit),"%s",key.parameter == 0 ? "linear" : key.parameter == 1 ? "balance" : "boolean");
state.info.minimum = key.parameter == 1 ? -1 : 0;
state.info.maximum = 1;
state.info.default_value = key.parameter == 0 ? 1 : 0;
state.value = state.info.default_value;
state.flags = XTC_PLUGIN_BOUNDED_BELOW | XTC_PLUGIN_BOUNDED_ABOVE | (key.parameter == 2 ? XTC_PLUGIN_TOGGLED : 0U);
} else return XTC_ERR_INVALID_ARGUMENT;
/* Keep all output untouched on failure. */
*out = state;
return XTC_OK;
}
static int valid_value(const xtc_parameter_state *state, float value)
{
return isfinite(value) && value >= state->info.minimum && value <= state->info.maximum &&
(!(state->flags & XTC_PLUGIN_INTEGER) || value == floorf(value)) &&
(!(state->flags & XTC_PLUGIN_TOGGLED) || value == 0 || value == 1);
}
xtc_result xtc_project_set_parameter(xtc_project *p, xtc_parameter_key key, double rate, float value)
{
xtc_parameter_state state;
xtc_result r = xtc_project_parameter(p,key,rate,&state);
size_t i;
if (r != XTC_OK) return r;
if (!valid_value(&state,value)) return XTC_ERR_INVALID_ARGUMENT;
if (key.kind == XTC_PARAMETER_TRACK) {
for (i = 0; i < p->track_count; ++i) if (p->tracks[i].id == key.owner) {
if (key.parameter) p->tracks[i].pan = value; else p->tracks[i].gain = value;
return XTC_OK;
}
} else if (key.kind == XTC_PARAMETER_PLUGIN) {
xtc_plugin_spec spec;
r = xtc_graph_get_plugin(p->graph,(size_t)key.owner,&spec);
if (r != XTC_OK) return r;
for (i = 0; i < spec.control_count; ++i) if (spec.ports[i] == key.parameter) spec.values[i] = value;
return xtc_graph_set_plugin(p->graph,(size_t)key.owner,&spec);
}
return XTC_ERR_UNSUPPORTED;
}
xtc_result xtc_project_automate(xtc_project *p, xtc_parameter_key key, double rate,
uint64_t tick, unsigned int step, float value, int remove)
{
xtc_parameter_state state;
xtc_result r = xtc_project_parameter(p,key,rate,&state);
if (r != XTC_OK) return r;
if ((remove != 0 && remove != 1) || tick > XTC_PROJECT_MAX_TICK) return XTC_ERR_INVALID_ARGUMENT;
if (key.kind == XTC_PARAMETER_LIVE) return XTC_ERR_UNSUPPORTED;
if (!remove && (step > 1 || !valid_value(&state,value) ||
(!step && (state.flags & (XTC_PLUGIN_INTEGER|XTC_PLUGIN_TOGGLED))))) return XTC_ERR_INVALID_ARGUMENT;
if (key.kind == XTC_PARAMETER_TRACK) {
xtc_automation_point point = {key.owner,tick,(xtc_automation_parameter)key.parameter,value,step};
return remove ? xtc_project_remove_automation(p,key.owner,point.parameter,tick) : xtc_project_set_automation(p,&point);
} else {
xtc_plugin_spec spec;
unsigned int i;
r = xtc_graph_get_plugin(p->graph,(size_t)key.owner,&spec);
if (r != XTC_OK) return r;
for (i = 0; i < spec.point_count; ++i) if (spec.points[i].port == key.parameter && spec.points[i].tick == tick) break;
if (remove) {
if (i == spec.point_count) return XTC_ERR_NOT_FOUND;
memmove(spec.points+i,spec.points+i+1,(spec.point_count-i-1)*sizeof(*spec.points));
--spec.point_count;
} else {
if (i == XTC_PLUGIN_POINTS) return XTC_ERR_CAPACITY;
spec.points[i] = (xtc_plugin_point){tick,key.parameter,step,value};
if (i == spec.point_count) ++spec.point_count;
}
return xtc_graph_set_plugin(p->graph,(size_t)key.owner,&spec);
}
}

View file

@ -73,6 +73,7 @@ MainWindow::MainWindow(bool prompt_unsaved)
menu->add("File/Save As", FL_CTRL + FL_SHIFT + 's', file_callback, this);
menu->add("File/Import WAV", FL_CTRL + 'i', audio_file_callback, this);
menu->add("File/Relink selected audio", 0, audio_file_callback, this);
menu->add("Audio/MIDI controller mapping", 0, control_map_callback, this);
menu->add("Audio/Panic", FL_F + 9, panic_callback, this);
menu->add("View/Piano roll", FL_CTRL + '4', piano_callback, this);
menu->add("Audio/Record WAV", FL_SHIFT + FL_F + 5, audio_file_callback, this);
@ -1366,6 +1367,36 @@ void MainWindow::history_callback(Fl_Widget *widget, void *context)
window->report_error("Undo/redo failed", r);
}
xtc_result MainWindow::set_control_map(unsigned int channel, const unsigned int controllers[3])
{
if (recorder_) return XTC_ERR_INVALID_STATE;
xtc_project *candidate = nullptr;
xtc_result r = xtc_project_clone(project_.get(),&candidate);
if (r == XTC_OK) r = xtc_project_set_control_map(candidate,channel,controllers);
if (r == XTC_OK) r = install_project(candidate,false);
if (r != XTC_OK) xtc_project_destroy(candidate); else mark_dirty();
return r;
}
void MainWindow::control_map_callback(Fl_Widget *, void *context)
{
auto *w = static_cast<MainWindow *>(context);
if (w->recorder_) { w->report_error("Stop recording before controller mapping",XTC_ERR_INVALID_STATE); return; }
unsigned int controllers[3]{};
std::string prompt = "Live sine MIDI bindings (channels 0..15; 128 disables). CC120/123 reserved.\n";
for (unsigned int channel = 0; channel < 16; ++channel) {
xtc_project_get_control_map(w->project_.get(),channel,controllers);
prompt += std::to_string(channel) + ": volume " + std::to_string(controllers[0]) +
", pan " + std::to_string(controllers[1]) + ", sustain " + std::to_string(controllers[2]) + "\n";
}
prompt += "Enter channel volume_CC pan_CC sustain_CC (distinct enabled CCs):";
const char *answer = fl_input("%s","0 7 10 64",prompt.c_str());
if (!answer) return;
unsigned int channel; char extra;
xtc_result r = std::sscanf(answer,"%u %u %u %u %c",&channel,controllers,controllers+1,controllers+2,&extra) == 4 ?
w->set_control_map(channel,controllers) : XTC_ERR_INVALID_ARGUMENT;
if (r != XTC_OK) w->report_error("Controller mapping rejected: check channel, unique CCs and reserved panic controllers",r);
}
xtc_result MainWindow::install_plugin_graph(xtc_graph *graph)
{
xtc_project *candidate = nullptr;
@ -1454,21 +1485,16 @@ xtc_result MainWindow::set_plugin_control(size_t id, unsigned int port, float va
xtc_result MainWindow::set_plugin_automation(size_t id, const xtc_plugin_point &point, bool remove)
{
if (recorder_) return XTC_ERR_INVALID_STATE;
double rate = 48000; xtc_backend_status status{};
if (ready_ && xtc_backend_get_status(backend_,&status) == XTC_OK) rate = status.sample_rate;
xtc_project *candidate = nullptr;
xtc_result r = xtc_project_clone(project_.get(),&candidate);
xtc_parameter_key key{XTC_PARAMETER_PLUGIN,static_cast<uint64_t>(id),point.port};
if (r == XTC_OK) r = xtc_project_automate(candidate,key,rate,point.tick,point.step,point.value,remove ? 1 : 0);
xtc_plugin_spec spec{};
xtc_result r = xtc_graph_get_plugin(xtc_project_graph(project_.get()),id,&spec);
if (r != XTC_OK) return r;
unsigned i;
for (i = 0; i < spec.point_count; ++i) if (spec.points[i].port == point.port && spec.points[i].tick == point.tick) break;
if (remove) {
if (i == spec.point_count) return XTC_ERR_NOT_FOUND;
for (unsigned j = i+1; j < spec.point_count; ++j) spec.points[j-1] = spec.points[j];
--spec.point_count;
} else {
if (i == XTC_PLUGIN_POINTS) return XTC_ERR_CAPACITY;
spec.points[i] = point;
if (i == spec.point_count) ++spec.point_count;
}
return apply_plugin_spec(id,spec);
if (r == XTC_OK) r = xtc_graph_get_plugin(xtc_project_graph(candidate),id,&spec);
xtc_project_destroy(candidate);
return r == XTC_OK ? apply_plugin_spec(id,spec) : r;
}
xtc_result MainWindow::apply_plugin_spec(size_t id, const xtc_plugin_spec &spec, bool replace)
{

View file

@ -8,6 +8,7 @@
#include "xtc/xtc_backend.h"
#include "xtc/xtc_mixer.h"
#include "xtc/xtc_plugin.h"
#include "xtc/xtc_control.h"
class GraphWidget;
class MixerWidget;
@ -20,6 +21,7 @@ class Fl_Tabs;
class MainWindow : public Fl_Double_Window {
public:
/* Control-thread plugin commands, transactional model adoption. */
xtc_result set_control_map(unsigned int channel, const unsigned int controllers[3]);
xtc_result add_plugin(const char *path, unsigned int index, size_t *id = nullptr);
xtc_result set_plugin_automation(size_t id, const xtc_plugin_point &point, bool remove = false);
xtc_result replace_plugin(size_t id, const char *path, unsigned int index);
@ -292,6 +294,7 @@ class MainWindow : public Fl_Double_Window {
* @param widget Triggering Fl_Menu_Bar whose selected label names the action.
* @param context MainWindow * owning the project and file path.
*/
static void control_map_callback(Fl_Widget *widget, void *context);
static void plugin_callback(Fl_Widget *widget, void *context);
xtc_result apply_plugin_spec(size_t id, const xtc_plugin_spec &spec, bool replace = false);
xtc_result install_plugin_graph(xtc_graph *graph);

View file

@ -1,4 +1,5 @@
#include "mixer_widget.hpp"
#include "xtc/xtc_control.h"
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Check_Button.H>
@ -88,6 +89,7 @@ class AutomationLane : public Fl_Widget {
if (it == points.end())
return points.back().value;
const auto &a = *(it - 1);
if (a.step) return a.value;
return a.value +
static_cast<float>(static_cast<double>(tick - a.tick) / static_cast<double>(it->tick - a.tick)) *
(it->value - a.value);
@ -222,6 +224,8 @@ MixerWidget::MixerWidget(int x, int y, int w, int h, xtc_project *p, BeforeEdit
start_->bounds(0, XTC_PROJECT_MAX_TICK - lane_ticks);
start_->step(3840);
start_->callback(select, this);
mode_ = new Fl_Choice(x + 705, y + 146, 150, 26, "Interpolation");
mode_->add("Linear|Hold (step)"); mode_->value(0);
auto *hint = new Fl_Box(x + 10, y + 180, w - 20, 24,
"Gain 0..4; pan -1 left / +1 right. M/S toggles; arrows change gain, "
"Shift+arrows pan; Up/Down selects track.");
@ -413,10 +417,9 @@ xtc_result MixerWidget::mix(float gain, float pan, int mute, int solo)
xtc_result MixerWidget::point(uint64_t tick, float value, bool remove)
{
xtc_result r = before_ ? before_(context_) : XTC_OK;
xtc_automation_point a{selected_track(), tick, parameter(), value};
xtc_parameter_key key{XTC_PARAMETER_TRACK,selected_track(),static_cast<unsigned int>(parameter())};
if (r == XTC_OK)
r = remove ? xtc_project_remove_automation(project_, a.track_id, a.parameter, tick)
: xtc_project_set_automation(project_, &a);
r = xtc_project_automate(project_,key,48000,tick,mode_->value() == 1 ? 1U : 0U,value,remove ? 1 : 0);
return changed(r);
}

View file

@ -143,7 +143,7 @@ class MixerWidget : public Fl_Group {
xtc_project *project_;
BeforeEdit before_;
void *context_;
Fl_Choice *tracks_, *parameter_, *routes_;
Fl_Choice *tracks_, *parameter_, *routes_, *mode_;
std::vector<uint64_t> route_ids_;
Fl_Value_Slider *gain_, *pan_;
Fl_Check_Button *mute_, *solo_;

View file

@ -30,6 +30,7 @@ struct xtc_midi_plan {
uint64_t monitor_position;
xtc_gain_ramp volume[16], pan[16];
unsigned int sustain[16];
unsigned char control_map[16][3];
xtc_mix_snapshot mix;
span notes[XTC_PROJECT_MAX_NOTES];
size_t count;
@ -39,7 +40,7 @@ struct xtc_midi_plan {
};
/**
* @brief Decodes a complete note or all-notes-off MIDI message into a block event.
* @brief Decodes a complete note, controller or all-notes-off MIDI message into a block event.
*
* @param bytes Borrowed MIDI message bytes.
* @param size Number of message bytes.
@ -58,8 +59,6 @@ xtc_result xtc_midi_decode(const unsigned char *bytes, size_t size, unsigned int
return XTC_ERR_UNSUPPORTED;
if (size != 3 || bytes[1] > 127 || bytes[2] > 127)
return XTC_ERR_INVALID_ARGUMENT;
if (command == 176 && bytes[1] != 120 && bytes[1] != 123 && bytes[1] != 7 && bytes[1] != 10 && bytes[1] != 64)
return XTC_ERR_UNSUPPORTED;
e.offset = offset;
e.channel = bytes[0] & 15U;
e.pitch = bytes[1];
@ -190,6 +189,7 @@ xtc_result xtc_midi_plan_create(const xtc_project *project, unsigned int rate, x
}
}
free(points);
memcpy(p->control_map,project->control_map,sizeof(p->control_map));
p->controller_frames = rate / 200U;
if (!p->controller_frames) p->controller_frames = 1;
xtc_midi_plan_reset(p);
@ -255,10 +255,10 @@ static void event(xtc_midi_plan *p, const xtc_midi_event *e, uint64_t position)
return;
}
if (e->type == XTC_MIDI_CONTROL) {
if (e->pitch == 7) (void)xtc_gain_ramp_target(p->volume+e->channel,(float)e->velocity/127.0f,p->controller_frames);
else if (e->pitch == 10) (void)xtc_gain_ramp_target(p->pan+e->channel,
if (e->pitch == p->control_map[e->channel][0]) (void)xtc_gain_ramp_target(p->volume+e->channel,(float)e->velocity/127.0f,p->controller_frames);
else if (e->pitch == p->control_map[e->channel][1]) (void)xtc_gain_ramp_target(p->pan+e->channel,
e->velocity >= 64 ? (float)(e->velocity-64)/63.0f : ((float)e->velocity-64)/64.0f,p->controller_frames);
else if (e->pitch == 64) {
else if (e->pitch == p->control_map[e->channel][2]) {
p->sustain[e->channel] = e->velocity >= 64;
if (!p->sustain[e->channel]) for (i = 0; i < XTC_MIDI_VOICES; ++i)
if (p->voices[i].channel == e->channel && p->voices[i].released) p->voices[i].active = 0;

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));

View file

@ -403,7 +403,7 @@ static xtc_result read_project(reader *input, xtc_project *project, const char *
project->automation_count = (size_t)value;
for (i = 0; i < project->automation_count; ++i) {
xtc_automation_point *a = project->automation + i;
READ("POINT", 5U);
READ("POINT", format_version >= 10U ? 6U : 5U);
NUM(1U, a->track_id);
NUM(2U, value);
if (value > 1)
@ -412,6 +412,22 @@ static xtc_result read_project(reader *input, xtc_project *project, const char *
NUM(3U, a->tick);
if (!decode_float(input->tokens[4], &a->value))
return XTC_ERR_FORMAT;
if (format_version >= 10U) {
NUM(5U,value); if (value > 1) return XTC_ERR_FORMAT;
a->step = (unsigned int)value;
}
}
}
if (format_version >= 10U) {
READ("CONTROL_MAPS",2U); NUM(1U,value);
if (value != 16) return XTC_ERR_FORMAT;
for (i = 0; i < 16; ++i) {
READ("MAP",5U); NUM(1U,value);
if (value != i) return XTC_ERR_FORMAT;
for (j = 0; j < 3; ++j) {
NUM(j+2,value); if (value > 128) return XTC_ERR_FORMAT;
project->control_map[i][j] = (unsigned char)value;
}
}
}
READ("END", 1U);
@ -549,10 +565,14 @@ static xtc_result write_project(FILE *file, const xtc_project *project, const ch
uint32_t bits;
const xtc_automation_point *a = project->automation + i;
memcpy(&bits, &a->value, sizeof(bits));
if (fprintf(file, "POINT %" PRIu64 " %u %" PRIu64 " %08" PRIx32 "\n", a->track_id, (unsigned int)a->parameter,
a->tick, bits) < 0)
if (fprintf(file, "POINT %" PRIu64 " %u %" PRIu64 " %08" PRIx32 " %u\n", a->track_id, (unsigned int)a->parameter,
a->tick, bits, a->step) < 0)
return XTC_ERR_IO;
}
if (fputs("CONTROL_MAPS 16\n",file) == EOF) return XTC_ERR_IO;
for (i = 0; i < 16; ++i)
if (fprintf(file,"MAP %zu %u %u %u\n",i,(unsigned int)project->control_map[i][0],
(unsigned int)project->control_map[i][1],(unsigned int)project->control_map[i][2]) < 0) return XTC_ERR_IO;
return fputs("END\n", file) == EOF ? XTC_ERR_IO : XTC_OK;
}

View file

@ -119,6 +119,13 @@ xtc_result xtc_project_create(xtc_project **out_project)
}
project->graph->require_output_nodes = 1;
project->tempo = 120000U;
{ size_t channel;
for (channel = 0; channel < 16; ++channel) {
project->control_map[channel][0] = 7;
project->control_map[channel][1] = 10;
project->control_map[channel][2] = 64;
}
}
*out_project = project;
return XTC_OK;
}
@ -516,6 +523,13 @@ xtc_result xtc_project_validate(const xtc_project *project)
if (project->tempo < 20000U || project->tempo > 300000U || project->track_count > XTC_PROJECT_MAX_TRACKS ||
project->clip_count > XTC_PROJECT_MAX_CLIPS || project->note_count > XTC_PROJECT_MAX_NOTES)
return XTC_ERR_FORMAT;
for (i = 0; i < 16; ++i) for (j = 0; j < 3; ++j) {
unsigned int cc = project->control_map[i][j];
size_t k;
if (cc > 128 || cc == 120 || cc == 123) return XTC_ERR_FORMAT;
for (k = 0; k < j; ++k)
if (cc != 128 && cc == project->control_map[i][k]) return XTC_ERR_FORMAT;
}
for (i = 0U; i < project->track_count; ++i) {
if (project->tracks[i].id >= project->next_track_id || !xtc_project_valid_name(project->tracks[i].name))
return XTC_ERR_FORMAT;
@ -577,7 +591,7 @@ xtc_result xtc_project_validate(const xtc_project *project)
}
for (i = 0; i < project->automation_count; ++i) {
const xtc_automation_point *a = project->automation + i;
if (track_index(project, a->track_id) == SIZE_MAX || a->tick > XTC_PROJECT_MAX_TICK || !isfinite(a->value) ||
if (track_index(project, a->track_id) == SIZE_MAX || a->tick > XTC_PROJECT_MAX_TICK || a->step > 1 || !isfinite(a->value) ||
(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

@ -9,6 +9,7 @@ struct xtc_project {
xtc_graph *graph;
uint64_t next_track_id, next_clip_id;
unsigned int tempo;
unsigned char control_map[16][3];
size_t track_count, clip_count;
uint64_t next_note_id;
size_t note_count;