source: roaraudio/include/roaraudio/audio.h @ 2709:42309f2b8877

Last change on this file since 2709:42309f2b8877 was 2709:42309f2b8877, checked in by phi, 15 years ago

new codecs

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