#include "xtc/xtc.h" #include "xtc/xtc_engine.h" #include #include #define CHECK(condition) do { \ if (!(condition)) { \ (void)fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #condition); \ return 1; \ } \ } while (0) int main(void) { xtc_app *app = NULL; xtc_graph *graph = NULL; size_t node_a = 0U; size_t node_b = 0U; float input[4] = {1.0f, -1.0f, 0.5f, 0.0f}; float output[4] = {0.0f, 0.0f, 0.0f, 0.0f}; CHECK(xtc_app_create(&app) == XTC_OK); CHECK(app != NULL); xtc_app_destroy(app); CHECK(xtc_graph_create(4U, &graph) == XTC_OK); CHECK(xtc_graph_add_gain(graph, 0.5f, &node_a) == XTC_OK); CHECK(xtc_graph_add_gain(graph, 2.0f, &node_b) == XTC_OK); CHECK(xtc_graph_connect(graph, node_a, node_b) == XTC_OK); CHECK(xtc_graph_validate(graph) == XTC_OK); CHECK(xtc_graph_process_offline(graph, input, output, 4U, 1.0f) == XTC_OK); CHECK(fabsf(output[0] - 1.0f) < 0.0001f); CHECK(fabsf(output[1] + 1.0f) < 0.0001f); CHECK(fabsf(output[2] - 0.5f) < 0.0001f); CHECK(xtc_graph_connect(graph, node_b, node_a) == XTC_ERR_GRAPH_CYCLE); CHECK(xtc_graph_validate(graph) == XTC_OK); xtc_graph_destroy(graph); (void)puts("All xtc core tests passed."); return 0; }