42 lines
2.5 KiB
C
42 lines
2.5 KiB
C
#include "xtc/xtc_midi.h"
|
|
#include "xtc/xtc_audio.h"
|
|
#include "xtc/xtc_mixer.h"
|
|
#include <assert.h>
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
int main(void)
|
|
{
|
|
xtc_project *p = NULL; xtc_midi_plan *midi = NULL; xtc_audio_plan *audio = NULL;
|
|
xtc_graph *graph = NULL; xtc_plan *plan = NULL;
|
|
uint64_t tracks[XTC_PROJECT_MAX_TRACKS],clips[XTC_PROJECT_MAX_CLIPS],id;
|
|
size_t i,j,previous = 0,node; float left[31],right[31],out[31],other[31];
|
|
assert(xtc_project_create(&p) == XTC_OK);
|
|
for (i = 0; i < XTC_PROJECT_MAX_TRACKS; ++i) assert(xtc_project_add_track(p,"Scale",tracks+i) == XTC_OK);
|
|
assert(xtc_project_add_track(p,"Excess",&id) == XTC_ERR_CAPACITY);
|
|
for (i = 0; i < XTC_PROJECT_MAX_CLIPS; ++i) assert(xtc_project_add_midi_clip(p,tracks[i%64],i*4,4,clips+i) == XTC_OK);
|
|
assert(xtc_project_add_midi_clip(p,tracks[0],0,4,&id) == XTC_ERR_CAPACITY);
|
|
for (i = 0; i < XTC_PROJECT_MAX_NOTES; ++i) assert(xtc_project_add_note(p,clips[i%1024],i/1024,1,60,100,0,&id) == XTC_OK);
|
|
assert(xtc_project_add_note(p,clips[0],0,1,60,100,0,&id) == XTC_ERR_CAPACITY);
|
|
for (i = 0; i < XTC_MAX_AUTOMATION_POINTS; ++i) {
|
|
xtc_automation_point a = {tracks[i%64],i/64,XTC_AUTOMATION_GAIN,.1f,0};
|
|
assert(xtc_project_set_automation(p,&a) == XTC_OK);
|
|
}
|
|
{ xtc_automation_point a = {tracks[0],1000,XTC_AUTOMATION_GAIN,1,0}; assert(xtc_project_set_automation(p,&a) == XTC_ERR_CAPACITY); }
|
|
assert(xtc_graph_create(256,&graph) == XTC_OK && xtc_graph_add_instrument(graph,&previous) == XTC_OK);
|
|
for (i = 1; i < 256; ++i) {
|
|
assert((i == 255 ? xtc_graph_add_output(graph,&node) : xtc_graph_add_meter(graph,&node)) == XTC_OK);
|
|
assert(xtc_graph_connect(graph,previous,node) == XTC_OK); previous = node;
|
|
}
|
|
assert(xtc_graph_add_gain(graph,1,&node) == XTC_ERR_CAPACITY);
|
|
assert(xtc_graph_compile(graph,96000,31,&plan) == XTC_OK);
|
|
assert(xtc_midi_plan_create(p,96000,&midi) == XTC_OK && xtc_audio_plan_create(p,96000,&audio) == XTC_OK);
|
|
for (i = 0; i < 100; ++i) {
|
|
assert(xtc_midi_plan_render_stereo(midi,i*31,NULL,0,left,right,31) == XTC_OK);
|
|
assert(xtc_plan_process_stereo(plan,NULL,NULL,NULL,left,right,out,other,31) == XTC_OK);
|
|
for (j = 0; j < 31; ++j) assert(isfinite(out[j]) && out[j] == other[j]);
|
|
}
|
|
xtc_audio_plan_destroy(audio); xtc_midi_plan_destroy(midi); xtc_plan_destroy(plan);
|
|
xtc_graph_destroy(graph); xtc_project_destroy(p);
|
|
puts("64 tracks, 1024 clips/points, 4096 notes, 256 metered nodes and capacity failures passed.");
|
|
return 0;
|
|
}
|