xtc/tests/integration/test_juce_plugin.c

30 lines
1.4 KiB
C
Raw Permalink Normal View History

2026-11-06 18:29:35 +01:00
/* Exercise the JUCE-built VST3 through xtc's existing C host, not JUCE's host. */
#include "xtc/xtc_plugin.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
int main(int argc,char **argv)
{
xtc_plugin_spec spec;
xtc_plugin *plugin=NULL;
xtc_midi_event events[]={{13,XTC_MIDI_NOTE_ON,0,69,100},{200,XTC_MIDI_ALL_OFF,0,0,0}};
float data[256]; size_t i, block; float peak=0;
assert(argc==2 && argv[1][0]=='/');
assert(xtc_plugin_probe_format(XTC_PLUGIN_VST3,argv[1],0,48000,&spec)==XTC_OK);
assert(spec.instrument && spec.inputs==0 && spec.format==XTC_PLUGIN_VST3);
assert(xtc_plugin_create(&spec,48000,256,&plugin)==XTC_OK);
assert(xtc_plugin_process_midi(plugin,events,2,data,256)==XTC_OK);
for(i=0;i<13;++i)assert(data[i]==0);
for(i=13;i<200;++i){assert(isfinite(data[i]));if(fabsf(data[i])>peak)peak=fabsf(data[i]);}
assert(peak>.005f);
/* The C VST3 host maps ALL_OFF to individual note-offs, allowing release. */
for(i=200;i<256;++i)assert(isfinite(data[i]));
for(block=0;block<200;++block) {
assert(xtc_plugin_process_midi(plugin,NULL,0,data,256)==XTC_OK);
for(i=0;i<256;++i)assert(isfinite(data[i]));
}
for(i=0;i<256;++i)assert(data[i]==0);
xtc_plugin_destroy(plugin);
puts("JUCE VST3 loaded through the xtc C host: identity, mono negotiation, MIDI offsets, note-off release and eventual silence passed.");
return 0;
}