Added automatic format conversion.
[aftubes.git] / main.c
blob45e1fe75d25b728354413b00909ed9020ba9408b
1 #include "stdio.h"
2 #include "soundout.h"
3 #include "wavefile.h"
4 #include "modules.h"
5 #include "graph.h"
6 #include "errors.h"
7 #include "assert.h"
9 #include "unistd.h"
10 #include "sys/types.h"
11 #include "signal.h"
13 void moan(err_t err)
15 if (err != EOK){
16 fprintf(stderr, "%s:%d: in function %s: %s\n",
17 get_last_error_file(),
18 get_last_error_line(),
19 get_last_error_func(),
20 get_last_error_message());
21 raise(SIGABRT);
25 int main(int argc, char **argv)
27 struct graph _graph, *graph = &_graph;
28 struct graphnode *node, *node_1, *node_2, *node_3;
29 err_t err;
31 if (graph_create(graph)){
32 fprintf(stderr, "cannot create graph\n");
33 return 1;
36 moan(wavesource_create(&node, "/home/aoe/reflections.wav"));
37 //moan(wavesource_create(&node, "/home/aoe/horizon.wav"));
38 assert(node);
39 moan(graph_add_node(graph, node));
40 node->name = "source";
41 node_1 = node;
43 moan(playsink_create(&node));
44 assert(node);
45 moan(graph_add_node(graph, node));
46 node->name = "sink";
47 node_2 = node;
49 moan(ringmod_create(&node));
50 assert(node);
51 moan(graph_add_node(graph, node));
52 node->name = "ringmod";
53 node_3 = node;
55 moan(graph_connect(graph, node_1->pins, node_3->pins));
56 moan(graph_connect(graph, node_3->pins->next, node_2->pins));
57 moan(graph_sort(graph));
60 struct graphnode *node;
61 for (node=graph->sorted_nodes; node; node=node->sorted_next){
62 printf("sorted_node: %s\n", node->name);
66 while ((err = graph_run(graph)) == EOK);
67 moan(err);
69 graph_destroy(graph);
72 return 0;