Commit | Line | Data |
---|---|---|
ce6c36be | 1 | /* |
2 | * This file is part of DisOrder | |
3 | * Copyright (C) 2007 Richard Kettlewell | |
4 | * | |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
ce6c36be | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
ce6c36be | 8 | * (at your option) any later version. |
e7eb3a27 RK |
9 | * |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
ce6c36be | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
ce6c36be | 17 | */ |
18 | /** @file lib/wav.h | |
19 | * @brief WAV file support | |
20 | */ | |
21 | ||
22 | #ifndef WAV_H | |
23 | #define WAV_H | |
24 | ||
281d0fd4 RK |
25 | #include "hreader.h" |
26 | ||
ce6c36be | 27 | /** @brief WAV file access structure */ |
28 | struct wavfile { | |
281d0fd4 RK |
29 | /** @brief File read handle */ |
30 | struct hreader input[1]; | |
ce6c36be | 31 | |
32 | /** @brief File length */ | |
33 | off_t length; | |
34 | ||
35 | /** @brief Offset of data chunk */ | |
36 | off_t data; | |
37 | ||
38 | /** @brief Sample rate (Hz) */ | |
39 | int rate; | |
40 | ||
41 | /** @brief Number of channels (usually 1 or 2) */ | |
42 | int channels; | |
43 | ||
44 | /** @brief Bits per sample */ | |
45 | int bits; | |
46 | ||
47 | /** @brief Size of data chunk in bytes */ | |
48 | off_t datasize; | |
49 | }; | |
50 | ||
51 | /** @brief Sample data callback from wav_data() | |
52 | * @param f WAV file being read | |
53 | * @param data Pointer to sample data | |
54 | * @param nbytes Number of bytes of data | |
55 | * @param u As passed to wav_data() | |
56 | * @return 0 on success or an errno value on error | |
57 | * | |
58 | * @p nbytes is always a multiple of the frame size and never 0. | |
59 | */ | |
60 | typedef int wav_data_callback(struct wavfile *f, | |
61 | const char *data, | |
62 | size_t nbytes, | |
63 | void *u); | |
64 | ||
65 | int wav_init(struct wavfile *f, const char *path); | |
66 | void wav_destroy(struct wavfile *f); | |
67 | int wav_data(struct wavfile *f, | |
68 | wav_data_callback *callback, | |
69 | void *u); | |
70 | ||
71 | #endif /* WAV_H */ | |
72 | ||
73 | /* | |
74 | Local Variables: | |
75 | c-basic-offset:2 | |
76 | comment-column:40 | |
77 | fill-column:79 | |
78 | indent-tabs-mode:nil | |
79 | End: | |
80 | */ |