/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE . *
* USE , DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD - STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN ' COPYING ' . PLEASE READ THESE TERMS BEFORE DISTRIBUTING . *
* *
* THE OggVorbis SOURCE CODE IS ( C ) COPYRIGHT 1994 - 2009 *
* by the Xiph . Org Foundation https : //xiph.org/ *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
function : linear scale - > dB , Bark and Mel scales
********************************************************************/
#ifndef _V_SCALES_H_
#define _V_SCALES_H_
#include <math.h>
#include "os.h"
#ifdef _MSC_VER
/* MS Visual Studio doesn't have C99 inline keyword. */
#define inline __inline
#endif
/* 20log10(x) */
#define VORBIS_IEEE_FLOAT32 1
#ifdef VORBIS_IEEE_FLOAT32
static inline float unitnorm(float x){
union {
ogg_uint32_t i;
float f;
} ix;
ix.f = x;
ix.i = (ix.i & 0 x80000000U) | (0 x3f800000U);
return ix.f;
}
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */
static inline float todB(const float *x){
union {
ogg_uint32_t i;
float f;
} ix;
ix.f = *x;
ix.i = ix.i&0 x7fffffff;
return (float )(ix.i * 7 .17711438 e-7 f -764 .6161886 f);
}
#define todB_nn(x) todB(x)
#else
static float unitnorm(float x){
if (x<0 )return (-1 .f);
return (1 .f);
}
#define todB(x) (*(x)==0 ?-400 .f:log(*(x)**(x))*4 .34294480 f)
#define todB_nn(x) (*(x)==0 .f?-400 .f:log(*(x))*8 .6858896 f)
#endif
#define fromdB(x) (exp((x)*.11512925 f))
/* The bark scale equations are approximations, since the original
table was somewhat hand rolled . The below are chosen to have the
best possible fit to the rolled tables , thus their somewhat odd
appearance ( these are more accurate and over a longer range than
the oft - quoted bark equations found in the texts I have ) . The
approximations are valid from 0 - 30 kHz ( nyquist ) or so .
all f in Hz, z in Bark */
#define toBARK(n) (13 .1 f*atan(.00074 f*(n))+2 .24 f*atan((n)*(n)*1 .85 e-8 f)+1 e-4 f*(n))
#define fromBARK(z) (102 .f*(z)-2 .f*pow(z,2 .f)+.4 f*pow(z,3 .f)+pow(1 .46 f,z)-1 .f)
#define toMEL(n) (log(1 .f+(n)*.001 f)*1442 .695 f)
#define fromMEL(m) (1000 .f*exp((m)/1442 .695 f)-1000 .f)
/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave
0.0 */
#define toOC(n) (log(n)*1 .442695 f-5 .965784 f)
#define fromOC(o) (exp(((o)+5 .965784 f)*.693147 f))
#endif
Messung V0.5 in Prozent C=93 H=100 G=96
¤ Dauer der Verarbeitung: 0.4 Sekunden
¤
*© Formatika GbR, Deutschland