"L. Spiro Engine"
|
00001 00018 #ifndef __LSS_VORBISCONSTANTS_H__ 00019 #define __LSS_VORBISCONSTANTS_H__ 00020 00021 #include "../LSSSoundLib.h" 00022 00023 00024 // General. 00025 #define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.2" 00026 #define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20101101 (Schaufenugget)" 00027 00028 00029 00030 // Vorbis PSY. 00031 #define P_BANDS 17 /* 62Hz to 16kHz */ 00032 #define P_LEVELS 8 /* 30dB to 100dB */ 00033 #define P_LEVEL_0 30.0f /* 30 dB */ 00034 #define P_NOISECURVES 3 00035 00036 #define NOISE_COMPAND_LEVELS 40 00037 00038 // Vorbis MDCT 00039 #define DATA_TYPE LSFLOAT 00040 #define REG_TYPE LSFLOAT 00041 #define cPI3_8 0.38268343236508977175f 00042 #define cPI2_8 0.70710678118654752441f 00043 #define cPI1_8 0.92387953251128675613f 00044 00045 #define FLOAT_CONV( X ) static_cast<LSFLOAT>(X) 00046 #define MULT_NORM( X ) (X) 00047 #define HALVE(X) ((X) * 0.5f) 00048 00049 #define rint( X ) (::floor( (X) + 0.5f )) 00050 00051 00052 #define fromdB( X ) (::exp( (X) * 0.11512925f )) 00053 00054 // The bark scale equations are approximations, since the original 00055 // table was somewhat hand rolled. The below are chosen to have the 00056 // best possible fit to the rolled tables, thus their somewhat odd 00057 // appearance (these are more accurate and over a longer range than 00058 // the oft-quoted bark equations found in the texts I have). The 00059 // approximations are valid from 0 - 30kHz (nyquist) or so. 00060 // All f in Hz, z in Bark. 00061 00062 #define toBARK(N) (13.1f * ::atan( 0.00074f * (N) ) + 2.24f * ::atan( (N) * (N) * 1.85e-8f ) + 1e-4f * (N)) 00063 #define fromBARK(Z) (102.0f * (Z) - 2.0f * ::pow( Z, 2.0f ) + 0.4f * ::pow( Z, 3.0f ) + ::pow( 1.46f, Z ) - 1.0f) 00064 #define toMEL(N) (::log( 1.0f + (N) * 0.001f ) * 1442.695f) 00065 #define fromMEL(M) (1000.0f * ::exp( (M) / 1442.695f ) - 1000.0f) 00066 00067 // Frequency to octave. We arbitrarily declare 63.5 Hz to be octave 0.0. 00068 #define toOC(N) (::log( N ) * 1.442695f - 5.965784f) 00069 #define fromOC(O) (::exp( ((O) + 5.965784f) * 0.693147f )) 00070 00071 #define NEGINF -9999.0f 00072 00073 00074 namespace lss { 00075 00076 // == Types. 00080 enum { 00081 NOTOPEN = 0, 00082 PARTOPEN = 1, 00083 OPENED = 2, 00084 STREAMSET = 3, 00085 INITSET = 4, 00086 00087 CHUNKSIZE = 65536, 00088 READSIZE = 2048, 00089 }; 00093 enum { 00094 VE_PRE = 16, 00095 VE_WIN = 4, 00096 VE_POST = 2, 00097 VE_AMP = (VE_PRE + VE_POST - 1), 00098 00099 VE_BANDS = 7, 00100 VE_NEARDC = 15, 00101 00102 VE_MINSTRETCH = 2, // A bit less than short block. 00103 VE_MAXSTRETCH = 12, // one-third full block. 00104 }; 00105 00109 enum LSS_VORBIS_BLOCK_SETTINGS { 00110 BLOCKTYPE_IMPULSE = 0, 00111 BLOCKTYPE_PADDING = 1, 00112 BLOCKTYPE_TRANSITION = 0, 00113 BLOCKTYPE_LONG = 1, 00114 }; 00115 00119 enum LSS_VORBIS_PACKET { 00120 PACKETBLOBS = 15 00121 }; 00122 00126 enum LSS_VORBIS_BACKEND { 00127 VIF_POSIT = 63, 00128 VIF_CLASS = 16, 00129 VIF_PARTS = 31, 00130 }; 00131 00135 enum LSS_VORBIS_MASKING { 00136 MAX_ATH = 88, 00137 00138 EHMER_OFFSET = 16, 00139 EHMER_MAX = 56, 00140 }; 00141 00145 enum LSS_CODE_BOOK { 00146 // 32 bit float (not IEEE; nonnormalized mantissa + 00147 // biased exponent): neeeeeee eeemmmmm mmmmmmmm mmmmmmmm 00148 // Why not IEEE? It's just not that important here. 00149 VQ_FEXP = 10, 00150 VQ_FMAN = 21, 00151 VQ_FEXP_BIAS = 768, // Bias toward values smaller than 1. 00152 }; 00153 00157 enum LSS_BLOCKS { 00158 WORD_ALIGN = 8 00159 }; 00160 00164 enum LSS_REGISTRY { 00165 VI_TRANSFORMB = 1, 00166 VI_WINDOWB = 1, 00167 VI_TIMEB = 1, 00168 VI_FLOORB = 2, 00169 VI_RESB = 3, 00170 VI_MAPB = 1, 00171 }; 00172 00179 class CVorbisConstants { 00180 public : 00181 // == Members. 00185 static const LSDOUBLE stereo_threshholds[]; 00186 00190 static const LSDOUBLE stereo_threshholds_limited[]; 00191 00195 static LSFLOAT FLOOR1_fromdB_LOOKUP[256]; 00196 00197 00198 // == Functions. 00205 static LSFLOAT unitnorm( LSFLOAT _fX ); 00206 00213 static LSFLOAT todB( const LSFLOAT * _pfX ); 00214 #define todB_nn( X ) todB( X ) 00215 00216 }; 00217 00218 } // namespace lss 00219 00220 #endif // __LSS_VORBISCONSTANTS_H__