Initial commit. Plays a wave file.
[aftubes.git] / main.c
blob8f9045b4fbb92dbf020660e0839c3d2e98f58aac
1 #include "stdio.h"
2 #include "soundout.h"
3 #include "wavefile.h"
5 int main(int argc, char **argv)
7 struct soundout so;
8 struct wavefile wf;
9 struct aformat af;
11 if (wavefile_open(&wf, "/home/aoe/reflections.wav") != 0){
12 fprintf(stderr, "cannot open wave file\n");
13 return 1;
16 af.srate = 44100;
17 af.bits = 16;
18 af.channels = 2;
20 if (soundout_open(&so, &af) != 0){
21 fprintf(stderr, "cannot open audio output device\n");
22 // wavefile_close
23 return 1;
26 unsigned int pos = 0;
27 char buf[4410 * 4];
28 for (;;){
29 if (wavefile_read_at(&wf, pos, buf, 4410) != 0){
30 // end of file
31 break;
33 soundout_write(&so, buf, 4410 * 4);
34 pos += 4410;
37 return 0;