Simple ring modulator (silly_effect)
[aftubes.git] / main.c
blobed6236e6bc6fc180b26ea40969c3679672febc09
1 #include "stdio.h"
2 #include "soundout.h"
3 #include "wavefile.h"
4 #include "effects.h"
6 int main(int argc, char **argv)
8 struct soundout so;
9 struct wavefile wf;
10 struct aformat af;
11 struct effect *ef1;
13 if (wavefile_open(&wf, "/home/aoe/reflections.wav") != 0){
14 fprintf(stderr, "cannot open wave file\n");
15 return 1;
18 af.srate = 44100;
19 af.bits = 16;
20 af.channels = 2;
22 if (soundout_open(&so, &af) != 0){
23 fprintf(stderr, "cannot open audio output device\n");
24 // wavefile_close
25 return 1;
28 ef1 = silly_effect_create();
30 unsigned int pos = 0;
31 char buf[4410 * 4];
32 void *buf_ptr = buf;
33 for (;;){
34 if (wavefile_read_at(&wf, pos, buf, 4410) != 0){
35 // end of file
36 break;
38 ef1->vtab->process(ef1, &buf_ptr, 4410);
39 soundout_write(&so, buf, 4410 * 4);
40 pos += 4410;
43 return 0;