feat: plan composition phases and persist named arrangement markers
This commit is contained in:
parent
1b668068de
commit
64e5ab170f
19 changed files with 323 additions and 9 deletions
|
|
@ -339,6 +339,8 @@ MainWindow::MainWindow(bool prompt_unsaved,const char *configuration)
|
|||
menu->add("Edit/Repeat selected phrase...",0,[](Fl_Widget *,void *c){static_cast<SequencerWidget *>(c)->repeat_dialog();},sequencer_);
|
||||
menu->add("Edit/Copy clips",0,[](Fl_Widget *,void *c){static_cast<SequencerWidget *>(c)->copy_selection();},sequencer_);
|
||||
menu->add("Edit/Paste clips at cursor",0,[](Fl_Widget *,void *c){static_cast<SequencerWidget *>(c)->paste_selection();},sequencer_);
|
||||
menu->add("Edit/Markers/Set at cursor...",0,[](Fl_Widget *,void *c){static_cast<SequencerWidget *>(c)->marker_dialog();},sequencer_);
|
||||
menu->add("Edit/Markers/Remove at cursor",0,[](Fl_Widget *,void *c){static_cast<SequencerWidget *>(c)->marker(nullptr);},sequencer_);
|
||||
menu->add("Edit/Select all clips",0,[](Fl_Widget *,void *c){static_cast<SequencerWidget *>(c)->select_all_clips();},sequencer_);
|
||||
menu->add("Edit/Duplicate clip",FL_CTRL+'d',[](Fl_Widget *, void *c) { (void)static_cast<SequencerWidget *>(c)->duplicate_selection(); },sequencer_);
|
||||
menu->add("Edit/Split audio at cursor", 0, [](Fl_Widget *, void *c) { (void)static_cast<SequencerWidget *>(c)->split_selection(); }, sequencer_);
|
||||
|
|
|
|||
|
|
@ -319,6 +319,14 @@ void SequencerWidget::draw()
|
|||
fl_color(loop_enabled_ ? xtc_ui::accent() : xtc_ui::muted());
|
||||
fl_rectf(left,y()+23,std::max(0,right-left),4);
|
||||
}
|
||||
size_t markers=0;xtc_project_marker_count(project_,&markers);
|
||||
for(size_t i=0;i<markers;++i) {
|
||||
xtc_marker marker{};xtc_project_get_marker(project_,i,&marker);
|
||||
int px=x()+header_width_+static_cast<int>(marker.tick*static_cast<unsigned int>(scale_)/960U);
|
||||
if(px<cx || px>cx+cw)continue;
|
||||
fl_color(xtc_ui::accent());fl_line(px,y()+24,px,y()+h());
|
||||
fl_push_clip(px,y(),160,12);fl_font(FL_HELVETICA,10);fl_draw(marker.name,px+3,y()+10);fl_pop_clip();
|
||||
}
|
||||
int playhead = x()+header_width_+static_cast<int>(cursor_*static_cast<unsigned int>(scale_)/960U);
|
||||
if (playhead >= cx && playhead <= cx+cw) {
|
||||
fl_color(xtc_ui::accent()); fl_line(playhead,y(),playhead,y()+h());
|
||||
|
|
@ -511,6 +519,16 @@ int SequencerWidget::handle(int event)
|
|||
return Fl_Group::handle(event);
|
||||
}
|
||||
|
||||
xtc_result SequencerWidget::marker(const char *name)
|
||||
{
|
||||
const uint64_t at=cursor_;xtc_result r=before_edit ? before_edit(context_) : XTC_OK;
|
||||
if(r==XTC_OK)r=name ? xtc_project_set_marker(project_,at,name) : xtc_project_remove_marker(project_,at);
|
||||
changed(r);return r;
|
||||
}
|
||||
void SequencerWidget::marker_dialog()
|
||||
{
|
||||
const char *name=fl_input("Marker at cursor (1..63 UTF-8 bytes)","Section");if(name)marker(name);
|
||||
}
|
||||
std::vector<uint64_t> SequencerWidget::selected_clips() const
|
||||
{
|
||||
std::vector<uint64_t> ids;xtc_clip_info c{};
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class SequencerWidget : public Fl_Group {
|
|||
Fl_Choice *instrument_choice(uint64_t track) const;
|
||||
void refresh_instruments();
|
||||
bool select(uint64_t track, uint64_t clip = UINT64_MAX);
|
||||
xtc_result marker(const char *name); /* NULL removes at cursor. */
|
||||
void marker_dialog();
|
||||
bool toggle_clip(uint64_t clip);
|
||||
void select_all_clips();
|
||||
bool clip_selected(uint64_t clip) const;
|
||||
|
|
|
|||
|
|
@ -495,6 +495,13 @@ static xtc_result read_project(reader *input, xtc_project *project, const char *
|
|||
}
|
||||
READ("LIVE_INSTRUMENT",2U); NUM(1U,project->live_instrument);
|
||||
}
|
||||
if(format_version>=16U) {
|
||||
READ("MARKERS",2U);NUM(1U,value);if(value>XTC_PROJECT_MAX_MARKERS)return XTC_ERR_FORMAT;
|
||||
project->marker_count=(size_t)value;
|
||||
for(i=0;i<project->marker_count;++i){READ("MARKER",3U);NUM(1U,project->markers[i].tick);
|
||||
if(!decode_name(input->tokens[2],project->markers[i].name))return XTC_ERR_FORMAT;
|
||||
}
|
||||
}
|
||||
READ("END", 1U);
|
||||
if (fgetc(input->file) != EOF)
|
||||
return XTC_ERR_FORMAT;
|
||||
|
|
@ -672,6 +679,8 @@ static xtc_result write_project(FILE *file, const xtc_project *project, const ch
|
|||
}
|
||||
if (fprintf(file,"LIVE_INSTRUMENT %" PRIu64 "\n",project->live_instrument) < 0) return XTC_ERR_IO;
|
||||
}
|
||||
if(fprintf(file,"MARKERS %zu\n",project->marker_count)<0)return XTC_ERR_IO;
|
||||
for(i=0;i<project->marker_count;++i)if(fprintf(file,"MARKER %" PRIu64 " ",project->markers[i].tick)<0 || !write_name(file,project->markers[i].name))return XTC_ERR_IO;
|
||||
return fputs("END\n", file) == EOF ? XTC_ERR_IO : XTC_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
33
src/project/sections.c
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue