[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 |
---|
[560] | 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) |
---|
[318] | 44 | |
---|
[733] | 45 | BB = Byte order / MSB/LSB |
---|
| 46 | |
---|
[318] | 47 | MIDI 0x08: |
---|
| 48 | 76543210 |
---|
| 49 | 000 0x08 -> MIDI File |
---|
| 50 | |
---|
| 51 | hi-level 0x10: |
---|
| 52 | 76543210 |
---|
| 53 | 0000 0x10 -> Ogg Vorbis |
---|
| 54 | 0001 0x11 -> Native FLAC |
---|
| 55 | 0010 0x12 -> Ogg Speex |
---|
| 56 | 0011 0x13 -> Reserved for CELT |
---|
| 57 | 0100 0x14 -> Ogg FLAC |
---|
| 58 | 0101 0x15 -> Ogg General |
---|
[329] | 59 | 0110 0x16 -> Ogg CELT |
---|
| 60 | [...] |
---|
| 61 | **** 0x1a -> ROAR CELT |
---|
| 62 | **** 0x1b -> ROAR SPEEX |
---|
[560] | 63 | |
---|
| 64 | RIFF/WAVE like 0x20: |
---|
| 65 | 76543210 |
---|
[733] | 66 | 0000 0x20 -> RIFF/WAVE |
---|
| 67 | |
---|
| 68 | LOG Codecs 0x30: |
---|
| 69 | 76543210 |
---|
| 70 | 00BB 0x30 -> A-Law (base) |
---|
| 71 | 01BB 0x34 -> mu-Law (base) |
---|
[0] | 72 | */ |
---|
| 73 | |
---|
| 74 | #define ROAR_CODEC_IS_SIGNED(x) (((x) & ROAR_CODEC_UNSIGNED) == 0 ? 1 : 0) |
---|
| 75 | #define ROAR_CODEC_BYTE_ORDER(x) ((x) & 0x03) |
---|
| 76 | |
---|
| 77 | #define ROAR_CODEC_UNSIGNED (1 << 2) |
---|
[733] | 78 | #define ROAR_CODEC_LE 0x01 |
---|
| 79 | #define ROAR_CODEC_BE 0x02 |
---|
| 80 | #define ROAR_CODEC_PDP 0x03 |
---|
[0] | 81 | |
---|
[733] | 82 | #define ROAR_CODEC_MSB 0x00 |
---|
| 83 | #define ROAR_CODEC_LSB 0x01 |
---|
| 84 | |
---|
| 85 | #define ROAR_CODEC_PCM 0x00 |
---|
| 86 | #define ROAR_CODEC_PCM_S_LE (ROAR_CODEC_PCM | ROAR_CODEC_LE ) |
---|
| 87 | #define ROAR_CODEC_PCM_S_BE (ROAR_CODEC_PCM | ROAR_CODEC_BE ) |
---|
| 88 | #define ROAR_CODEC_PCM_S_PDP (ROAR_CODEC_PCM | ROAR_CODEC_PDP) |
---|
[0] | 89 | |
---|
| 90 | #define ROAR_CODEC_PCM_U_LE (ROAR_CODEC_PCM_S_LE | ROAR_CODEC_UNSIGNED) |
---|
| 91 | #define ROAR_CODEC_PCM_U_BE (ROAR_CODEC_PCM_S_BE | ROAR_CODEC_UNSIGNED) |
---|
| 92 | #define ROAR_CODEC_PCM_U_PDP (ROAR_CODEC_PCM_S_PDP | ROAR_CODEC_UNSIGNED) |
---|
| 93 | |
---|
[318] | 94 | #define ROAR_CODEC_MIDI_FILE 0x08 |
---|
| 95 | |
---|
| 96 | #define ROAR_CODEC_OGG_VORBIS 0x10 |
---|
| 97 | #define ROAR_CODEC_FLAC 0x11 /* native FLAC without Ogg container */ |
---|
| 98 | #define ROAR_CODEC_OGG_SPEEX 0x12 |
---|
| 99 | /* #define ROAR_CODEC_CELT/OGG_CELT 0x13 Reserved for CELT */ |
---|
| 100 | #define ROAR_CODEC_OGG_FLAC 0x14 |
---|
| 101 | #define ROAR_CODEC_OGG_GENERAL 0x15 |
---|
| 102 | |
---|
[329] | 103 | #define ROAR_CODEC_ROAR_CELT 0x1a |
---|
| 104 | #define ROAR_CODEC_ROAR_SPEEX 0x1b |
---|
| 105 | |
---|
[879] | 106 | #define ROAR_CODEC_RAUM 0x1c |
---|
| 107 | #define ROAR_CODEC_RAUM_VORBIS 0x1d |
---|
[560] | 108 | |
---|
| 109 | #define ROAR_CODEC_RIFF_WAVE 0x20 |
---|
| 110 | |
---|
[733] | 111 | #define ROAR_CODEC_ALAW 0x30 |
---|
| 112 | #define ROAR_CODEC_MULAW 0x34 |
---|
| 113 | |
---|
| 114 | |
---|
[0] | 115 | #if BYTE_ORDER == BIG_ENDIAN |
---|
| 116 | |
---|
[870] | 117 | #define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_BE |
---|
| 118 | |
---|
[0] | 119 | #define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_BE |
---|
| 120 | #define ROAR_BE2DEF(x) (x) |
---|
| 121 | |
---|
| 122 | #elif BYTE_ORDER == LITTLE_ENDIAN |
---|
| 123 | |
---|
[870] | 124 | #define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_LE |
---|
| 125 | |
---|
[0] | 126 | #define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_LE |
---|
| 127 | #define ROAR_LE2DEF(x) (x) |
---|
| 128 | |
---|
| 129 | #else |
---|
| 130 | |
---|
[870] | 131 | #define ROAR_CODEC_NATIVE_ENDIAN ROAR_CODEC_PDP |
---|
| 132 | |
---|
[0] | 133 | #define ROAR_CODEC_DEFAULT ROAR_CODEC_PCM_PDP |
---|
| 134 | #define ROAR_PDP2DEF(x) (x) |
---|
| 135 | |
---|
| 136 | #endif |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | #define ROAR_CODEC_NATIVE ROAR_CODEC_DEFAULT |
---|
| 140 | |
---|
| 141 | #define ROAR_BITS_MAX 32 |
---|
| 142 | |
---|
| 143 | #define ROAR_BITS_DEFAULT 16 |
---|
| 144 | #define ROAR_CHANNELS_DEFAULT 2 |
---|
| 145 | #define ROAR_RATE_DEFAULT 44100 |
---|
| 146 | |
---|
[16] | 147 | #define ROAR_MAX_CHANNELS 64 |
---|
| 148 | |
---|
[17] | 149 | #define ROAR_SET_VOL_ALL 1 |
---|
| 150 | #define ROAR_SET_VOL_ONE 2 |
---|
| 151 | |
---|
[393] | 152 | |
---|
[394] | 153 | #define ROAR_SPEEX_MAX_CC 256 |
---|
[622] | 154 | #define ROAR_SPEEX_MAGIC "RoarSpeex" |
---|
| 155 | #define ROAR_SPEEX_MAGIC_LEN 9 |
---|
[393] | 156 | #define ROAR_SPEEX_MODE_NB 1 |
---|
| 157 | #define ROAR_SPEEX_MODE_WB 2 |
---|
| 158 | #define ROAR_SPEEX_MODE_UWB 3 |
---|
| 159 | |
---|
[636] | 160 | #define ROAR_CELT_MAGIC "RoarCELT0" |
---|
| 161 | #define ROAR_CELT_MAGIC_LEN 9 |
---|
[393] | 162 | |
---|
[0] | 163 | struct roar_audio_info { |
---|
| 164 | unsigned int rate; |
---|
| 165 | unsigned int bits; |
---|
| 166 | unsigned int channels; |
---|
| 167 | unsigned int codec; |
---|
| 168 | }; |
---|
| 169 | |
---|
| 170 | struct roar_mixer_settings { |
---|
[17] | 171 | //unsigned channels; |
---|
[0] | 172 | roar_intm16 scale; |
---|
[319] | 173 | roar_intm16 rpg_mul; // rpg = ReplayGain |
---|
| 174 | roar_intm16 rpg_div; |
---|
[16] | 175 | roar_intm16 mixer[ROAR_MAX_CHANNELS]; |
---|
[0] | 176 | }; |
---|
| 177 | |
---|
| 178 | #endif |
---|
| 179 | |
---|
| 180 | //ll |
---|