-
Notifications
You must be signed in to change notification settings - Fork 7
/
wavplay.h
88 lines (74 loc) · 1.56 KB
/
wavplay.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef _WAVPLAY_H
#define _WAVPLAY_H
/*-
* wavplay - a C library to play WAV sound via OSS/ALSA
*
* Copyright (c) 2011, 2012
* Zhihao Yuan. All rights reserved.
*
* Reference:
* http://www.freshports.org/audio/waveplay/
*
* This file is distributed under the 2-clause BSD License.
*/
#include <stdint.h>
#include <stdio.h>
#ifndef USE_ALSA
#define DEV_NAME "/dev/dsp"
#else
#define DEV_NAME "default"
#endif
typedef struct _riffchunk {
char id[4];
uint32_t size;
} riffchunk_t;
typedef struct _wavheader {
int16_t format;
int16_t nchannels;
int32_t framerate;
int32_t byterate;
int16_t blocksize;
int16_t bitdepth;
} wavheader_t;
typedef struct _extdouble {
int16_t expon;
uint32_t himant;
uint32_t lomant;
} __attribute__((__packed__)) extdouble_t;
typedef struct _aifheader {
int16_t nchannels;
int32_t nframes;
int16_t bitdepth;
extdouble_t framerate;
char comptype[4];
} __attribute__((__packed__)) aifheader_t;
typedef struct _sunheader {
uint32_t size;
int32_t encoding;
int32_t framerate;
int32_t nchannels;
} __attribute__((__packed__)) sunheader_t;
typedef struct _wav_info {
int nchannels;
int nframes;
int sampwidth;
int framerate;
int devformat;
} wav_info_t;
#ifdef __cplusplus
extern "C" {
#endif
int wav_play(const char *filename);
int wav_send(FILE *stream);
int snd_init(void);
int snd_set(int format, /* OSS/ALSA format constant */
int nchannels,
int framerate);
int snd_send(FILE *stream,
size_t size);
int snd_drop(void);
int snd_end(void);
#ifdef __cplusplus
}
#endif
#endif