source: roaraudio/include/roaraudio/audio.h @ 4159:195c87e5b538

Last change on this file since 4159:195c87e5b538 was 4159:195c87e5b538, checked in by phi, 14 years ago

updated handling of CELT magics

File size: 9.2 KB
Line 
1//audio.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
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// TODO: move this block to a more logical location.
33#define ROAR_CODEC_PCM_LE  ROAR_CODEC_PCM_S_LE
34#define ROAR_CODEC_PCM_BE  ROAR_CODEC_PCM_S_BE
35#define ROAR_CODEC_PCM_PDP ROAR_CODEC_PCM_S_PDP
36
37
38/*
39 Bits:
40 76543210
41 |||||||\---\ byte-
42 ||||||\----/ order
43 |||||\-----> unsigned?
44 ||||\------> PCM(0) or MIDI(1)?
45 |||\-------> PCM/MIDI(0) or hi-level codecs(1)
46 ||\--------> MISC(0) or RIFF/WAVE like(1)
47 |\---------> first set(0) or second set(1)
48 \----------> (0)
49
50 BB = Byte order / MSB/LSB
51
52 -- First Set:
53
54 MIDI 0x08:
55 76543210
56      000 0x08 -> MIDI File
57
58 hi-level 0x10:
59  76543210
60      0000 0x10 -> Ogg Vorbis
61      0001 0x11 -> Native FLAC
62      0010 0x12 -> Ogg Speex
63      0011 0x13 -> Reserved for CELT
64      0100 0x14 -> Ogg FLAC
65      0101 0x15 -> Ogg General
66      0110 0x16 -> Ogg CELT
67      0111 0x17 -> Ogg
68      [...]
69      **** 0x1a -> ROAR CELT
70      **** 0x1b -> ROAR SPEEX
71      **** 0x1c -> RAUM
72      **** 0x1d -> RAUM Vorbis
73      **** 0x1e -> RAUM FLAC
74
75 RIFF/WAVE like 0x20:
76  76543210
77      0000 0x20 -> RIFF/WAVE
78
79 LOG Codecs 0x30:
80  76543210
81      00BB 0x30 -> A-Law (base)
82      01BB 0x34 -> mu-Law (base)
83
84 -- Second Set:
85
86 Bits:
87 76543210
88 |||||||\---\ byte-
89 ||||||\----/ order
90 |||||\-----> unsigned? (or other flags)
91 ||||\------> META: text(0) or binary(1)
92 |||\-------> META(0)/CONTAINER(1)
93 ||\--------> Specal codecs(0)
94 |\---------> second set(1)
95 \----------> (0)
96
97 Meta Codecs 0x40:
98  76543210
99      0000 0x40 -> Meta Text: Vorbis Comment Like
100      [...]
101      0100 0x44 -> Meta Text: RoarAudio Like
102      [...]
103      11BB 0x4c -> Meta Binary: RoarAudio Like
104
105 Container 0x50:
106  76543210
107      0000 0x50 -> Null container: pass
108      0001 0x51 -> Gzip
109      0010 0x52 -> Bzip2
110      0011 0x53 -> OpenPGP bin
111      0100 0x54 -> OpenPGP asc
112      0101 0x55 -> TAR
113
114 Bits:
115 76543210
116 |||||||\---\ byte-
117 ||||||\----/ order
118 |||||\-----> unsigned? (or other flags)
119 ||||\------> (0)
120 |||\-------> MIDI(0)/Light(1)
121 ||\--------> MIDI and Light(1)
122 |\---------> second set(1)
123 \----------> (0)
124
125 MIDI 0x60:
126  76543210
127      0000 -> MIDI
128
129 Light 0x70:
130  76543210
131      0000 -> DMX512
132      0001 -> RoarDMX
133
134 Bits:
135 76543210
136 |||||||\---\ byte-
137 ||||||\----/ order
138 |||||\-----> unsigned? (or other flags)
139 ||||\------> ID
140 |||\-------> RDTCS(0) / User/Vendor Specific(1)
141 ||\--------> first subset(0)
142 |\---------> first set(0)
143 \----------> (1)
144
145 RDTCS 0x80:
146  76543210
147      0000 -> RDS
148
149 User  0x90:
150  76543210
151      0000 -> USER0
152      [...]
153      1111 -> USER15
154
155*/
156
157#define ROAR_CODEC_IS_SIGNED(x)  (((x) & ROAR_CODEC_UNSIGNED) == 0 ? 1 : 0)
158#define ROAR_CODEC_BYTE_ORDER(x) ((x) & 0x03)
159
160#define ROAR_CODEC_UNSIGNED    (1 << 2)
161#define ROAR_CODEC_LE          0x01
162#define ROAR_CODEC_BE          0x02
163#define ROAR_CODEC_PDP         0x03
164
165#define ROAR_CODEC_MSB         0x00
166#define ROAR_CODEC_LSB         0x01
167
168#define ROAR_CODEC_PCM       0x00
169#define ROAR_CODEC_PCM_S_LE  (ROAR_CODEC_PCM | ROAR_CODEC_LE )
170#define ROAR_CODEC_PCM_S_BE  (ROAR_CODEC_PCM | ROAR_CODEC_BE )
171#define ROAR_CODEC_PCM_S_PDP (ROAR_CODEC_PCM | ROAR_CODEC_PDP)
172
173#define ROAR_CODEC_PCM_U_LE  (ROAR_CODEC_PCM_S_LE  | ROAR_CODEC_UNSIGNED)
174#define ROAR_CODEC_PCM_U_BE  (ROAR_CODEC_PCM_S_BE  | ROAR_CODEC_UNSIGNED)
175#define ROAR_CODEC_PCM_U_PDP (ROAR_CODEC_PCM_S_PDP | ROAR_CODEC_UNSIGNED)
176
177#define ROAR_CODEC_MIDI_FILE    0x08
178
179#define ROAR_CODEC_OGG_VORBIS   0x10
180#define ROAR_CODEC_FLAC         0x11 /* native FLAC without Ogg container */
181#define ROAR_CODEC_OGG_SPEEX    0x12
182/* #define ROAR_CODEC_CELT/OGG_CELT 0x13 Reserved for CELT */
183#define ROAR_CODEC_OGG_FLAC     0x14
184#define ROAR_CODEC_OGG_GENERAL  0x15
185#define ROAR_CODEC_OGG_CELT     0x16
186#define ROAR_CODEC_OGG          0x17
187
188#define ROAR_CODEC_ROAR_CELT    0x1a
189#define ROAR_CODEC_ROAR_SPEEX   0x1b
190
191#define ROAR_CODEC_RAUM         0x1c
192#define ROAR_CODEC_RAUM_VORBIS  0x1d
193#define ROAR_CODEC_RAUM_FLAC    0x1e
194
195#define ROAR_CODEC_RIFF_WAVE    0x20
196#define ROAR_CODEC_RIFX         (ROAR_CODEC_RIFF_WAVE | ROAR_CODEC_BE)
197#define ROAR_CODEC_AU           0x24
198#define ROAR_CODEC_AIFF         0x28
199
200#define ROAR_CODEC_ALAW         0x30
201#define ROAR_CODEC_MULAW        0x34
202#define ROAR_CODEC_GSM          0x38
203#define ROAR_CODEC_GSM49        0x39
204
205// Meta Codecs:
206#define ROAR_CODEC_META_VCLT    0x40 /* VCLT = Vorbis Comment Like Text */
207#define ROAR_CODEC_META_RALT    0x44 /* RALT = RoarAudio Like Text      */
208#define ROAR_CODEC_META_RALB    0x4c /* RALB = RoarAudio Like Binary    */
209                                     /* if no byte order is given then you
210                                        should assume BE as it is network
211                                        byte order                     */
212#define ROAR_CODEC_META_RALB_LE  (ROAR_CODEC_META_RALB | ROAR_CODEC_LE )
213#define ROAR_CODEC_META_RALB_BE  (ROAR_CODEC_META_RALB | ROAR_CODEC_BE )
214#define ROAR_CODEC_META_RALB_PDP (ROAR_CODEC_META_RALB | ROAR_CODEC_PDP)
215
216// Container Codecs:
217/*
218 Container 0x50:
219  76543210
220      0000 0x50 -> Null container: pass
221      0001 0x51 -> Gzip
222      0010 0x52 -> Bzip2
223      0011 0x53 -> OpenPGP bin
224      0100 0x54 -> OpenPGP asc
225      0101 0x55 -> TAR
226*/
227#define ROAR_CODEC_CONT_NULL    0x50
228#define ROAR_CODEC_CONT_BASE    ROAR_CODEC_CONT_NULL
229#define ROAR_CODEC_CONT_GZIP    0x51
230#define ROAR_CODEC_CONT_BZIP2   0x52
231#define ROAR_CODEC_CONT_OPGPBIN 0x53
232#define ROAR_CODEC_CONT_OPGPASC 0x54
233#define ROAR_CODEC_CONT_TAR     0x55
234
235
236// MIDI:
237#define ROAR_CODEC_MIDI         0x60
238#define ROAR_CODEC_ROARMIDI     0x64
239
240// Light Control:
241#define ROAR_CODEC_DMX512       0x70
242#define ROAR_CODEC_ROARDMX      0x71
243
244// RDTCS:
245#define ROAR_CODEC_RDS          0x80
246
247// User specific:
248#define ROAR_CODEC_USER0        0x90
249#define ROAR_CODEC_USER1        0x91
250#define ROAR_CODEC_USER2        0x92
251#define ROAR_CODEC_USER3        0x93
252#define ROAR_CODEC_USER4        0x94
253#define ROAR_CODEC_USER5        0x95
254#define ROAR_CODEC_USER6        0x96
255#define ROAR_CODEC_USER7        0x97
256#define ROAR_CODEC_USER8        0x98
257#define ROAR_CODEC_USER9        0x99
258#define ROAR_CODEC_USER10       0x9a
259#define ROAR_CODEC_USER11       0x9b
260#define ROAR_CODEC_USER12       0x9c
261#define ROAR_CODEC_USER13       0x9d
262#define ROAR_CODEC_USER14       0x9e
263#define ROAR_CODEC_USER15       0x9f
264
265#if BYTE_ORDER == BIG_ENDIAN
266
267#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_BE
268
269#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_BE
270#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_BE
271#define ROAR_BE2DEF(x) (x)
272
273#elif BYTE_ORDER == LITTLE_ENDIAN
274
275#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_LE
276
277#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_LE
278#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_LE
279#define ROAR_LE2DEF(x) (x)
280
281#else
282
283#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_PDP
284
285#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_PDP
286#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_PDP
287#define ROAR_PDP2DEF(x) (x)
288
289#endif
290
291#define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_S
292
293
294#define ROAR_CODEC_NATIVE ROAR_CODEC_DEFAULT
295
296#define ROAR_BITS_MAX             32
297
298#ifndef ROAR_BITS_DEFAULT
299#define ROAR_BITS_DEFAULT         16
300#endif
301#ifndef ROAR_CHANNELS_DEFAULT
302#define ROAR_CHANNELS_DEFAULT      2
303#endif
304#ifndef ROAR_RATE_DEFAULT
305#define ROAR_RATE_DEFAULT      44100
306#endif
307
308#define ROAR_MIDI_TICKS_PER_BEAT  96
309#define ROAR_MIDI_BITS             8
310#define ROAR_MIDI_CHANNELS_DEFAULT 16
311
312#define ROAR_MAX_CHANNELS         64
313
314#define ROAR_SET_VOL_ALL           1
315#define ROAR_SET_VOL_ONE           2
316
317
318#define ROAR_SPEEX_MAX_CC          256
319#define ROAR_SPEEX_MAGIC           "RoarSpeex"
320#define ROAR_SPEEX_MAGIC_LEN       9
321#define ROAR_SPEEX_MODE_NB         1
322#define ROAR_SPEEX_MODE_WB         2
323#define ROAR_SPEEX_MODE_UWB        3
324
325#define ROAR_CELT_MAGIC_0          "RoarCELT0"
326#define ROAR_CELT_MAGIC_1          "RoarCELT1"
327#define ROAR_CELT_MAGIC_LEN        9
328
329#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
330#define ROAR_CELT_MAGIC            ROAR_CELT_MAGIC_1
331#else
332#define ROAR_CELT_MAGIC            ROAR_CELT_MAGIC_0
333#endif
334
335struct roar_audio_info {
336 unsigned int rate;
337 unsigned int bits;
338 unsigned int channels;
339 unsigned int codec;
340};
341
342struct roar_mixer_settings {
343 //unsigned      channels;
344 uint16_t   scale;
345 uint16_t   rpg_mul; // rpg = ReplayGain
346 uint16_t   rpg_div;
347 uint16_t   mixer[ROAR_MAX_CHANNELS];
348};
349
350#define ROAR_MIXER(x) ((struct roar_mixer_settings *)x)
351
352#endif
353
354//ll
Note: See TracBrowser for help on using the repository browser.