feat(presets): add creative internal effect chain templates (phase 94)

This commit is contained in:
Johannes Findeisen 2026-11-06 02:06:27 +01:00
commit c65ac61a98
7 changed files with 62 additions and 4 deletions

View file

@ -39,6 +39,10 @@ class TrackInsertsPanel : public Fl_Group {
add->add("Internal Delay",0,[](Fl_Widget *,void *c){static_cast<TrackInsertsPanel *>(c)->add(XTC_BUILTIN_PATH,2);},this);
add->add("Internal Reverb",0,[](Fl_Widget *,void *c){static_cast<TrackInsertsPanel *>(c)->add(XTC_BUILTIN_PATH,3);},this);
add->add("Plugin library...",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);std::string file;if(!xtc_choose_plugin_file(p->owner_->settings(),file))return;unsigned int index=0;if(xtc_choose_plugin(file.c_str(),p->owner_->sample_rate(),index))p->add(file.c_str(),index);},this);
for(unsigned int preset=0;preset<3;++preset) {
std::string label=std::string("Templates (replace)/")+xtc_track_chain_template_name(preset);
add->add(label.c_str(),0,[](Fl_Widget *w,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);auto *menu=static_cast<Fl_Menu_Button *>(w);unsigned int index=0;for(;index<3;++index)if(!strcmp(menu->mvalue()->label(),xtc_track_chain_template_name(index)))break;p->result(p->apply_template(index));},this);
}
struct Action {const char *name;int command;};
int left=x+486;
for(const auto &action:{Action{"Up",-1},Action{"Down",1},Action{"Bypass",2},Action{"Remove",3}}) {
@ -73,6 +77,11 @@ 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 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);
return r;
}
void clear_session() {clipboard_={};clipboard_ready_=false;for(auto &slot:comparisons_)slot=Comparison{};update_actions();}
bool clipboard_ready() const {return clipboard_ready_;}
bool comparison_ready(unsigned int slot) const {return slot<2 && comparisons_[slot].ready && comparisons_[slot].track==track_;}

View file

@ -9,3 +9,25 @@ xtc_result xtc_track_chain_duplicate(const xtc_track_chain *chain,size_t index,x
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;
}
const char *xtc_track_chain_template_name(unsigned int index)
{
static const char *names[]={"Slapback","Dub Echo","Ambient Space"};
return index<3 ? names[index] : NULL;
}
xtc_result xtc_track_chain_template(unsigned int index,unsigned int tempo,xtc_track_chain *out)
{
xtc_track_chain c={0};size_t i;xtc_result r=XTC_OK;
if(!out || index>=3 || tempo<20000 || tempo>300000)return XTC_ERR_INVALID_ARGUMENT;
c.output_gain=index ? .8f : 1;c.count=index ? 2 : 1;
for(i=0;r==XTC_OK && i<c.count;++i) {
unsigned int device=index==2 ? (i ? 2U : 3U) : (i ? 3U : 2U);
r=xtc_plugin_probe_format(XTC_PLUGIN_BUILTIN,XTC_BUILTIN_PATH,device,48000,&c.slots[i].plugin);
c.slots[i].enabled=1;c.slots[i].wet=1;c.slots[i].plugin.tempo=tempo;
}
if(r!=XTC_OK)return r;
if(index==0){c.slots[0].plugin.values[0]=80;c.slots[0].plugin.values[1]=.1f;c.slots[0].plugin.values[2]=.3f;}
if(index==1){c.slots[0].plugin.values[0]=375;c.slots[0].plugin.values[1]=.65f;c.slots[0].plugin.values[2]=.4f;c.slots[1].plugin.values[0]=.55f;c.slots[1].plugin.values[1]=.5f;c.slots[1].plugin.values[2]=.15f;}
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;
}