feat: navigate arrangement markers and loop named sections

This commit is contained in:
Johannes Findeisen 2026-11-06 00:31:08 +01:00
commit bd39eb1345
8 changed files with 71 additions and 5 deletions

View file

@ -31,3 +31,22 @@ xtc_result xtc_project_remove_marker(xtc_project *p,uint64_t tick)
memmove(p->markers+i,p->markers+i+1,(p->marker_count-i-1)*sizeof(*p->markers));
--p->marker_count;return XTC_OK;
}
xtc_result xtc_project_adjacent_marker(const xtc_project *p,uint64_t tick,int direction,xtc_marker *out)
{
size_t i;if(!p || !out || tick>XTC_PROJECT_MAX_TICK || (direction!=-1 && direction!=1))return XTC_ERR_INVALID_ARGUMENT;
if(direction>0){for(i=0;i<p->marker_count;++i)if(p->markers[i].tick>tick){*out=p->markers[i];return XTC_OK;}}
else for(i=p->marker_count;i>0;--i)if(p->markers[i-1].tick<tick){*out=p->markers[i-1];return XTC_OK;}
return XTC_ERR_NOT_FOUND;
}
xtc_result xtc_project_section(const xtc_project *p,uint64_t tick,uint64_t *begin,uint64_t *end)
{
size_t i,j;uint64_t finish=0;
if(!p || !begin || !end || begin==end || tick>XTC_PROJECT_MAX_TICK)return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<p->marker_count && p->markers[i].tick<=tick;++i){}
if(!i)return XTC_ERR_NOT_FOUND;
if(i<p->marker_count)finish=p->markers[i].tick;
else for(j=0;j<p->clip_count;++j)if(p->clips[j].start_tick+p->clips[j].length_tick>finish)finish=p->clips[j].start_tick+p->clips[j].length_tick;
if(finish<=p->markers[i-1].tick)return XTC_ERR_INVALID_STATE;
*begin=p->markers[i-1].tick;*end=finish;return XTC_OK;
}