[0] | 1 | //audio.h: |
---|
| 2 | |
---|
[704] | 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 | |
---|
[0] | 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 |
---|
[1211] | 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) |
---|
[318] | 46 | |
---|
[733] | 47 | BB = Byte order / MSB/LSB |
---|
| 48 | |
---|
[1211] | 49 | -- First Set: |
---|
| 50 | |
---|
[318] | 51 | MIDI 0x08: |
---|
| 52 | 76543210 |
---|
| 53 | 000 0x08 -> MIDI File |
---|
| 54 | |
---|
| 55 | hi-level 0x10: |
---|
[1211] | 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 | [...] |
---|
| 65 | **** 0x1a -> ROAR CELT |
---|
| 66 | **** 0x1b -> ROAR SPEEX |
---|
| 67 | **** 0x1c -> RAUM |
---|
| 68 | **** 0x1d -> RAUM Vorbis |
---|
[2332] | 69 | **** 0x1e -> RAUM FLAC |
---|
[560] | 70 | |
---|
| 71 | RIFF/WAVE like 0x20: |
---|
| 72 | 76543210 |
---|
[733] | 73 | 0000 0x20 -> RIFF/WAVE |
---|
| 74 | |
---|
| 75 | LOG Codecs 0x30: |
---|
| 76 | 76543210 |
---|
| 77 | 00BB 0x30 -> A-Law (base) |
---|
| 78 | 01BB 0x34 -> mu-Law (base) |
---|
[1211] | 79 | |
---|
| 80 | -- Second Set: |
---|
| 81 | |
---|
| 82 | Bits: |
---|
| 83 | 76543210 |
---|
| 84 | |||||||\---\ byte- |
---|
| 85 | ||||||\----/ order |
---|
| 86 | |||||\-----> unsigned? (or other flags) |
---|
| 87 | ||||\------> META: text(0) or binary(1) |
---|
[1294] | 88 | |||\-------> META(0)/CONTAINER(1) |
---|
[1820] | 89 | ||\--------> Specal codecs(0) |
---|
[1211] | 90 | |\---------> second set(1) |
---|
| 91 | \----------> (0) |
---|
| 92 | |
---|
| 93 | Meta Codecs 0x40: |
---|
| 94 | 76543210 |
---|
| 95 | 0000 0x40 -> Meta Text: Vorbis Comment Like |
---|
| 96 | [...] |
---|
| 97 | 0100 0x44 -> Meta Text: RoarAudio Like |
---|
| 98 | [...] |
---|
| 99 | 11BB 0x4c -> Meta Binary: RoarAudio Like |
---|
| 100 | |
---|
[1294] | 101 | Container 0x50: |
---|
| 102 | 76543210 |
---|
| 103 | 0000 0x50 -> Null container: pass |
---|
| 104 | 0001 0x51 -> Gzip |
---|
| 105 | 0010 0x52 -> Bzip2 |
---|
| 106 | 0011 0x53 -> OpenPGP bin |
---|
| 107 | 0100 0x54 -> OpenPGP asc |
---|
| 108 | 0101 0x55 -> TAR |
---|
| 109 | |
---|
[1820] | 110 | Bits: |
---|
| 111 | 76543210 |
---|
| 112 | |||||||\---\ byte- |
---|
| 113 | ||||||\----/ order |
---|
| 114 | |||||\-----> unsigned? (or other flags) |
---|
| 115 | ||||\------> (0) |
---|
| 116 | |||\-------> MIDI(0)/Light(1) |
---|
| 117 | ||\--------> MIDI and Light(1) |
---|
| 118 | |\---------> second set(1) |
---|
| 119 | \----------> (0) |
---|
| 120 | |
---|
| 121 | MIDI 0x60: |
---|
| 122 | 76543210 |
---|
| 123 | 0000 -> MIDI |
---|
| 124 | |
---|
| 125 | Light 0x70: |
---|
| 126 | 76543210 |
---|
| 127 | 0000 -> DMX512 |
---|
[1962] | 128 | 0001 -> RoarDMX |
---|
[1820] | 129 | |
---|
[0] | 130 | */ |
---|
| 131 | |
---|
| 132 | #define ROAR_CODEC_IS_SIGNED(x) (((x) & ROAR_CODEC_UNSIGNED) == 0 ? 1 : 0) |
---|
| 133 | #define ROAR_CODEC_BYTE_ORDER(x) ((x) & 0x03) |
---|
| 134 | |
---|
| 135 | #define ROAR_CODEC_UNSIGNED (1 << 2) |
---|
[733] | 136 | #define ROAR_CODEC_LE 0x01 |
---|
| 137 | #define ROAR_CODEC_BE 0x02 |
---|
| 138 | #define ROAR_CODEC_PDP 0x03 |
---|
[0] | 139 | |
---|
[733] | 140 | #define ROAR_CODEC_MSB 0x00 |
---|
| 141 | #define ROAR_CODEC_LSB 0x01 |
---|
| 142 | |
---|
| 143 | #define ROAR_CODEC_PCM 0x00 |
---|
| 144 | #define ROAR_CODEC_PCM_S_LE (ROAR_CODEC_PCM | ROAR_CODEC_LE ) |
---|
| 145 | #define ROAR_CODEC_PCM_S_BE (ROAR_CODEC_PCM | ROAR_CODEC_BE ) |
---|
| 146 | #define ROAR_CODEC_PCM_S_PDP (ROAR_CODEC_PCM | ROAR_CODEC_PDP) |
---|
[0] | 147 | |
---|
| 148 | #define ROAR_CODEC_PCM_U_LE (ROAR_CODEC_PCM_S_LE | ROAR_CODEC_UNSIGNED) |
---|
| 149 | #define ROAR_CODEC_PCM_U_BE (ROAR_CODEC_PCM_S_BE | ROAR_CODEC_UNSIGNED) |
---|
| 150 | #define ROAR_CODEC_PCM_U_PDP (ROAR_CODEC_PCM_S_PDP | ROAR_CODEC_UNSIGNED) |
---|
| 151 | |
---|
[318] | 152 | #define ROAR_CODEC_MIDI_FILE 0x08 |
---|
| 153 | |
---|
| 154 | #define ROAR_CODEC_OGG_VORBIS 0x10 |
---|
| 155 | #define ROAR_CODEC_FLAC 0x11 /* native FLAC without Ogg container */ |
---|
| 156 | #define ROAR_CODEC_OGG_SPEEX 0x12 |
---|
| 157 | /* #define ROAR_CODEC_CELT/OGG_CELT 0x13 Reserved for CELT */ |
---|
| 158 | #define ROAR_CODEC_OGG_FLAC 0x14 |
---|
| 159 | #define ROAR_CODEC_OGG_GENERAL 0x15 |
---|
| 160 | |
---|
[329] | 161 | #define ROAR_CODEC_ROAR_CELT 0x1a |
---|
| 162 | #define ROAR_CODEC_ROAR_SPEEX 0x1b |
---|
| 163 | |
---|
[879] | 164 | #define ROAR_CODEC_RAUM 0x1c |
---|
| 165 | #define ROAR_CODEC_RAUM_VORBIS 0x1d |
---|
[2332] | 166 | #define ROAR_CODEC_RAUM_FLAC 0x1e |
---|
[560] | 167 | |
---|
| 168 | #define ROAR_CODEC_RIFF_WAVE 0x20 |
---|
| 169 | |
---|
[733] | 170 | #define ROAR_CODEC_ALAW 0x30 |
---|
| 171 | #define ROAR_CODEC_MULAW 0x34 |
---|
| 172 | |
---|
[1211] | 173 | // Meta Codecs: |
---|
| 174 | #define ROAR_CODEC_META_VCLT 0x40 /* VCLT = Vorbis Comment Like Text */ |
---|
| 175 | #define ROAR_CODEC_META_RALT 0x44 /* RALT = RoarAudio Like Text */ |
---|
| 176 | #define ROAR_CODEC_META_RALB 0x4c /* RALB = RoarAudio Like Binary */ |
---|
| 177 | /* if no byte order is given then you |
---|
| 178 | should assume BE as it is network |
---|
| 179 | byte order */ |
---|
| 180 | #define ROAR_CODEC_META_RALB_LE (ROAR_CODEC_META_RALB | ROAR_CODEC_LE) |
---|
| 181 | #define ROAR_CODEC_META_RALB_BE (ROAR_CODEC_META_RALB | ROAR_CODEC_BE) |
---|
| 182 | #define ROAR_CODEC_META_RALB_PDP (ROAR_CODEC_META_RALB | ROAR_CODEC_PDP) |
---|
[733] | 183 | |
---|
[1294] | 184 | // Container Codecs: |
---|
| 185 | /* |
---|
| 186 | Container 0x50: |
---|
| 187 | 76543210 |
---|
| 188 | 0000 0x50 -> Null container: pass |
---|
| 189 | 0001 0x51 -> Gzip |
---|
| 190 | 0010 0x52 -> Bzip2 |
---|
| 191 | 0011 0x53 -> OpenPGP bin |
---|
| 192 | 0100 0x54 -> OpenPGP asc |
---|
| 193 | 0101 0x55 -> TAR |
---|
| 194 | */ |
---|
| 195 | #define ROAR_CODEC_CONT_NULL 0x50 |
---|
| 196 | #define ROAR_CODEC_CONT_BASE ROAR_CODEC_CONT_NULL |
---|
| 197 | #define ROAR_CODEC_CONT_GZIP 0x51 |
---|
| 198 | #define ROAR_CODEC_CONT_BZIP2 0x52 |
---|
| 199 | #define ROAR_CODEC_CONT_OPGPBIN 0x53 |
---|
| 200 | #define ROAR_CODEC_CONT_OPGPASC 0x54 |
---|
| 201 | #define ROAR_CODEC_CONT_TAR 0x55 |
---|
| 202 | |
---|
[1820] | 203 | |
---|
| 204 | #define ROAR_CODEC_MIDI 0x60 |
---|
| 205 | #define ROAR_CODEC_DMX512 0x70 |
---|
[1962] | 206 | #define ROAR_CODEC_ROARDMX 0x71 |
---|
[1820] | 207 | |
---|
[0] | 208 | #if BYTE_ORDER == BIG_ENDIAN |
---|
| 209 | |
---|
[870] | 210 | #define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_BE |
---|
| 211 | |
---|
[0] | 212 | #define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_BE |
---|
| 213 | #define ROAR_BE2DEF(x) (x) |
---|
| 214 | |
---|
| 215 | #elif BYTE_ORDER == LITTLE_ENDIAN |
---|
| 216 | |
---|
[870] | 217 | #define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_LE |
---|
| 218 | |
---|
[0] | 219 | #define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_LE |
---|
| 220 | #define ROAR_LE2DEF(x) (x) |
---|
| 221 | |
---|
| 222 | #else |
---|
| 223 | |
---|
[870] | 224 | #define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_PDP |
---|
| 225 | |
---|
[0] | 226 | #define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_PDP |
---|
| 227 | #define ROAR_PDP2DEF(x) (x) |
---|
| 228 | |
---|
| 229 | #endif |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | #define ROAR_CODEC_NATIVE ROAR_CODEC_DEFAULT |
---|
| 233 | |
---|
| 234 | #define ROAR_BITS_MAX 32 |
---|
| 235 | |
---|
[1062] | 236 | #ifndef ROAR_BITS_DEFAULT |
---|
[0] | 237 | #define ROAR_BITS_DEFAULT 16 |
---|
[1062] | 238 | #endif |
---|
| 239 | #ifndef ROAR_CHANNELS_DEFAULT |
---|
[0] | 240 | #define ROAR_CHANNELS_DEFAULT 2 |
---|
[1062] | 241 | #endif |
---|
| 242 | #ifndef ROAR_RATE_DEFAULT |
---|
[0] | 243 | #define ROAR_RATE_DEFAULT 44100 |
---|
[1062] | 244 | #endif |
---|
[0] | 245 | |
---|
[2398] | 246 | #define ROAR_MIDI_TICKS_PER_BEAT 96 |
---|
| 247 | #define ROAR_MIDI_BITS 8 |
---|
| 248 | #define ROAR_MIDI_CHANNELS_DEFAULT 16 |
---|
| 249 | |
---|
[16] | 250 | #define ROAR_MAX_CHANNELS 64 |
---|
| 251 | |
---|
[17] | 252 | #define ROAR_SET_VOL_ALL 1 |
---|
| 253 | #define ROAR_SET_VOL_ONE 2 |
---|
| 254 | |
---|
[393] | 255 | |
---|
[394] | 256 | #define ROAR_SPEEX_MAX_CC 256 |
---|
[622] | 257 | #define ROAR_SPEEX_MAGIC "RoarSpeex" |
---|
| 258 | #define ROAR_SPEEX_MAGIC_LEN 9 |
---|
[393] | 259 | #define ROAR_SPEEX_MODE_NB 1 |
---|
| 260 | #define ROAR_SPEEX_MODE_WB 2 |
---|
| 261 | #define ROAR_SPEEX_MODE_UWB 3 |
---|
| 262 | |
---|
[636] | 263 | #define ROAR_CELT_MAGIC "RoarCELT0" |
---|
| 264 | #define ROAR_CELT_MAGIC_LEN 9 |
---|
[393] | 265 | |
---|
[0] | 266 | struct roar_audio_info { |
---|
| 267 | unsigned int rate; |
---|
| 268 | unsigned int bits; |
---|
| 269 | unsigned int channels; |
---|
| 270 | unsigned int codec; |
---|
| 271 | }; |
---|
| 272 | |
---|
| 273 | struct roar_mixer_settings { |
---|
[17] | 274 | //unsigned channels; |
---|
[0] | 275 | roar_intm16 scale; |
---|
[319] | 276 | roar_intm16 rpg_mul; // rpg = ReplayGain |
---|
| 277 | roar_intm16 rpg_div; |
---|
[16] | 278 | roar_intm16 mixer[ROAR_MAX_CHANNELS]; |
---|
[0] | 279 | }; |
---|
| 280 | |
---|
[1671] | 281 | #define ROAR_MIXER(x) ((struct roar_mixer_settings *)x) |
---|
| 282 | |
---|
[0] | 283 | #endif |
---|
| 284 | |
---|
| 285 | //ll |
---|