source: roaraudio/include/roaraudio/audio.h @ 5823:f9f70dbaa376

Last change on this file since 5823:f9f70dbaa376 was 5823:f9f70dbaa376, checked in by phi, 11 years ago

updated copyright

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