feat(inserts): duplicate effect slots with independent state (phase 91)
This commit is contained in:
parent
e6cf7023fb
commit
062b33f55f
8 changed files with 69 additions and 5 deletions
|
|
@ -17,6 +17,7 @@
|
|||
class TrackInsertsPanel : public Fl_Group {
|
||||
MainWindow *owner_;
|
||||
Fl_Choice *tracks_;
|
||||
Fl_Menu_Button *actions_;
|
||||
Fl_Hold_Browser *slots_;
|
||||
Fl_Box *message_;
|
||||
Fl_Value_Input *wet_,*gain_;
|
||||
|
|
@ -49,6 +50,8 @@ class TrackInsertsPanel : public Fl_Group {
|
|||
wet_=new Fl_Value_Input(x+110,y+52,100,26,"Insert wet");wet_->bounds(0,1);wet_->step(.01);wet_->when(FL_WHEN_RELEASE);
|
||||
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("Duplicate effect",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->duplicate_slot());},this);
|
||||
message_=new Fl_Box(x+16,y+84,w-32,30,"Track input > inserts > output gain > track fader > bus/master");message_->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
slots_=new Fl_Hold_Browser(x+16,y+126,230,h-142);slots_->format_char(0);slots_->callback([](Fl_Widget *,void *c){static_cast<TrackInsertsPanel *>(c)->update_mix();},this);
|
||||
scroll_=new Fl_Scroll(x+260,y+126,w-276,h-142);
|
||||
|
|
@ -61,6 +64,13 @@ 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 duplicate_slot() {
|
||||
xtc_track_chain chain{};auto r=xtc_project_get_chain(owner_->project_.get(),track_,&chain);size_t index=selected_slot();
|
||||
if(r==XTC_OK)r=xtc_track_chain_duplicate(&chain,index,&chain);
|
||||
if(r==XTC_OK)r=owner_->set_track_chain(track_,chain);
|
||||
if(r==XTC_OK){slots_->select(static_cast<int>(index+2));update_mix();}
|
||||
return r;
|
||||
}
|
||||
void update_mix() {
|
||||
xtc_track_chain chain{};if(xtc_project_get_chain(owner_->project_.get(),track_,&chain)!=XTC_OK){wet_->deactivate();gain_->deactivate();return;}
|
||||
gain_->activate();gain_->value(chain.output_gain);size_t index=selected_slot();
|
||||
|
|
|
|||
11
src/project/chain_tools.c
Normal file
11
src/project/chain_tools.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "xtc/xtc_plugin.h"
|
||||
/* Metadata transforms never load modules; aliases are safe and errors atomic. */
|
||||
xtc_result xtc_track_chain_duplicate(const xtc_track_chain *chain,size_t index,xtc_track_chain *out)
|
||||
{
|
||||
xtc_track_chain copy;size_t i;
|
||||
if(!out || xtc_track_chain_validate(chain)!=XTC_OK || index>=chain->count)return XTC_ERR_INVALID_ARGUMENT;
|
||||
if(chain->count==XTC_TRACK_INSERTS)return XTC_ERR_CAPACITY;
|
||||
copy=*chain;
|
||||
for(i=copy.count;i>index+1;--i)copy.slots[i]=copy.slots[i-1];
|
||||
copy.slots[index+1]=copy.slots[index];++copy.count;*out=copy;return XTC_OK;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue