source: roaraudio/include/roaraudio/audio.h @ 4894:f91a610f943d

Last change on this file since 4894:f91a610f943d was 4894:f91a610f943d, checked in by phi, 13 years ago

assign a offical ID to SPC-700's BRR

File size: 9.8 KB
Line 
1//audio.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
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_AUTLAW_LE    (ROAR_CODEC_ALAW|ROAR_CODEC_LE)
202#define ROAR_CODEC_AUTLAW_BE    (ROAR_CODEC_ALAW|ROAR_CODEC_BE)
203#define ROAR_CODEC_AUTLAW       ROAR_CODEC_AUTLAW_BE
204#define ROAR_CODEC_MULAW        0x34
205#define ROAR_CODEC_MUUTLAW_LE   (ROAR_CODEC_MULAW|ROAR_CODEC_LE)
206#define ROAR_CODEC_MUUTLAW_BE   (ROAR_CODEC_MULAW|ROAR_CODEC_BE)
207#define ROAR_CODEC_MUUTLAW      ROAR_CODEC_MUUTLAW_BE
208#define ROAR_CODEC_GSM          0x38
209#define ROAR_CODEC_GSM49        0x39
210#define ROAR_CODEC_BRR          0x3c /* SPC-700 Bit Rate Reduction of              */
211                                     /* Super Nintendo Entertainment System (SNES) */
212
213// Meta Codecs:
214#define ROAR_CODEC_META_VCLT    0x40 /* VCLT = Vorbis Comment Like Text */
215#define ROAR_CODEC_META_RALT    0x44 /* RALT = RoarAudio Like Text      */
216#define ROAR_CODEC_META_RALB    0x4c /* RALB = RoarAudio Like Binary    */
217                                     /* if no byte order is given then you
218                                        should assume BE as it is network
219                                        byte order                     */
220#define ROAR_CODEC_META_RALB_LE  (ROAR_CODEC_META_RALB | ROAR_CODEC_LE )
221#define ROAR_CODEC_META_RALB_BE  (ROAR_CODEC_META_RALB | ROAR_CODEC_BE )
222#define ROAR_CODEC_META_RALB_PDP (ROAR_CODEC_META_RALB | ROAR_CODEC_PDP)
223
224// Container Codecs:
225/*
226 Container 0x50:
227  76543210
228      0000 0x50 -> Null container: pass
229      0001 0x51 -> Gzip
230      0010 0x52 -> Bzip2
231      0011 0x53 -> OpenPGP bin
232      0100 0x54 -> OpenPGP asc
233      0101 0x55 -> TAR
234*/
235#define ROAR_CODEC_CONT_NULL    0x50
236#define ROAR_CODEC_CONT_BASE    ROAR_CODEC_CONT_NULL
237#define ROAR_CODEC_CONT_GZIP    0x51
238#define ROAR_CODEC_CONT_BZIP2   0x52
239#define ROAR_CODEC_CONT_OPGPBIN 0x53
240#define ROAR_CODEC_CONT_OPGPASC 0x54
241#define ROAR_CODEC_CONT_TAR     0x55
242
243
244// MIDI:
245#define ROAR_CODEC_MIDI         0x60
246#define ROAR_CODEC_ROARMIDI     0x64
247
248// Light Control:
249#define ROAR_CODEC_DMX512       0x70
250#define ROAR_CODEC_ROARDMX      0x71
251
252// RDTCS:
253#define ROAR_CODEC_RDS          0x80
254
255// User specific:
256#define ROAR_CODEC_USER0        0x90
257#define ROAR_CODEC_USER1        0x91
258#define ROAR_CODEC_USER2        0x92
259#define ROAR_CODEC_USER3        0x93
260#define ROAR_CODEC_USER4        0x94
261#define ROAR_CODEC_USER5        0x95
262#define ROAR_CODEC_USER6        0x96
263#define ROAR_CODEC_USER7        0x97
264#define ROAR_CODEC_USER8        0x98
265#define ROAR_CODEC_USER9        0x99
266#define ROAR_CODEC_USER10       0x9a
267#define ROAR_CODEC_USER11       0x9b
268#define ROAR_CODEC_USER12       0x9c
269#define ROAR_CODEC_USER13       0x9d
270#define ROAR_CODEC_USER14       0x9e
271#define ROAR_CODEC_USER15       0x9f
272
273#if BYTE_ORDER == BIG_ENDIAN
274
275#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_BE
276
277#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_BE
278#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_BE
279#define ROAR_BE2DEF(x) (x)
280
281#elif BYTE_ORDER == LITTLE_ENDIAN
282
283#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_LE
284
285#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_LE
286#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_LE
287#define ROAR_LE2DEF(x) (x)
288
289#else
290
291#define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_PDP
292
293#define ROAR_CODEC_PCM_S   ROAR_CODEC_PCM_S_PDP
294#define ROAR_CODEC_PCM_U   ROAR_CODEC_PCM_U_PDP
295#define ROAR_PDP2DEF(x) (x)
296
297#endif
298
299#define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_S
300
301
302#define ROAR_CODEC_NATIVE ROAR_CODEC_DEFAULT
303
304#define ROAR_BITS_MAX             32
305
306#ifndef ROAR_BITS_DEFAULT
307#define ROAR_BITS_DEFAULT         16
308#endif
309#ifndef ROAR_CHANNELS_DEFAULT
310#define ROAR_CHANNELS_DEFAULT      2
311#endif
312#ifndef ROAR_RATE_DEFAULT
313#define ROAR_RATE_DEFAULT      44100
314#endif
315
316#define ROAR_MIDI_TICKS_PER_BEAT  96
317#define ROAR_MIDI_BITS             8
318#define ROAR_MIDI_CHANNELS_DEFAULT 16
319
320#define ROAR_MAX_CHANNELS         64
321
322#define ROAR_SET_VOL_ALL           1
323#define ROAR_SET_VOL_ONE           2
324#define ROAR_SET_VOL_MS            3
325#define ROAR_SET_VOL_UNMAPPED      4
326
327
328#define ROAR_SPEEX_MAX_CC          256
329#define ROAR_SPEEX_MAGIC           "RoarSpeex"
330#define ROAR_SPEEX_MAGIC_LEN       9
331#define ROAR_SPEEX_MODE_NB         1
332#define ROAR_SPEEX_MODE_WB         2
333#define ROAR_SPEEX_MODE_UWB        3
334
335#define ROAR_CELT_MAGIC_0          "RoarCELT0"
336#define ROAR_CELT_MAGIC_1          "RoarCELT1"
337#define ROAR_CELT_MAGIC_LEN        9
338
339#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
340#define ROAR_CELT_MAGIC            ROAR_CELT_MAGIC_1
341#else
342#define ROAR_CELT_MAGIC            ROAR_CELT_MAGIC_0
343#endif
344
345struct roar_audio_info {
346 unsigned int rate;
347 unsigned int bits;
348 unsigned int channels;
349 unsigned int codec;
350};
351
352struct roar_mixer_settings {
353 //unsigned      channels;
354 uint16_t   scale;
355 uint16_t   rpg_mul; // rpg = ReplayGain
356 uint16_t   rpg_div;
357 uint16_t   mixer[ROAR_MAX_CHANNELS];
358};
359
360#define ROAR_MIXER(x) ((struct roar_mixer_settings *)x)
361
362#endif
363
364//ll
Note: See TracBrowser for help on using the repository browser.