1 /* soundfile.h - low-level sound file I/O interface.
2  *
3  * Copyright 2010 Petteri Hintsanen <petterih@iki.fi>
4  *
5  * This file is part of abx.
6  *
7  * abx is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * abx is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with abx.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef ABX_SOUNDFILE_H
22 #define ABX_SOUNDFILE_H
23 
24 /* sound metadata structure */
25 typedef struct {
26     char *filename;
27     int bits;                   /* bits per sample */
28     int channels;               /* number of channels */
29     int frames;                 /* number of frames */
30     int rate;                   /* sampling rate */
31 
32     /* some derived numbers for convenience */
33     double duration;            /* duration in seconds */
34     unsigned int minutes;       /* duration, minutes part */
35     unsigned int seconds;       /* duration, seconds part */
36 } Metadata;
37 
38 typedef struct Sound_file Sound_file;
39 
40 extern Sound_file *open_sound_file(const char *filename);
41 extern int close_sound_file(Sound_file *sndfile);
42 extern Metadata get_metadata(Sound_file *sndfile);
43 extern double seek_sound_file(Sound_file *sndfile, double offset,
44                               int whence);
45 extern unsigned int read_pcm_data(Sound_file *sndfile,
46                                   float *buf, unsigned int nframes);
47 
48 #endif
49