feat(inserts): add bulk enable, bypass and clear actions (phase 95)

This commit is contained in:
Johannes Findeisen 2026-11-06 02:07:19 +01:00
commit 924821738d
7 changed files with 48 additions and 6 deletions

View file

@ -58,6 +58,9 @@ class TrackInsertsPanel : public Fl_Group {
gain_=new Fl_Value_Input(x+360,y+52,100,26,"Chain gain");gain_->bounds(0,4);gain_->step(.01);gain_->when(FL_WHEN_RELEASE);
for(auto *input:{wet_,gain_})input->callback([](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->set_mix(p->wet_->value(),p->gain_->value()));},this);
actions_=new Fl_Menu_Button(x+486,y+52,150,26,"Rack actions");
actions_->add("Enable all effects",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->bulk(XTC_CHAIN_ENABLE_ALL));},this);
actions_->add("Bypass all effects",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->bulk(XTC_CHAIN_BYPASS_ALL));},this);
actions_->add("Clear chain",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->bulk(XTC_CHAIN_CLEAR));},this);
actions_->add("Compare/Capture A",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->comparison(0,true));},this);
actions_->add("Compare/Recall A",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->comparison(0,false));},this,FL_MENU_INACTIVE);
actions_->add("Compare/Capture B",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->comparison(1,true));},this);
@ -77,6 +80,12 @@ class TrackInsertsPanel : public Fl_Group {
void select_track(uint64_t id) {track_=id;refresh(true);}
const xtc_graph *graph() const {return model_;}
void add(const char *file,unsigned int index) { result(owner_->add_track_effect(track_,file,index)); }
xtc_result bulk(xtc_chain_action action) {
xtc_track_chain chain{};auto r=xtc_project_get_chain(owner_->project_.get(),track_,&chain);
if(r==XTC_OK && !chain.count)return XTC_ERR_NOT_FOUND;
if(r==XTC_OK)r=xtc_track_chain_bulk(&chain,action,&chain);
return r==XTC_OK ? owner_->set_track_chain(track_,chain) : r;
}
xtc_result apply_template(unsigned int index) {
xtc_track_chain chain{};auto r=xtc_track_chain_template(index,xtc_project_tempo(owner_->project_.get()),&chain);
if(r==XTC_OK)r=owner_->set_track_chain(track_,chain);

View file

@ -31,3 +31,13 @@ xtc_result xtc_track_chain_template(unsigned int index,unsigned int tempo,xtc_tr
if(index==2){c.slots[0].plugin.values[0]=.88f;c.slots[0].plugin.values[1]=.6f;c.slots[0].plugin.values[2]=.6f;c.slots[1].plugin.values[0]=500;c.slots[1].plugin.values[1]=.35f;c.slots[1].plugin.values[2]=.25f;}
r=xtc_track_chain_validate(&c);if(r==XTC_OK)*out=c;return r;
}
xtc_result xtc_track_chain_bulk(const xtc_track_chain *chain,xtc_chain_action action,xtc_track_chain *out)
{
xtc_track_chain copy;size_t i;
if(!out || xtc_track_chain_validate(chain)!=XTC_OK || action<XTC_CHAIN_ENABLE_ALL || action>XTC_CHAIN_CLEAR)return XTC_ERR_INVALID_ARGUMENT;
copy=*chain;
if(action==XTC_CHAIN_CLEAR){copy.count=0;for(i=0;i<XTC_TRACK_INSERTS;++i)copy.slots[i]=(xtc_track_insert){0};}
else for(i=0;i<copy.count;++i)copy.slots[i].enabled=action==XTC_CHAIN_ENABLE_ALL;
*out=copy;return XTC_OK;
}