feat: plan composition phases and persist named arrangement markers

This commit is contained in:
Johannes Findeisen 2026-11-06 00:29:48 +01:00
commit 64e5ab170f
19 changed files with 323 additions and 9 deletions

View file

@ -529,6 +529,9 @@ 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;
if(project->marker_count>XTC_PROJECT_MAX_MARKERS)return XTC_ERR_FORMAT;
for(i=0;i<project->marker_count;++i)if(project->markers[i].tick>XTC_PROJECT_MAX_TICK ||
!xtc_project_valid_name(project->markers[i].name) || (i && project->markers[i-1].tick>=project->markers[i].tick))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;

View file

@ -8,6 +8,8 @@
struct xtc_project {
xtc_graph *graph;
size_t marker_count;
xtc_marker markers[XTC_PROJECT_MAX_MARKERS];
uint64_t live_instrument;
xtc_plugin_spec instruments[XTC_PROJECT_MAX_TRACKS];
uint64_t next_track_id, next_clip_id;

33
src/project/sections.c Normal file
View file

@ -0,0 +1,33 @@
#include "project_internal.h"
#include <string.h>
xtc_result xtc_project_marker_count(const xtc_project *p,size_t *out)
{
if(!p || !out)return XTC_ERR_INVALID_ARGUMENT;
*out=p->marker_count;return XTC_OK;
}
xtc_result xtc_project_get_marker(const xtc_project *p,size_t index,xtc_marker *out)
{
if(!p || !out)return XTC_ERR_INVALID_ARGUMENT;
if(index>=p->marker_count)return XTC_ERR_NOT_FOUND;
*out=p->markers[index];return XTC_OK;
}
xtc_result xtc_project_set_marker(xtc_project *p,uint64_t tick,const char *name)
{
size_t i;xtc_marker marker;
if(!p || tick>XTC_PROJECT_MAX_TICK || !xtc_project_valid_name(name))return XTC_ERR_INVALID_ARGUMENT;
memset(&marker,0,sizeof(marker));marker.tick=tick;memcpy(marker.name,name,strlen(name)+1);
for(i=0;i<p->marker_count && p->markers[i].tick<tick;++i){}
if(i<p->marker_count && p->markers[i].tick==tick){p->markers[i]=marker;return XTC_OK;}
if(p->marker_count==XTC_PROJECT_MAX_MARKERS)return XTC_ERR_CAPACITY;
memmove(p->markers+i+1,p->markers+i,(p->marker_count-i)*sizeof(marker));
p->markers[i]=marker;++p->marker_count;return XTC_OK;
}
xtc_result xtc_project_remove_marker(xtc_project *p,uint64_t tick)
{
size_t i;if(!p)return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<p->marker_count;++i)if(p->markers[i].tick==tick)break;
if(i==p->marker_count)return XTC_ERR_NOT_FOUND;
memmove(p->markers+i,p->markers+i+1,(p->marker_count-i-1)*sizeof(*p->markers));
--p->marker_count;return XTC_OK;
}