source: roaraudio/include/roaraudio/audio.h @ 3517:1a3218a3fc5b

Last change on this file since 3517:1a3218a3fc5b was 3517:1a3218a3fc5b, checked in by phi, 14 years ago

updated license headers, FSF moved office

File size: 8.5 KB
Line 
1//audio.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
5 *
6 *  This file is part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU Lesser General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 *  NOTE: Even though this file is LGPLed it (may) include GPLed files
25 *  so the license of this file is/may therefore downgraded to GPL.
26 *  See HACKING for details.
27 */
28
29#ifndef _ROARAUDIO_AUDIO_H_
30#define _ROARAUDIO_AUDIO_H_
31
32#define ROAR_CODEC_PCM_LE  ROAR_CODEC_PCM_S_LE
33#define ROAR_CODEC_PCM_BE  ROAR_CODEC_PCM_S_BE
34#define ROAR_CODEC_PCM_PDP ROAR_CODEC_PCM_S_PDP
35
36/*
37 Bits:
38 76543210
39 |||||||\---\ byte-
40 ||||||\----/ order
41 |||||\-----> unsigned?
42 ||||\------> PCM(0) or MIDI(1)?
43 |||\-------> PCM/MIDI(0) or hi-level codecs(1)
44 ||\--------> MISC(0) or RIFF/WAVE like(1)
45 |\---------> first set(0) or second set(1)
46 \----------> (0)
47
48 BB = Byte order / MSB/LSB
49
50 -- First Set:
51
52 MIDI 0x08:
53 76543210
54      000 0x08 -> MIDI File
55
56 hi-level 0x10:
57  76543210
58      0000 0x10 -> Ogg Vorbis
59      0001 0x11 -> Native FLAC
60      0010 0x12 -> Ogg Speex
61      0011 0x13 -> Reserved for CELT
62      0100 0x14 -> Ogg FLAC
63      0101 0x15 -> Ogg General
64      0110 0x16 -> Ogg CELT
65      0111 0x17 -> Ogg
66      [...]
67      **** 0x1a -> ROAR CELT
68      **** 0x1b -> ROAR SPEEX
69      **** 0x1c -> RAUM
70      **** 0x1d -> RAUM Vorbis
71      **** 0x1e -> RAUM FLAC
72
73 RIFF/WAVE like 0x20:
74  76543210
75      0000 0x20 -> RIFF/WAVE
76
77 LOG Codecs 0x30:
78  76543210
79      00BB 0x30 -> A-Law (base)
80      01BB 0x34 -> mu-Law (base)
81
82 -- Second Set:
83
84 Bits:
85 76543210
86 |||||||\---\ byte-
87 ||||||\----/ order
88 |||||\-----> unsigned? (or other flags)
89 ||||\------> META: text(0) or binary(1)
90 |||\-------> META(0)/CONTAINER(1)
91 ||\--------> Specal codecs(0)
92 |\---------> second set(1)
93 \----------> (0)
94
95 Meta Codecs 0x40:
96  76543210
97      0000 0x40 -> Meta Text: Vorbis Comment Like
98      [...]
99      0100 0x44 -> Meta Text: RoarAudio Like
100      [...]
101      11BB 0x4c -> Meta Binary: RoarAudio Like
102
103 Container 0x50:
104  76543210
105      0000 0x50 -> Null container: pass
106      0001 0x51 -> Gzip
107      0010 0x52 -> Bzip2
108      0011 0x53 -> OpenPGP bin
109      0100 0x54 -> OpenPGP asc
110      0101 0x55 -> TAR
111
112 Bits:
113 76543210
114 |||||||\---\ byte-
115 ||||||\----/ order
116 |||||\-----> unsigned? (or other flags)
117 ||||\------> (0)
118 |||\-------> MIDI(0)/Light(1)
119 ||\--------> MIDI and Light(1)
120 |\---------> second set(1)
121 \----------> (0)
122
123 MIDI 0x60:
124  76543210
125      0000 -> MIDI
126
127 Light 0x70:
128  76543210
129      0000 -> DMX512
130      0001 -> RoarDMX
131
132 Bits:
133 76543210
134 |||||||\---\ byte-
135 ||||||\----/ order
136 |||||\-----> unsigned? (or other flags)
137 ||||\------> ID
138 |||\-------> RDTCS(0) / User/Vendor Specific(1)
139 ||\--------> first subset(0)
140 |\---------> first set(0)
141 \----------> (1)
142
143 RDTCS 0x80:
144  76543210
145      0000 -> RDS
146
147 User  0x90:
148  76543210
149      0000 -> USER0
150      [...]
151      1111 -> USER15
152
153*/
154
155#define ROAR_CODEC_IS_SIGNED(x)  (((x) & ROAR_CODEC_UNSIGNED) == 0 ? 1 : 0)
156#define ROAR_CODEC_BYTE_ORDER(x) ((x) & 0x03)
157
158#define ROAR_CODEC_UNSIGNED    (1 << 2)
159#define ROAR_CODEC_LE          0x01
160#define ROAR_CODEC_BE          0x02
161#define ROAR_CODEC_PDP         0x03
162
163#define ROAR_CODEC_MSB         0x00
164#define ROAR_CODEC_LSB         0x01
165
166#define ROAR_CODEC_PCM       0x00
167#define ROAR_CODEC_PCM_S_LE  (ROAR_CODEC_PCM | ROAR_CODEC_LE )
168#define ROAR_CODEC_PCM_S_BE  (ROAR_CODEC_PCM | ROAR_CODEC_BE )
169#define ROAR_CODEC_PCM_S_PDP (ROAR_CODEC_PCM | ROAR_CODEC_PDP)
170
171#define ROAR_CODEC_PCM_U_LE  (ROAR_CODEC_PCM_S_LE  | ROAR_CODEC_UNSIGNED)
172#define ROAR_CODEC_PCM_U_BE  (ROAR_CODEC_PCM_S_BE  | ROAR_CODEC_UNSIGNED)
173#define ROAR_CODEC_PCM_U_PDP (ROAR_CODEC_PCM_S_PDP | ROAR_CODEC_UNSIGNED)
174
175#define ROAR_CODEC_MIDI_FILE    0x08
176
177#define ROAR_CODEC_OGG_VORBIS   0x10
178#define ROAR_CODEC_FLAC         0x11 /* native FLAC without Ogg container */
179#define ROAR_CODEC_OGG_SPEEX    0x12
180/* #define ROAR_CODEC_CELT/OGG_CELT 0x13 Reserved for CELT */
181#define ROAR_CODEC_OGG_FLAC     0x14
182#define ROAR_CODEC_OGG_GENERAL  0x15
183#define ROAR_CODEC_OGG_CELT     0x16
184#define ROAR_CODEC_OGG          0x17
185
186#define ROAR_CODEC_ROAR_CELT    0x1a
187#define ROAR_CODEC_ROAR_SPEEX   0x1b
188
189#define ROAR_CODEC_RAUM         0x1c
190#define ROAR_CODEC_RAUM_VORBIS  0x1d
191#define ROAR_CODEC_RAUM_FLAC    0x1e
192
193#define ROAR_CODEC_RIFF_WAVE    0x20
194
195#define ROAR_CODEC_ALAW         0x30
196#define ROAR_CODEC_MULAW        0x34
197
198// Meta Codecs:
199#define ROAR_CODEC_META_VCLT    0x40 /* VCLT = Vorbis Comment Like Text */
200#define ROAR_CODEC_META_RALT    0x44 /* RALT = RoarAudio Like Text      */
201#define ROAR_CODEC_META_RALB    0x4c /* RALB = RoarAudio Like Binary    */
202                                     /* if no byte order is given then you
203                                        should assume BE as it is network
204                                        byte order                     */
205#define ROAR_CODEC_META_RALB_LE (ROAR_CODEC_META_RALB | ROAR_CODEC_LE)
206#define ROAR_CODEC_META_RALB_BE (ROAR_CODEC_META_RALB | ROAR_CODEC_BE)
207#define ROAR_CODEC_META_RALB_PDP (ROAR_CODEC_META_RALB | ROAR_CODEC_PDP)
208
209// Container Codecs:
210/*
211 Container 0x50:
212  76543210
213      0000 0x50 -> Null container: pass
214      0001 0x51 -> Gzip
215      0010 0x52 -> Bzip2
216      0011 0x53 -> OpenPGP bin
217      0100 0x54 -> OpenPGP asc
218      0101 0x55 -> TAR
219*/
220#define ROAR_CODEC_CONT_NULL    0x50
221#define ROAR_CODEC_CONT_BASE    ROAR_CODEC_CONT_NULL
222#define ROAR_CODEC_CONT_GZIP    0x51
223#define ROAR_CODEC_CONT_BZIP2   0x52
224#define ROAR_CODEC_CONT_OPGPBIN 0x53
225#define ROAR_CODEC_CONT_OPGPASC 0x54
226#define ROAR_CODEC_CONT_TAR     0x55
227
228
229// MIDI:
230#define ROAR_CODEC_MIDI         0x60
231
232// Light COntrol:
233#define ROAR_CODEC_DMX512       0x70
234#define ROAR_CODEC_ROARDMX      0x71
235
236// RDTCS:
237#define ROAR_CODEC_RDS          0x80
238
239// User specific:
240#define ROAR_CODEC_USER0        0x90
241#define ROAR_CODEC_USER1        0x91
242#define ROAR_CODEC_USER2        0x92
243#define ROAR_CODEC_USER3        0x93
244#define ROAR_CODEC_USER4        0x94
245#define ROAR_CODEC_USER5        0x95
246#define ROAR_CODEC_USER6        0x96
247#define ROAR_CODEC_USER7        0x97
248#define ROAR_CODEC_USER8        0x98
249#define ROAR_CODEC_USER9        0x99
250#define ROAR_CODEC_USER10       0x9a
251#define ROAR_CODEC_USER11       0x9b
252#define ROAR_CODEC_USER12       0x9c
253#define ROAR_CODEC_USER13       0x9d
254#define ROAR_CODEC_USER14       0x9e
255#define ROAR_CODEC_USER15       0x9f
256
257#if BYTE_ORDER == BIG_ENDIAN
258
259#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_BE
260
261#define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_BE
262#define ROAR_BE2DEF(x) (x)
263
264#elif BYTE_ORDER == LITTLE_ENDIAN
265
266#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_LE
267
268#define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_LE
269#define ROAR_LE2DEF(x) (x)
270
271#else
272
273#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_PDP
274
275#define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_PDP
276#define ROAR_PDP2DEF(x) (x)
277
278#endif
279
280
281#define ROAR_CODEC_NATIVE ROAR_CODEC_DEFAULT
282
283#define ROAR_BITS_MAX             32
284
285#ifndef ROAR_BITS_DEFAULT
286#define ROAR_BITS_DEFAULT         16
287#endif
288#ifndef ROAR_CHANNELS_DEFAULT
289#define ROAR_CHANNELS_DEFAULT      2
290#endif
291#ifndef ROAR_RATE_DEFAULT
292#define ROAR_RATE_DEFAULT      44100
293#endif
294
295#define ROAR_MIDI_TICKS_PER_BEAT  96
296#define ROAR_MIDI_BITS             8
297#define ROAR_MIDI_CHANNELS_DEFAULT 16
298
299#define ROAR_MAX_CHANNELS         64
300
301#define ROAR_SET_VOL_ALL           1
302#define ROAR_SET_VOL_ONE           2
303
304
305#define ROAR_SPEEX_MAX_CC          256
306#define ROAR_SPEEX_MAGIC           "RoarSpeex"
307#define ROAR_SPEEX_MAGIC_LEN       9
308#define ROAR_SPEEX_MODE_NB         1
309#define ROAR_SPEEX_MODE_WB         2
310#define ROAR_SPEEX_MODE_UWB        3
311
312#define ROAR_CELT_MAGIC            "RoarCELT0"
313#define ROAR_CELT_MAGIC_LEN        9
314
315struct roar_audio_info {
316 unsigned int rate;
317 unsigned int bits;
318 unsigned int channels;
319 unsigned int codec;
320};
321
322struct roar_mixer_settings {
323 //unsigned      channels;
324 roar_intm16   scale;
325 roar_intm16   rpg_mul; // rpg = ReplayGain
326 roar_intm16   rpg_div;
327 roar_intm16   mixer[ROAR_MAX_CHANNELS];
328};
329
330#define ROAR_MIXER(x) ((struct roar_mixer_settings *)x)
331
332#endif
333
334//ll
Note: See TracBrowser for help on using the repository browser.