mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-24 06:10:09 +01:00
dox2-src
help
images
lib-src
FileDialog
expat
ffmpeg
iAVC
id3lib
lib-widget-extra
libflac
libid3tag
liblrdf
libmad
libnyquist
libogg
libraptor
libresample
libsamplerate
libscorealign
libsndfile
libsoxr
libvamp
libvorbis
include
lib
books
modes
Makefile.am
Makefile.in
analysis.c
backends.h
barkmel.c
bitrate.c
bitrate.h
block.c
codebook.c
codebook.h
codec_internal.h
envelope.c
envelope.h
floor0.c
floor1.c
highlevel.h
info.c
lookup.c
lookup.h
lookup_data.h
lookups.pl
lpc.c
lpc.h
lsp.c
lsp.h
mapping0.c
masking.h
mdct.c
mdct.h
misc.h
os.h
psy.c
psy.h
psytune.c
registry.c
registry.h
res0.c
scales.h
sharedbook.c
smallft.c
smallft.h
synthesis.c
tone.c
vorbisenc.c
vorbisfile.c
window.c
window.h
macos
macosx
symbian
vq
win32
AUTHORS
CHANGES
COPYING
Makefile.am
Makefile.in
README
acinclude.m4
autogen.sh
config.guess
config.h.in
config.sub
configure
configure.in
depcomp
install-sh
libvorbis.spec.in
local-libogg.patch
ltmain.sh
missing
no-docs-examples.patch
todo.txt
vorbis-uninstalled.pc.in
vorbis.m4
vorbis.pc.in
vorbisenc-uninstalled.pc.in
vorbisenc.pc.in
vorbisfile-uninstalled.pc.in
vorbisfile.pc.in
mod-null
mod-nyq-bench
mod-script-pipe
mod-track-panel
portaudio-v19
portburn
portmidi
portmixer
portsmf
redland
rtaudio
sbsms
slv2
soundtouch
taglib
twolame
Makefile.in
audacity-patches.txt
locale
m4
mac
nyquist
plug-ins
presets
qa
scripts
src
tests
win
LICENSE.txt
Makefile.in
README.txt
audacity.dox
autogen.sh
config.guess
config.sub
configure
configure.in
install-sh
todo.txt
87 lines
2.7 KiB
C
87 lines
2.7 KiB
C
/********************************************************************
|
|
* *
|
|
* 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-2007 *
|
|
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
|
* *
|
|
********************************************************************
|
|
|
|
function: linear scale -> dB, Bark and Mel scales
|
|
last mod: $Id: scales.h,v 1.7 2008-02-02 15:53:54 richardash1981 Exp $
|
|
|
|
********************************************************************/
|
|
|
|
#ifndef _V_SCALES_H_
|
|
#define _V_SCALES_H_
|
|
|
|
#include <math.h>
|
|
#include "os.h"
|
|
|
|
/* 20log10(x) */
|
|
#define VORBIS_IEEE_FLOAT32 1
|
|
#ifdef VORBIS_IEEE_FLOAT32
|
|
|
|
static float unitnorm(float x){
|
|
union {
|
|
ogg_uint32_t i;
|
|
float f;
|
|
} ix;
|
|
ix.f = x;
|
|
ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
|
|
return ix.f;
|
|
}
|
|
|
|
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */
|
|
static float todB(const float *x){
|
|
union {
|
|
ogg_uint32_t i;
|
|
float f;
|
|
} ix;
|
|
ix.f = *x;
|
|
ix.i = ix.i&0x7fffffff;
|
|
return (float)(ix.i * 7.17711438e-7f -764.6161886f);
|
|
}
|
|
|
|
#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.34294480f)
|
|
#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
|
|
|
|
#endif
|
|
|
|
#define fromdB(x) (exp((x)*.11512925f))
|
|
|
|
/* 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 - 30kHz (nyquist) or so.
|
|
|
|
all f in Hz, z in Bark */
|
|
|
|
#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
|
|
#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
|
|
#define toMEL(n) (log(1.f+(n)*.001f)*1442.695f)
|
|
#define fromMEL(m) (1000.f*exp((m)/1442.695f)-1000.f)
|
|
|
|
/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave
|
|
0.0 */
|
|
|
|
#define toOC(n) (log(n)*1.442695f-5.965784f)
|
|
#define fromOC(o) (exp(((o)+5.965784f)*.693147f))
|
|
|
|
#endif
|
|
|