chiark / gitweb /
more thorough kvp.c testing
[disorder] / lib / wav.h
CommitLineData
ce6c36be 1/*
2 * This file is part of DisOrder
3 * Copyright (C) 2007 Richard Kettlewell
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20/** @file lib/wav.h
21 * @brief WAV file support
22 */
23
24#ifndef WAV_H
25#define WAV_H
26
27/** @brief WAV file access structure */
28struct wavfile {
29 /** @brief File descriptor onto file */
30 int fd;
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 */
60typedef int wav_data_callback(struct wavfile *f,
61 const char *data,
62 size_t nbytes,
63 void *u);
64
65int wav_init(struct wavfile *f, const char *path);
66void wav_destroy(struct wavfile *f);
67int wav_data(struct wavfile *f,
68 wav_data_callback *callback,
69 void *u);
70
71#endif /* WAV_H */
72
73/*
74Local Variables:
75c-basic-offset:2
76comment-column:40
77fill-column:79
78indent-tabs-mode:nil
79End:
80*/