feat(presets): save and adopt reusable effect chains (phase 87)
This commit is contained in:
parent
eb71ca765f
commit
b6d0771b4f
8 changed files with 67 additions and 5 deletions
23
src/project/chain_preset.c
Normal file
23
src/project/chain_preset.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include "project_internal.h"
|
||||
/* Reuse the versioned atomic project container. No module loading occurs here. */
|
||||
xtc_result xtc_track_chain_preset_save(const xtc_track_chain *chain,const char *path)
|
||||
{
|
||||
xtc_project *p=NULL;uint64_t id;xtc_result r;
|
||||
if(!path || xtc_track_chain_validate(chain)!=XTC_OK)return XTC_ERR_INVALID_ARGUMENT;
|
||||
r=xtc_project_create(&p);
|
||||
if(r==XTC_OK)r=xtc_project_add_track(p,"Effect chain preset",&id);
|
||||
if(r==XTC_OK)r=xtc_project_set_chain(p,id,chain);
|
||||
if(r==XTC_OK)r=xtc_project_save(p,path);
|
||||
xtc_project_destroy(p);return r;
|
||||
}
|
||||
xtc_result xtc_track_chain_preset_load(const char *path,xtc_track_chain *out)
|
||||
{
|
||||
xtc_project *p=NULL;xtc_track_chain chain;xtc_result r;
|
||||
if(!path || !out)return XTC_ERR_INVALID_ARGUMENT;
|
||||
r=xtc_project_create(&p);
|
||||
if(r==XTC_OK)r=xtc_project_load(p,path);
|
||||
if(r==XTC_OK && (p->track_count!=1 || p->clip_count || p->tracks[0].is_bus || p->instruments[0].instrument))r=XTC_ERR_FORMAT;
|
||||
if(r==XTC_OK)r=xtc_project_get_chain(p,p->tracks[0].id,&chain);
|
||||
if(r==XTC_OK)*out=chain;
|
||||
xtc_project_destroy(p);return r;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue