feat: add a bounded WAV sampler with looping, relinking and saved presets

This commit is contained in:
Johannes Findeisen 2026-11-05 23:50:14 +01:00
commit 35bf6a00a1
24 changed files with 213 additions and 32 deletions

View file

@ -482,6 +482,15 @@ static xtc_result read_project(reader *input, xtc_project *project, const char *
a->step=(unsigned int)value;if(!decode_float(input->tokens[4],&a->value))return XTC_ERR_FORMAT;
}
}
if(format_version>=15U) {
READ("SAMPLE",2U);
if(strcmp(input->tokens[1],"-") && !decode_bytes(input->tokens[1],s->sample_path,sizeof(s->sample_path)))return XTC_ERR_FORMAT;
if(s->sample_path[0] && s->sample_path[0]!='/') {
size_t root=strlen(directory),len=strlen(s->sample_path);
if(root+len+2>sizeof(s->sample_path))return XTC_ERR_CAPACITY;
memmove(s->sample_path+root+1,s->sample_path,len+1);memcpy(s->sample_path,directory,root);s->sample_path[root]='/';
}
}
if (xtc_plugin_spec_validate(s) != XTC_OK) return XTC_ERR_FORMAT;
}
READ("LIVE_INSTRUMENT",2U); NUM(1U,project->live_instrument);
@ -654,6 +663,12 @@ static xtc_result write_project(FILE *file, const xtc_project *project, const ch
if(fprintf(file,"PARAM %" PRIu64 " %u %u %08" PRIx32 "\n",s->points[k].tick,s->points[k].port,s->points[k].step,bits)<0)return XTC_ERR_IO;
}
}
if(fputs("SAMPLE ",file)==EOF)return XTC_ERR_IO;
if(s->sample_path[0]) {
const char *asset=s->sample_path;size_t root=strlen(directory);
if(!strncmp(asset,directory,root) && asset[root]=='/' && asset[root+1])asset+=root+1;
if(!write_name(file,asset))return XTC_ERR_IO;
} else if(fputs("-\n",file)==EOF)return XTC_ERR_IO;
}
if (fprintf(file,"LIVE_INSTRUMENT %" PRIu64 "\n",project->live_instrument) < 0) return XTC_ERR_IO;
}