Math Macros

mathematical operations and values needed for functions within this library More...

Defines

#define PI   3.141592653589793238462643
#define TWO_PI   6.28318530717958647692
#define INV_TWO_PI   (1 / TWO_PI)
#define PI_2   1.57079632679489661923
#define LOG2   0.69314718055994529
#define LOG10   2.3025850929940459
#define EXP   2.7182818284590451
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 returns the maximum of a and b
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 returns the minimum of a and b

Functions

sfloat sms_magToDB (sfloat x)
 convert from magnitude to decibel
sfloat sms_dBToMag (sfloat x)
 convert from decibel to magnitude
void sms_arrayMagToDB (int sizeArray, sfloat *pArray)
 convert an array from magnitude to decibel
void sms_arrayDBToMag (int sizeArray, sfloat *pArray)
 convert and array from decibel (0-100) to magnitude (0-1)
void sms_setMagThresh (sfloat x)
 set the linear magnitude threshold
sfloat sms_rms (int sizeArray, sfloat *pArray)
 Root Mean Squared of an array.
sfloat sms_sine (sfloat fTheta)
 table-lookup sine method
sfloat sms_sinc (sfloat fTheta)
 global sinc table-lookup method
sfloat sms_random (void)
 random number genorator
int sms_power2 (int n)
 make sure a number is a power of 2
sfloat sms_scalarTempered (float x)
void sms_arrayScalarTempered (int sizeArray, sfloat *pArray)
 scale an array of linear frequencies to the well-tempered scale

Detailed Description

mathematical operations and values needed for functions within this library


Define Documentation

#define EXP   2.7182818284590451

Eurler's number

Referenced by sms_dCepstrumEnvelope().

#define INV_TWO_PI   (1 / TWO_PI)

1 / ( pi * 2)

Referenced by SineSynthIFFT(), sms_deterministic(), and sms_sine().

#define LOG10   2.3025850929940459

natural logarithm of 10

#define LOG2   0.69314718055994529

natural logarithm of 2

Referenced by InitializeHybrid().

#define MAX ( a,
 )     ((a) > (b) ? (a) : (b))
#define MIN ( a,
 )     ((a) < (b) ? (a) : (b))

returns the minimum of a and b

Referenced by FillGap(), sms_analyze(), sms_copyFrame(), sms_detectPeaks(), and sms_spectralApprox().

#define PI   3.141592653589793238462643

pi

Referenced by GetPhaseVal(), Hanning(), and sms_dCepstrum().

#define PI_2   1.57079632679489661923
#define TWO_PI   6.28318530717958647692

Function Documentation

void sms_arrayDBToMag ( int  sizeArray,
sfloat *  pArray 
)

convert and array from decibel (0-100) to magnitude (0-1)

depends on the magnitude threshold

See also:
sms_setMagThresh
Parameters:
sizeArray size of array
pArray pointer to array

References sms_dBToMag().

Referenced by sms_analyze().

Here is the call graph for this function:

void sms_arrayMagToDB ( int  sizeArray,
sfloat *  pArray 
)

convert an array from magnitude to decibel

Depends on a linear threshold that indicates the bottom end of the dB scale (magnutdes at this value will convert to zero).

See also:
sms_setMagThresh
Parameters:
sizeArray size of array
pArray pointer to array

References sms_magToDB().

Referenced by sms_analyzeFrame().

Here is the call graph for this function:

void sms_arrayScalarTempered ( int  sizeArray,
sfloat *  pArray 
)

scale an array of linear frequencies to the well-tempered scale

Parameters:
sizeArray size of the array
pArray pointer to array of frequencies

References sms_scalarTempered().

Here is the call graph for this function:

sfloat sms_dBToMag ( sfloat  x  ) 

convert from decibel to magnitude

Parameters:
x decibel (0-100)
Returns:
magnitude (0-1)

References mag_thresh.

Referenced by SinePhaSynth(), SineSynth(), sms_arrayDBToMag(), and sms_scaleDet().

sfloat sms_magToDB ( sfloat  x  ) 

convert from magnitude to decibel

Parameters:
x magnitude (0:1)
Returns:
decibel (0: -100)

References inv_mag_thresh, mag_thresh, and TWENTY_OVER_LOG10.

Referenced by sms_arrayMagToDB(), and sms_scaleDet().

int sms_power2 ( int  n  ) 

make sure a number is a power of 2

Returns:
a power of two integer >= input value

Referenced by sms_analyze(), sms_analyzeFrame(), sms_dCepstrumEnvelope(), sms_initAnalysis(), sms_initSynth(), sms_invSpectrum(), sms_spectrum(), sms_spectrumMag(), and sms_stocAnalysis().

sfloat sms_random ( void   ) 

random number genorator

Returns:
random number between -1 and 1

References genrand_real1(), INV_HALF_MAX, and sfloat.

Referenced by SineSynth(), SineSynthIFFT(), sms_deterministic(), sms_stochastic(), and StocSynthApprox().

Here is the call graph for this function:

sfloat sms_rms ( int  sizeArray,
sfloat *  pArray 
)

Root Mean Squared of an array.

Returns:
RMS energy

References sfloat.

sfloat sms_scalarTempered ( float  x  ) 
Todo:
remove this define now that there is sms_scalerTempered
void sms_setMagThresh ( sfloat  x  ) 

set the linear magnitude threshold

magnitudes below this will go to zero when converted to db. it is limited to 0.00001 (-100db)

Parameters:
x threshold value

References inv_mag_thresh, and mag_thresh.

sfloat sms_sinc ( sfloat  fTheta  ) 

global sinc table-lookup method

fTheta has to be from 0 to 8

Parameters:
fTheta angle in radians
Returns:
approximately sinc(fTheta)

References fSincScale, and sms_tab_sinc.

Referenced by SineSynthIFFT(), and sms_deterministic().

sfloat sms_sine ( sfloat  fTheta  ) 

table-lookup sine method

Parameters:
fTheta angle in radians
Returns:
approximately sin(fTheta)

References fSineIncr, INV_TWO_PI, sms_tab_sine, and TWO_PI.

Referenced by SineSynth(), SineSynthIFFT(), sms_dCepstrum(), and sms_deterministic().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Thu Oct 29 04:08:07 2009 for libsms by  doxygen 1.6.1