1 | /* -*- mode: C; tab-width:8; c-basic-offset:8 -*- |
---|
2 | * vi:set ts=8: |
---|
3 | * |
---|
4 | * This is the header that apps should include when linking against |
---|
5 | * audioconvert or such. |
---|
6 | */ |
---|
7 | #ifndef AC_H_ |
---|
8 | #define AC_H_ |
---|
9 | |
---|
10 | #include "al_siteconfig.h" |
---|
11 | |
---|
12 | #include <AL/al.h> |
---|
13 | |
---|
14 | #include "audioconvert/ac_adpcm.h" |
---|
15 | |
---|
16 | /* new data types */ |
---|
17 | typedef struct _acAudioCVT { |
---|
18 | int needed; /* Set to 1 if conversion possible */ |
---|
19 | ALushort src_format; /* Source audio format */ |
---|
20 | ALushort dst_format; /* Target audio format */ |
---|
21 | double rate_incr; /* Rate conversion increment */ |
---|
22 | void *buf; /* Buffer to hold entire audio data */ |
---|
23 | int len; /* Length of original audio buffer */ |
---|
24 | int len_cvt; /* Length of converted audio buffer */ |
---|
25 | int len_mult; /* buffer must be len*len_mult big */ |
---|
26 | double len_ratio; /* Given len, final size is len*len_ratio */ |
---|
27 | void (*filters[10])(struct _acAudioCVT *cvt, ALushort format); |
---|
28 | int filter_index; /* Current audio conversion function */ |
---|
29 | } acAudioCVT; |
---|
30 | |
---|
31 | /* Audio format flags (defaults to LSB byte order) */ |
---|
32 | #define AUDIO_U8 0x0008 /* Unsigned 8-bit samples */ |
---|
33 | #define AUDIO_S8 0x8008 /* Signed 8-bit samples */ |
---|
34 | #define AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */ |
---|
35 | #define AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */ |
---|
36 | #define AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */ |
---|
37 | #define AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */ |
---|
38 | |
---|
39 | /* Native audio byte ordering */ |
---|
40 | #ifndef WORDS_BIGENDIAN |
---|
41 | #define AUDIO_U16 AUDIO_U16LSB |
---|
42 | #define AUDIO_S16 AUDIO_S16LSB |
---|
43 | #else |
---|
44 | #define AUDIO_U16 AUDIO_U16MSB |
---|
45 | #define AUDIO_S16 AUDIO_S16MSB |
---|
46 | #endif |
---|
47 | |
---|
48 | /* macros */ |
---|
49 | #define acFormatBits(fmt) (fmt & 0xff) |
---|
50 | |
---|
51 | /* bit changes */ |
---|
52 | void acConvert16MSB(acAudioCVT *cvt, ALushort format); |
---|
53 | void acConvert16LSB(acAudioCVT *cvt, ALushort format); |
---|
54 | void acConvert8(acAudioCVT *cvt, ALushort format); |
---|
55 | |
---|
56 | /* frequency changes */ |
---|
57 | void acFreqMUL2(acAudioCVT *cvt, ALushort format); |
---|
58 | void acFreqDIV2(acAudioCVT *cvt, ALushort format); |
---|
59 | void acFreqSLOW(acAudioCVT *cvt, ALushort format); |
---|
60 | |
---|
61 | /* channel changes */ |
---|
62 | void acConvertStereo(acAudioCVT *cvt, ALushort format); |
---|
63 | void acConvertMono(acAudioCVT *cvt, ALushort format); |
---|
64 | |
---|
65 | /* misc */ |
---|
66 | int ac_is_wave(void *data); |
---|
67 | void *ac_guess_info(void *data, ALuint *size, |
---|
68 | ALushort *fmt, ALushort *channels, ALushort *freq); |
---|
69 | void *ac_guess_wave_info(void *data, ALuint *size, |
---|
70 | ALushort *fmt, ALushort *channels, ALushort *freq); |
---|
71 | void *ac_wave_to_pcm(const void *data, ALuint *size, |
---|
72 | ALushort *fmt, ALushort *channels, ALushort *freq); |
---|
73 | |
---|
74 | int ac_isWAVE_ANY_adpcm(void *datap, ALuint size); |
---|
75 | int ac_isWAVE_IMA_adpcm(void *data, ALuint size); |
---|
76 | int ac_isWAVE_MS_adpcm(void *data, ALuint size); |
---|
77 | void *ac_getWAVEadpcm_info(void *data, ALuint *size, void *spec); |
---|
78 | |
---|
79 | /* sdl helper stuff */ |
---|
80 | int acBuildAudioCVT(acAudioCVT *cvt, |
---|
81 | ALushort src_format, ALubyte src_channels, ALuint src_rate, |
---|
82 | ALushort dst_format, ALubyte dst_channels, ALuint dst_rate); |
---|
83 | |
---|
84 | int acConvertAudio(acAudioCVT *); |
---|
85 | void *acLoadWAV(const void *data, ALuint *size, void **udata, |
---|
86 | ALushort *format, |
---|
87 | ALushort *channels, |
---|
88 | ALushort *freq); |
---|
89 | |
---|
90 | #endif /* AC_H_ */ |
---|