chiark / gitweb /
Uniform audio command back end now rate limited.
[disorder] / lib / wav.h
CommitLineData
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
25/** @brief WAV file access structure */
26struct wavfile {
27 /** @brief File descriptor onto file */
28 int fd;
29
30 /** @brief File length */
31 off_t length;
32
33 /** @brief Offset of data chunk */
34 off_t data;
35
36 /** @brief Sample rate (Hz) */
37 int rate;
38
39 /** @brief Number of channels (usually 1 or 2) */
40 int channels;
41
42 /** @brief Bits per sample */
43 int bits;
44
45 /** @brief Size of data chunk in bytes */
46 off_t datasize;
47};
48
49/** @brief Sample data callback from wav_data()
50 * @param f WAV file being read
51 * @param data Pointer to sample data
52 * @param nbytes Number of bytes of data
53 * @param u As passed to wav_data()
54 * @return 0 on success or an errno value on error
55 *
56 * @p nbytes is always a multiple of the frame size and never 0.
57 */
58typedef int wav_data_callback(struct wavfile *f,
59 const char *data,
60 size_t nbytes,
61 void *u);
62
63int wav_init(struct wavfile *f, const char *path);
64void wav_destroy(struct wavfile *f);
65int wav_data(struct wavfile *f,
66 wav_data_callback *callback,
67 void *u);
68
69#endif /* WAV_H */
70
71/*
72Local Variables:
73c-basic-offset:2
74comment-column:40
75fill-column:79
76indent-tabs-mode:nil
77End:
78*/