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
RevLine 
[0]1//audio.h:
2
[704]3/*
[3811]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
[704]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
[3517]21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
[704]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
[0]29#ifndef _ROARAUDIO_AUDIO_H_
30#define _ROARAUDIO_AUDIO_H_
31
[3590]32// TODO: move this block to a more logical location.
[0]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
[3590]37
[0]38/*
39 Bits:
40 76543210
[1211]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)
[318]49
[733]50 BB = Byte order / MSB/LSB
51
[1211]52 -- First Set:
53
[318]54 MIDI 0x08:
55 76543210
56      000 0x08 -> MIDI File
57
58 hi-level 0x10:
[1211]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
[2681]67      0111 0x17 -> Ogg
[1211]68      [...]
69      **** 0x1a -> ROAR CELT
70      **** 0x1b -> ROAR SPEEX
71      **** 0x1c -> RAUM
72      **** 0x1d -> RAUM Vorbis
[2332]73      **** 0x1e -> RAUM FLAC
[560]74
75 RIFF/WAVE like 0x20:
76  76543210
[733]77      0000 0x20 -> RIFF/WAVE
78
79 LOG Codecs 0x30:
80  76543210
81      00BB 0x30 -> A-Law (base)
82      01BB 0x34 -> mu-Law (base)
[1211]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)
[1294]92 |||\-------> META(0)/CONTAINER(1)
[1820]93 ||\--------> Specal codecs(0)
[1211]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
[1294]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
[1820]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
[1962]132      0001 -> RoarDMX
[1820]133
[2709]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
[0]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)
[733]161#define ROAR_CODEC_LE          0x01
162#define ROAR_CODEC_BE          0x02
163#define ROAR_CODEC_PDP         0x03
[0]164
[733]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)
[0]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
[318]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
[2681]185#define ROAR_CODEC_OGG_CELT     0x16
186#define ROAR_CODEC_OGG          0x17
[318]187
[329]188#define ROAR_CODEC_ROAR_CELT    0x1a
189#define ROAR_CODEC_ROAR_SPEEX   0x1b
190
[879]191#define ROAR_CODEC_RAUM         0x1c
192#define ROAR_CODEC_RAUM_VORBIS  0x1d
[2332]193#define ROAR_CODEC_RAUM_FLAC    0x1e
[560]194
195#define ROAR_CODEC_RIFF_WAVE    0x20
[4000]196#define ROAR_CODEC_RIFX         (ROAR_CODEC_RIFF_WAVE | ROAR_CODEC_BE)
197#define ROAR_CODEC_AU           0x24
198#define ROAR_CODEC_AIFF         0x28
[560]199
[733]200#define ROAR_CODEC_ALAW         0x30
201#define ROAR_CODEC_MULAW        0x34
[3993]202#define ROAR_CODEC_GSM          0x38
203#define ROAR_CODEC_GSM49        0x39
[733]204
[1211]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                     */
[3821]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 )
[1211]214#define ROAR_CODEC_META_RALB_PDP (ROAR_CODEC_META_RALB | ROAR_CODEC_PDP)
[733]215
[1294]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
[1820]235
[2709]236// MIDI:
[1820]237#define ROAR_CODEC_MIDI         0x60
[3993]238#define ROAR_CODEC_ROARMIDI     0x64
[2709]239
[3993]240// Light Control:
[1820]241#define ROAR_CODEC_DMX512       0x70
[1962]242#define ROAR_CODEC_ROARDMX      0x71
[1820]243
[2709]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
[0]265#if BYTE_ORDER == BIG_ENDIAN
266
[870]267#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_BE
268
[3590]269#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_BE
270#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_BE
[0]271#define ROAR_BE2DEF(x) (x)
272
273#elif BYTE_ORDER == LITTLE_ENDIAN
274
[870]275#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_LE
276
[3590]277#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_LE
278#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_LE
[0]279#define ROAR_LE2DEF(x) (x)
280
281#else
282
[870]283#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_PDP
284
[3590]285#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_PDP
286#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_PDP
[0]287#define ROAR_PDP2DEF(x) (x)
288
289#endif
290
[3590]291#define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_S
292
[0]293
294#define ROAR_CODEC_NATIVE ROAR_CODEC_DEFAULT
295
296#define ROAR_BITS_MAX             32
297
[1062]298#ifndef ROAR_BITS_DEFAULT
[0]299#define ROAR_BITS_DEFAULT         16
[1062]300#endif
301#ifndef ROAR_CHANNELS_DEFAULT
[0]302#define ROAR_CHANNELS_DEFAULT      2
[1062]303#endif
304#ifndef ROAR_RATE_DEFAULT
[0]305#define ROAR_RATE_DEFAULT      44100
[1062]306#endif
[0]307
[2398]308#define ROAR_MIDI_TICKS_PER_BEAT  96
309#define ROAR_MIDI_BITS             8
310#define ROAR_MIDI_CHANNELS_DEFAULT 16
311
[16]312#define ROAR_MAX_CHANNELS         64
313
[17]314#define ROAR_SET_VOL_ALL           1
315#define ROAR_SET_VOL_ONE           2
316
[393]317
[394]318#define ROAR_SPEEX_MAX_CC          256
[622]319#define ROAR_SPEEX_MAGIC           "RoarSpeex"
320#define ROAR_SPEEX_MAGIC_LEN       9
[393]321#define ROAR_SPEEX_MODE_NB         1
322#define ROAR_SPEEX_MODE_WB         2
323#define ROAR_SPEEX_MODE_UWB        3
324
[4159]325#define ROAR_CELT_MAGIC_0          "RoarCELT0"
326#define ROAR_CELT_MAGIC_1          "RoarCELT1"
327#define ROAR_CELT_MAGIC_LEN        9
328
[4152]329#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
[4159]330#define ROAR_CELT_MAGIC            ROAR_CELT_MAGIC_1
[4152]331#else
[4159]332#define ROAR_CELT_MAGIC            ROAR_CELT_MAGIC_0
[4152]333#endif
334
[0]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 {
[17]343 //unsigned      channels;
[3565]344 uint16_t   scale;
345 uint16_t   rpg_mul; // rpg = ReplayGain
346 uint16_t   rpg_div;
347 uint16_t   mixer[ROAR_MAX_CHANNELS];
[0]348};
349
[1671]350#define ROAR_MIXER(x) ((struct roar_mixer_settings *)x)
351
[0]352#endif
353
354//ll
Note: See TracBrowser for help on using the repository browser.