feat: add tempo-synced stereo delay and coupled room reverb
This commit is contained in:
parent
35bf6a00a1
commit
7a01e2d2f3
12 changed files with 241 additions and 63 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "xtc/xtc_plugin.h"
|
||||
#include "xtc/xtc_dsp.h"
|
||||
#include "../../src/audio/wave_internal.h"
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -221,7 +222,51 @@ static void sampler(void)
|
|||
for(i=0;i<256;++i)assert(x[i]==0);
|
||||
xtc_plugin_destroy(a);unlink(preset);
|
||||
}
|
||||
static void stereo_effect(unsigned int id)
|
||||
{
|
||||
xtc_plugin_spec s;xtc_plugin *a=NULL,*b=NULL;float in[256]={0},zero[256]={0},l[256],r[256],x[256],y[256];
|
||||
size_t i,k;double left_energy=0,right_energy=0;
|
||||
assert(xtc_plugin_probe(XTC_BUILTIN_PATH,id,48000,&s)==XTC_OK);
|
||||
s.values[2]=1;
|
||||
s.point_count=2;s.points[0]=(xtc_plugin_point){0,0,1,id==5 ? 10 : .5f};
|
||||
s.points[1]=(xtc_plugin_point){960,0,1,id==5 ? 40 : .95f};
|
||||
if(id==5)s.values[1]=.9f;else {s.values[3]=1;s.values[4]=1;}
|
||||
assert(xtc_plugin_create(&s,48000,256,&a)==XTC_OK && xtc_plugin_create(&s,48000,256,&b)==XTC_OK);
|
||||
for(k=0;k<1200;++k) {
|
||||
in[0]=k==0 ? 1 : 0;
|
||||
assert(xtc_plugin_process_stereo_at(a,in,zero,l,r,256,k*256)==XTC_OK);
|
||||
assert(xtc_plugin_process_stereo_at(b,in,zero,x,y,128,k*256)==XTC_OK);
|
||||
assert(xtc_plugin_process_stereo_at(b,in+128,zero+128,x+128,y+128,128,k*256+128)==XTC_OK);
|
||||
assert(!memcmp(l,x,sizeof(l)) && !memcmp(r,y,sizeof(r)));
|
||||
for(i=0;i<256;++i){assert(isfinite(l[i]) && isfinite(r[i]) && fabsf(l[i])<=1 && fabsf(r[i])<=1);left_energy+=fabs(l[i]);right_energy+=fabs(r[i]);}
|
||||
}
|
||||
assert(left_energy>0 && right_energy>0);xtc_plugin_destroy(a);xtc_plugin_destroy(b);
|
||||
{
|
||||
xtc_graph *graph=NULL;xtc_plan *plan=NULL;size_t source,node,output;
|
||||
assert(xtc_graph_create(3,&graph)==XTC_OK);
|
||||
assert(xtc_graph_add_audio(graph,&source)==XTC_OK && xtc_graph_add_plugin(graph,&s,&node)==XTC_OK && xtc_graph_add_output(graph,&output)==XTC_OK);
|
||||
assert(xtc_graph_connect(graph,source,node)==XTC_OK && xtc_graph_connect(graph,node,output)==XTC_OK);
|
||||
assert(xtc_graph_compile(graph,48000,256,&plan)==XTC_OK);
|
||||
assert(xtc_plugin_create(&s,48000,256,&a)==XTC_OK);
|
||||
for(k=0;k<200;++k) {
|
||||
in[0]=k==0 ? 1 : 0;
|
||||
assert(xtc_plan_process_stereo(plan,NULL,in,zero,NULL,NULL,l,r,256)==XTC_OK);
|
||||
assert(xtc_plugin_process_stereo_at(a,in,zero,x,y,256,k*256)==XTC_OK);
|
||||
for(i=0;i<256;++i)assert(l[i]==xtc_dsp_finite(x[i]) && r[i]==xtc_dsp_finite(y[i]));
|
||||
}
|
||||
xtc_plugin_destroy(a);xtc_plan_destroy(plan);xtc_graph_destroy(graph);
|
||||
}
|
||||
if(id==5) {
|
||||
s.point_count=0;s.values[3]=1;s.values[1]=0;s.tempo=120000;
|
||||
assert(xtc_plugin_create(&s,48000,256,&a)==XTC_OK);
|
||||
for(k=0;k<100;++k) {
|
||||
in[0]=k==0 ? 1 : 0;
|
||||
assert(xtc_plugin_process_stereo_at(a,in,zero,l,r,256,k*256)==XTC_OK);
|
||||
for(i=0;i<256;++i)assert(l[i]==(k*256+i==24000 ? 1 : 0));
|
||||
}xtc_plugin_destroy(a);
|
||||
}
|
||||
}
|
||||
int main(void) {
|
||||
sampler();editable();transport(0);transport(1);automation();roundtrip(0,2);roundtrip(1,3);effects(2);effects(3);synth(0);synth(1);
|
||||
stereo_effect(5);stereo_effect(6);sampler();editable();transport(0);transport(1);automation();roundtrip(0,2);roundtrip(1,3);effects(2);effects(3);synth(0);synth(1);
|
||||
synth_partition(0);synth_partition(1);puts("Built-in devices passed.");return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue