zenilib: zenilib/jni/external/openal-soft/utils/makehrtf.c File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros | Typedefs | Enumerations | Functions
makehrtf.c File Reference
`#include "config.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <stdarg.h>`
`#include <string.h>`
`#include <ctype.h>`
`#include <math.h>`
`#include "AL/al.h"`

Go to the source code of this file.

## Macros

#define | DEFAULT_EQUALIZE (1)
#define | DEFAULT_LIMIT (24.0)
#define | DEFAULT_SURFACE (1)
#define | DEFAULT_TRUNCSIZE (32)
#define | EPSILON (1e-15)
#define | FOURCC_DATA (0x61746164)
#define | FOURCC_FMT (0x20746D66)
#define | FOURCC_LIST (0x5453494C)
#define | FOURCC_RIFF (0x46464952)
#define | FOURCC_RIFX (0x58464952)
#define | FOURCC_SLNT (0x746E6C73)
#define | FOURCC_WAVE (0x45564157)
#define | FOURCC_WAVL (0x6C766177)
#define | M_PI (3.14159265358979323846)
#define | MAX_ASCII_BITS (32)
#define | MAX_AZ_COUNT (128)
#define | MAX_BIN_SIZE (4)
#define | MAX_DISTANCE (2.5)
#define | MAX_EV_COUNT (128)
#define | MAX_FFTSIZE (16384)
#define | MAX_HRTD (63.0)
#define | MAX_IDENT_LEN (16)
#define | MAX_LIMIT (120.0)
#define | MAX_PATH_LEN (256)
#define | MAX_POINTS (8192)
#define | MAX_RADIUS (0.15)
#define | MAX_RATE (96000)
#define | MAX_TRUNCSIZE (128)
#define | MAX_WAVE_CHANNELS (65535)
#define | MHR_FORMAT ("MinPHR01")
#define | MIN_ASCII_BITS (16)
#define | MIN_AZ_COUNT (1)
#define | MIN_BIN_BITS (16)
#define | MIN_BIN_SIZE (2)
#define | MIN_DISTANCE (0.5)
#define | MIN_EV_COUNT (5)
#define | MIN_FFTSIZE (512)
#define | MIN_LIMIT (2.0)
#define | MIN_POINTS (16)
#define | MIN_RADIUS (0.05)
#define | MIN_RATE (32000)
#define | MIN_TRUNCSIZE (8)
#define | MOD_TRUNCSIZE (8)
#define | TR_LOAD_SIZE (TR_RING_SIZE >> 2)
#define | TR_RING_BITS (16)
#define | TR_RING_MASK (TR_RING_SIZE - 1)
#define | TR_RING_SIZE (1 << TR_RING_BITS)
#define | WAVE_FORMAT_EXTENSIBLE (0xFFFE)
#define | WAVE_FORMAT_IEEE_FLOAT (0x0003)
#define | WAVE_FORMAT_PCM (0x0001)

## Typedefs

typedef enum ByteOrderT | ByteOrderT
typedef enum ElementTypeT | ElementTypeT
typedef struct HrirDataT | HrirDataT
typedef ALint | int4
typedef enum OutputFormatT | OutputFormatT
typedef struct ResamplerT | ResamplerT
typedef enum SourceFormatT | SourceFormatT
typedef struct SourceRefT | SourceRefT
typedef struct TokenReaderT | TokenReaderT
typedef unsigned int | uint
typedef ALubyte | uint1
typedef ALuint | uint4

## Enumerations

enum | ByteOrderT { BO_NONE = 0, BO_LITTLE, BO_BIG }
enum | ElementTypeT { ET_NONE = 0, ET_INT, ET_FP }
enum | OutputFormatT { OF_NONE = 0, OF_MHR, OF_TABLE }
enum | SourceFormatT { SF_NONE = 0, SF_WAVE, SF_BIN_LE, SF_BIN_BE, SF_ASCII }

## Functions

static void | AverageHrirMagnitude (const double *hrir, const double f, const uint ei, const uint ai, const HrirDataT *hData)
static double | BesselI_0 (const double x)
static void | CalcAzIndices (const HrirDataT *hData, const uint ei, const double az, uint *j0, uint *j1, double *jf)
static double | CalcKaiserBeta (const double rejection)
static uint | CalcKaiserOrder (const double rejection, const double transition)
static double | CalcLTD (const double ev, const double az, const double rad, const double dist)
static void | CalculateDfWeights (const HrirDataT *hData, double *weights)
static void | CalculateDiffuseFieldAverage (const HrirDataT *hData, const int weighted, const double limit, double *dfa)
static void | CalculateHrtds (HrirDataT *hData)
static double | Clamp (const double val, const double lower, const double upper)
static double | ComplexAbs (const double r, const double i)
static void | ComplexExp (const double inR, const double inI, double *outR, double *outI)
static void | ComplexMul (const double aR, const double aI, const double bR, const double bI, double *outR, double *outI)
static double * | CreateArray (const size_t n)
static void | DestroyArray (const double *a)
static void | DiffuseFieldEqualize (const double *dfa, const HrirDataT *hData)
static void | FftArrange (const uint n, const double *inR, const double *inI, double *outR, double *outI)
static void | FftForward (const uint n, const double *inR, const double *inI, double *outR, double *outI)
static void | FftInverse (const uint n, const double *inR, const double *inI, double *outR, double *outI)
static void | FftSummation (const uint n, const double s, double *re, double *im)
static uint | Gcd (const uint a, const uint b)
static void | Hilbert (const uint n, const double *in, double *outR, double *outI)
static int | HpTpdfDither (const double in, int *hpHist)
static double | Kaiser (const double b, const double k)
static double | Lerp (const double a, const double b, const double f)
static void | LimitMagnitudeResponse (const uint n, const double limit, const double *in, double *out)
static int | LoadAsciiSource (FILE *fp, const SourceRefT *src, const uint n, double *hrir)
static int | LoadBinarySource (FILE *fp, const SourceRefT *src, const ByteOrderT order, const uint n, double *hrir)
static int | LoadSource (SourceRefT *src, const uint hrirRate, const uint n, double *hrir)
static int | LoadWaveSource (FILE *fp, SourceRefT *src, const uint hrirRate, const uint n, double *hrir)
static void | MagnitudeResponse (const uint n, const double *inR, const double *inI, double *out)
int | main (const int argc, const char *argv[])
static ElementTypeT | MatchElementType (const char *ident)
static SourceFormatT | MatchSourceFormat (const char *ident)
static void | MinimumPhase (const uint n, const double *in, double *outR, double *outI)
static void | NormalizeHrirs (const HrirDataT *hData)
static int | ProcessDefinition (const char *inName, const uint outRate, const uint fftSize, const int equalize, const int surface, const double limit, const uint truncSize, const OutputFormatT outFormat, const char *outName)
static int | ProcessMetrics (TokenReaderT *tr, const uint fftSize, const uint truncSize, HrirDataT *hData)
static int | ProcessSources (TokenReaderT *tr, HrirDataT *hData)
static int | ReadAsciiAsDouble (TokenReaderT *tr, const char *filename, const ElementTypeT type, const uint bits, double *out)
static int | ReadBin4 (FILE *fp, const char *filename, const ByteOrderT order, const uint bytes, uint4 *out)
static int | ReadBin8 (FILE *fp, const char *filename, const ByteOrderT order, uint8 *out)
static int | ReadBinAsDouble (FILE *fp, const char *filename, const ByteOrderT order, const ElementTypeT type, const uint bytes, const int bits, double *out)
static int | ReadIndexPair (TokenReaderT *tr, const HrirDataT *hData, uint *ei, uint *ai)
static int | ReadSourceRef (TokenReaderT *tr, SourceRefT *src)
static int | ReadWaveData (FILE *fp, const SourceRefT *src, const ByteOrderT order, const uint n, double *hrir)
static int | ReadWaveFormat (FILE *fp, const ByteOrderT order, const uint hrirRate, SourceRefT *src)
static int | ReadWaveList (FILE *fp, const SourceRefT *src, const ByteOrderT order, const uint n, double *hrir)
static void | ReconstructHrirs (const HrirDataT *hData)
static void | ResampleHrirs (const uint rate, HrirDataT *hData)
static void | ResamplerClear (ResamplerT *rs)
static void | ResamplerRun (ResamplerT *rs, const uint inN, const double *in, const uint outN, double *out)
static void | ResamplerSetup (ResamplerT *rs, const uint srcRate, const uint dstRate)
static double | Sinc (const double x)
static double | SincFilter (const int l, const double b, const double gain, const double cutoff, const int i)
static int | StoreMhr (const HrirDataT *hData, const char *filename)
static int | StoreTable (const HrirDataT *hData, const char *filename)
static int | StrSubst (const char *in, const char *pat, const char *rep, const size_t maxLen, char *out)
static void | SynthesizeHrirs (HrirDataT *hData)
static void | TrError (const TokenReaderT *tr, const char *format,...)
static void | TrErrorAt (const TokenReaderT *tr, uint line, uint column, const char *format,...)
static void | TrErrorVA (const TokenReaderT *tr, uint line, uint column, const char *format, va_list argPtr)
static void | TrIndication (TokenReaderT *tr, uint *line, uint *column)
static int | TrIsOperator (TokenReaderT *tr, const char *op)
static int | TrLoad (TokenReaderT *tr)
static int | TrReadFloat (TokenReaderT *tr, const double loBound, const double hiBound, double *value)
static int | TrReadIdent (TokenReaderT *tr, const uint maxLen, char *ident)
static int | TrReadInt (TokenReaderT *tr, const int loBound, const int hiBound, int *value)
static int | TrReadOperator (TokenReaderT *tr, const char *op)
static int | TrReadString (TokenReaderT *tr, const uint maxLen, char *text)
static void | TrSetup (FILE *fp, const char *filename, TokenReaderT *tr)
static void | TrSkipLine (TokenReaderT *tr)
static int | TrSkipWhitespace (TokenReaderT *tr)
static int | WriteAscii (const char *out, FILE *fp, const char *filename)
static int | WriteBin4 (const ByteOrderT order, const uint bytes, const uint4 in, FILE *fp, const char *filename)

## Macro Definition Documentation

#define DEFAULT_EQUALIZE (1)

Definition at line 161 of file makehrtf.c.

Referenced by main().

#define DEFAULT_LIMIT (24.0)

Definition at line 163 of file makehrtf.c.

Referenced by main().

#define DEFAULT_SURFACE (1)

Definition at line 162 of file makehrtf.c.

Referenced by main().

#define DEFAULT_TRUNCSIZE (32)

Definition at line 164 of file makehrtf.c.

Referenced by main().

#define EPSILON (1e-15)

Definition at line 83 of file makehrtf.c.

Referenced by CalculateDiffuseFieldAverage(), MagnitudeResponse(), MinimumPhase(), and Sinc().

#define FOURCC_DATA (0x61746164)

Definition at line 171 of file makehrtf.c.

Referenced by ReadWaveList().

#define FOURCC_FMT (0x20746D66)

Definition at line 170 of file makehrtf.c.

Referenced by ReadWaveFormat().

#define FOURCC_LIST (0x5453494C)

Definition at line 172 of file makehrtf.c.

Referenced by ReadWaveList().

#define FOURCC_RIFF (0x46464952)

Definition at line 167 of file makehrtf.c.

Referenced by LoadWaveSource().

#define FOURCC_RIFX (0x58464952)

Definition at line 168 of file makehrtf.c.

Referenced by LoadWaveSource().

#define FOURCC_SLNT (0x746E6C73)

Definition at line 174 of file makehrtf.c.

Referenced by ReadWaveList().

#define FOURCC_WAVE (0x45564157)

Definition at line 169 of file makehrtf.c.

Referenced by LoadWaveSource().

#define FOURCC_WAVL (0x6C766177)

Definition at line 173 of file makehrtf.c.

Referenced by ReadWaveList().

#define M_PI (3.14159265358979323846)

Definition at line 75 of file makehrtf.c.

Referenced by CalcAzIndices(), CalcKaiserOrder(), CalcLTD(), CalculateDfWeights(), CalculateHrtds(), FftSummation(), Sinc(), and SynthesizeHrirs().

#define MAX_ASCII_BITS (32)

Definition at line 142 of file makehrtf.c.

Referenced by ReadSourceRef().

#define MAX_AZ_COUNT (128)

Definition at line 115 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MAX_BIN_SIZE (4)

Definition at line 133 of file makehrtf.c.

Referenced by ReadSourceRef().

#define MAX_DISTANCE (2.5)

Definition at line 124 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MAX_EV_COUNT (128)

Definition at line 111 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MAX_FFTSIZE (16384)

Definition at line 146 of file makehrtf.c.

Referenced by main().

#define MAX_HRTD (63.0)

Definition at line 182 of file makehrtf.c.

Referenced by StoreMhr(), and StoreTable().

#define MAX_IDENT_LEN (16)

Definition at line 95 of file makehrtf.c.

Referenced by ProcessMetrics(), and ReadSourceRef().

#define MAX_LIMIT (120.0)

Definition at line 150 of file makehrtf.c.

Referenced by main().

#define MAX_PATH_LEN (256)

Definition at line 98 of file makehrtf.c.

Referenced by ProcessDefinition(), and ReadSourceRef().

#define MAX_POINTS (8192)

Definition at line 107 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MAX_RADIUS (0.15)

Definition at line 119 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MAX_RATE (96000)

Definition at line 103 of file makehrtf.c.

Referenced by main(), and ProcessMetrics().

#define MAX_TRUNCSIZE (128)

Definition at line 154 of file makehrtf.c.

Referenced by main().

#define MAX_WAVE_CHANNELS (65535)

Definition at line 128 of file makehrtf.c.

Referenced by ReadSourceRef().

#define MHR_FORMAT ("MinPHR01")

Definition at line 186 of file makehrtf.c.

Referenced by StoreMhr().

#define MIN_ASCII_BITS (16)

Definition at line 141 of file makehrtf.c.

Referenced by ReadSourceRef().

#define MIN_AZ_COUNT (1)

Definition at line 114 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MIN_BIN_BITS (16)

Definition at line 137 of file makehrtf.c.

Referenced by ReadSourceRef().

#define MIN_BIN_SIZE (2)

Definition at line 132 of file makehrtf.c.

Referenced by ReadSourceRef().

#define MIN_DISTANCE (0.5)

Definition at line 123 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MIN_EV_COUNT (5)

Definition at line 110 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MIN_FFTSIZE (512)

Definition at line 145 of file makehrtf.c.

Referenced by main().

#define MIN_LIMIT (2.0)

Definition at line 149 of file makehrtf.c.

Referenced by main().

#define MIN_POINTS (16)

Definition at line 106 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MIN_RADIUS (0.05)

Definition at line 118 of file makehrtf.c.

Referenced by ProcessMetrics().

#define MIN_RATE (32000)

Definition at line 102 of file makehrtf.c.

Referenced by main(), and ProcessMetrics().

#define MIN_TRUNCSIZE (8)

Definition at line 153 of file makehrtf.c.

Referenced by main().

#define MOD_TRUNCSIZE (8)

Definition at line 158 of file makehrtf.c.

Referenced by main().

#define TR_LOAD_SIZE (TR_RING_SIZE >> 2)

Definition at line 91 of file makehrtf.c.

Referenced by TrLoad().

#define TR_RING_BITS (16)

Definition at line 86 of file makehrtf.c.

#define TR_RING_MASK (TR_RING_SIZE - 1)

Definition at line 88 of file makehrtf.c.

Referenced by TrIsOperator(), TrLoad(), TrReadFloat(), TrReadIdent(), TrReadInt(), TrReadOperator(), TrReadString(), TrSkipLine(), and TrSkipWhitespace().

#define TR_RING_SIZE (1 << TR_RING_BITS)

Definition at line 87 of file makehrtf.c.

Referenced by TrLoad().

#define WAVE_FORMAT_EXTENSIBLE (0xFFFE)

Definition at line 179 of file makehrtf.c.

Referenced by DSoundOpenCapture(), DSoundResetPlayback(), MakeExtensible(), and ReadWaveFormat().

#define WAVE_FORMAT_IEEE_FLOAT (0x0003)

Definition at line 178 of file makehrtf.c.

Referenced by ReadWaveFormat().

#define WAVE_FORMAT_PCM (0x0001)

Definition at line 177 of file makehrtf.c.

Referenced by DSoundOpenCapture(), DSoundResetPlayback(), MakeExtensible(), ReadWaveFormat(), WinMMOpenCapture(), WinMMOpenPlayback(), and WinMMResetPlayback().

## Typedef Documentation

typedef enum ByteOrderT ByteOrderT

Definition at line 239 of file makehrtf.c.

typedef enum ElementTypeT ElementTypeT

Definition at line 241 of file makehrtf.c.

typedef struct HrirDataT HrirDataT

Definition at line 246 of file makehrtf.c.

typedef ALint int4

Definition at line 224 of file makehrtf.c.

typedef enum OutputFormatT OutputFormatT

Definition at line 242 of file makehrtf.c.

typedef struct ResamplerT ResamplerT

Definition at line 247 of file makehrtf.c.

typedef enum SourceFormatT SourceFormatT

Definition at line 240 of file makehrtf.c.

typedef struct SourceRefT SourceRefT

Definition at line 245 of file makehrtf.c.

typedef struct TokenReaderT TokenReaderT

Definition at line 244 of file makehrtf.c.

typedef unsigned int uint

Definition at line 219 of file makehrtf.c.

typedef ALubyte uint1

Definition at line 222 of file makehrtf.c.

typedef ALuint uint4

Definition at line 225 of file makehrtf.c.

## Enumeration Type Documentation

enum ByteOrderT

Enumerator
BO_NONE |
BO_LITTLE |
BO_BIG |

Definition at line 189 of file makehrtf.c.

enum ElementTypeT

Enumerator
ET_NONE |
ET_INT |
ET_FP |

Definition at line 205 of file makehrtf.c.

enum OutputFormatT

Enumerator
OF_NONE |
OF_MHR |
OF_TABLE |

Definition at line 212 of file makehrtf.c.

enum SourceFormatT

Enumerator
SF_NONE |
SF_WAVE |
SF_BIN_LE |
SF_BIN_BE |
SF_ASCII |

Definition at line 196 of file makehrtf.c.

## Function Documentation

static void AverageHrirMagnitude | ( | const double * | hrir,
|  | const double | f,
|  | const uint | ei,
|  | const uint | ai,
|  | const HrirDataT * | hData
| ) |  |

static

Definition at line 1688 of file makehrtf.c.

References CreateArray(), DestroyArray(), FftForward(), i, j, Lerp(), m, MagnitudeResponse(), and NULL.

Referenced by ProcessSources().

static double BesselI_0 | ( | const double | x | ) |

static

Definition at line 1034 of file makehrtf.c.

References k, and term.

Referenced by Kaiser().

static void CalcAzIndices | ( | const HrirDataT * | hData,
|  | const uint | ei,
|  | const double | az,
|  | uint * | j0,
|  | uint * | j1,
|  | double * | jf
| ) |  |

static

Definition at line 1858 of file makehrtf.c.

References floor(), and M_PI.

Referenced by SynthesizeHrirs().

static double CalcKaiserBeta | ( | const double | rejection | ) |

static

Definition at line 1110 of file makehrtf.c.

Referenced by ResamplerSetup().

static uint CalcKaiserOrder | ( | const double | rejection,
|  | const double | transition
| ) |  |

static

Definition at line 1100 of file makehrtf.c.

References M_PI.

Referenced by ResamplerSetup().

static double CalcLTD | ( | const double | ev,
|  | const double | az,
|  | const double | rad,
|  | const double | dist
| ) |  |

static

Definition at line 1957 of file makehrtf.c.

References cos(), M_PI, and sin().

Referenced by CalculateHrtds().

static void CalculateDfWeights | ( | const HrirDataT * | hData,
|  | double * | weights
| ) |  |

static

Definition at line 1717 of file makehrtf.c.

References M_PI, and sin().

Referenced by CalculateDiffuseFieldAverage().

static void CalculateDiffuseFieldAverage | ( | const HrirDataT * | hData,
|  | const int | weighted,
|  | const double | limit,
|  | double * | dfa
| ) |  |

static

Definition at line 1752 of file makehrtf.c.

References CalculateDfWeights(), CreateArray(), DestroyArray(), EPSILON, i, j, LimitMagnitudeResponse(), m, and NULL.

Referenced by ProcessDefinition().

static void CalculateHrtds | ( | HrirDataT * | hData | ) |

static

Definition at line 1971 of file makehrtf.c.

References CalcLTD(), e, j, and M_PI.

Referenced by ProcessDefinition().

static double Clamp | ( | const double | val,
|  | const double | lower,
|  | const double | upper
| ) |  |

static

Definition at line 745 of file makehrtf.c.

Referenced by Kaiser(), and LimitMagnitudeResponse().

static double ComplexAbs | ( | const double | r,
|  | const double | i
| ) |  |

static

Definition at line 787 of file makehrtf.c.

Referenced by MagnitudeResponse().

static void ComplexExp | ( | const double | inR,
|  | const double | inI,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 798 of file makehrtf.c.

References cos(), e, and sin().

Referenced by MinimumPhase().

static void ComplexMul | ( | const double | aR,
|  | const double | aI,
|  | const double | bR,
|  | const double | bI,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 792 of file makehrtf.c.

Referenced by MinimumPhase().

static double* CreateArray | ( | const size_t | n | ) |

static

Definition at line 768 of file makehrtf.c.

References calloc, and NULL.

Referenced by AverageHrirMagnitude(), CalculateDiffuseFieldAverage(), MinimumPhase(), ProcessDefinition(), ProcessSources(), ReconstructHrirs(), ResamplerRun(), and ResamplerSetup().

static void DestroyArray | ( | const double * | a | ) |

static

Definition at line 780 of file makehrtf.c.

References free.

Referenced by AverageHrirMagnitude(), CalculateDiffuseFieldAverage(), MinimumPhase(), ProcessDefinition(), ProcessSources(), ReconstructHrirs(), ResamplerClear(), and ResamplerRun().

static void DiffuseFieldEqualize | ( | const double * | dfa,
|  | const HrirDataT * | hData
| ) |  |

static

Definition at line 1803 of file makehrtf.c.

References i, j, and m.

Referenced by ProcessDefinition().

static void FftArrange | ( | const uint | n,
|  | const double * | inR,
|  | const double * | inI,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 812 of file makehrtf.c.

References k, and m.

Referenced by FftForward(), and FftInverse().

static void FftForward | ( | const uint | n,
|  | const double * | inR,
|  | const double * | inI,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 888 of file makehrtf.c.

References FftArrange(), and FftSummation().

Referenced by AverageHrirMagnitude(), and Hilbert().

static void FftInverse | ( | const uint | n,
|  | const double * | inR,
|  | const double * | inI,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 894 of file makehrtf.c.

References FftArrange(), FftSummation(), and i.

Referenced by Hilbert(), and ReconstructHrirs().

static void FftSummation | ( | const uint | n,
|  | const double | s,
|  | double * | re,
|  | double * | im
| ) |  |

static

Definition at line 848 of file makehrtf.c.

References i, k, m, M_PI, pi, and sin().

Referenced by FftForward(), and FftInverse().

static uint Gcd | ( | const uint | a,
|  | const uint | b
| ) |  |

static

Definition at line 1080 of file makehrtf.c.

Referenced by ResamplerSetup().

static void Hilbert | ( | const uint | n,
|  | const double * | in,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 912 of file makehrtf.c.

References FftForward(), FftInverse(), and i.

Referenced by MinimumPhase().

static int HpTpdfDither | ( | const double | in,
|  | int * | hpHist
| ) |  |

static

Definition at line 756 of file makehrtf.c.

Referenced by StoreMhr(), and StoreTable().

static double Kaiser | ( | const double | b,
|  | const double | k
| ) |  |

static

Definition at line 1069 of file makehrtf.c.

References BesselI_0(), and Clamp().

Referenced by SincFilter().

static double Lerp | ( | const double | a,
|  | const double | b,
|  | const double | f
| ) |  |

static

Definition at line 750 of file makehrtf.c.

Referenced by AverageHrirMagnitude(), and SynthesizeHrirs().

static void LimitMagnitudeResponse | ( | const uint | n,
|  | const double | limit,
|  | const double * | in,
|  | double * | out
| ) |  |

static

Definition at line 961 of file makehrtf.c.

References Clamp(), floor(), i, and m.

Referenced by CalculateDiffuseFieldAverage().

static int LoadAsciiSource | ( | FILE * | fp,
|  | const SourceRefT * | src,
|  | const uint | n,
|  | double * | hrir
| ) |  |

static

Definition at line 1640 of file makehrtf.c.

References i, j, NULL, ReadAsciiAsDouble(), and TrSetup().

Referenced by LoadSource().

static int LoadBinarySource | ( | FILE * | fp,
|  | const SourceRefT * | src,
|  | const ByteOrderT | order,
|  | const uint | n,
|  | double * | hrir
| ) |  |

static

Definition at line 1625 of file makehrtf.c.

References i, ReadBinAsDouble(), SEEK_CUR, and SEEK_SET.

Referenced by LoadSource().

static int LoadSource | ( | SourceRefT * | src,
|  | const uint | hrirRate,
|  | const uint | n,
|  | double * | hrir
| ) |  |

static

Definition at line 1662 of file makehrtf.c.

References BO_BIG, BO_LITTLE, LoadAsciiSource(), LoadBinarySource(), LoadWaveSource(), NULL, SF_ASCII, SF_BIN_BE, SF_BIN_LE, and SF_WAVE.

Referenced by ProcessSources().

static int LoadWaveSource | ( | FILE * | fp,
|  | SourceRefT * | src,
|  | const uint | hrirRate,
|  | const uint | n,
|  | double * | hrir
| ) |  |

static

Definition at line 1596 of file makehrtf.c.

References BO_BIG, BO_LITTLE, FOURCC_RIFF, FOURCC_RIFX, FOURCC_WAVE, ReadBin4(), ReadWaveFormat(), and ReadWaveList().

Referenced by LoadSource().

static void MagnitudeResponse | ( | const uint | n,
|  | const double * | inR,
|  | const double * | inI,
|  | double * | out
| ) |  |

static

Definition at line 949 of file makehrtf.c.

References ComplexAbs(), EPSILON, i, and m.

Referenced by AverageHrirMagnitude().

int main | ( | const int | argc,
|  | const char * | argv[]
| ) |  |

Definition at line 2542 of file makehrtf.c.

References DEFAULT_EQUALIZE, DEFAULT_LIMIT, DEFAULT_SURFACE, DEFAULT_TRUNCSIZE, MAX_FFTSIZE, MAX_LIMIT, MAX_RATE, MAX_TRUNCSIZE, MIN_FFTSIZE, MIN_LIMIT, MIN_RATE, MIN_TRUNCSIZE, MOD_TRUNCSIZE, NULL, OF_MHR, OF_TABLE, and ProcessDefinition().

static ElementTypeT MatchElementType | ( | const char * | ident | ) |

static

Definition at line 2265 of file makehrtf.c.

References ET_FP, ET_INT, and ET_NONE.

Referenced by ReadSourceRef().

static SourceFormatT MatchSourceFormat | ( | const char * | ident | ) |

static

Definition at line 2252 of file makehrtf.c.

References SF_ASCII, SF_BIN_BE, SF_BIN_LE, SF_NONE, and SF_WAVE.

Referenced by ReadSourceRef().

static void MinimumPhase | ( | const uint | n,
|  | const double * | in,
|  | double * | outR,
|  | double * | outI
| ) |  |

static

Definition at line 991 of file makehrtf.c.

References ComplexExp(), ComplexMul(), CreateArray(), DestroyArray(), EPSILON, Hilbert(), i, m, and NULL.

Referenced by ReconstructHrirs().

static void NormalizeHrirs | ( | const HrirDataT * | hData | ) |

static

Definition at line 1937 of file makehrtf.c.

References fabs(), i, and j.

Referenced by ProcessDefinition().

static int ProcessDefinition | ( | const char * | inName,
|  | const uint | outRate,
|  | const uint | fftSize,
|  | const int | equalize,
|  | const int | surface,
|  | const double | limit,
|  | const uint | truncSize,
|  | const OutputFormatT | outFormat,
|  | const char * | outName
| ) |  |

static

Definition at line 2455 of file makehrtf.c.

References CalculateDiffuseFieldAverage(), CalculateHrtds(), CreateArray(), DestroyArray(), DiffuseFieldEqualize(), MAX_PATH_LEN, NormalizeHrirs(), NULL, OF_MHR, OF_TABLE, ProcessMetrics(), ProcessSources(), ReconstructHrirs(), ResampleHrirs(), StoreMhr(), StoreTable(), StrSubst(), SynthesizeHrirs(), and TrSetup().

Referenced by main().

static int ProcessMetrics | ( | TokenReaderT * | tr,
|  | const uint | fftSize,
|  | const uint | truncSize,
|  | HrirDataT * | hData
| ) |  |

static

Definition at line 2117 of file makehrtf.c.

References MAX_AZ_COUNT, MAX_DISTANCE, MAX_EV_COUNT, MAX_IDENT_LEN, MAX_POINTS, MAX_RADIUS, MAX_RATE, MIN_AZ_COUNT, MIN_DISTANCE, MIN_EV_COUNT, MIN_POINTS, MIN_RADIUS, MIN_RATE, TrError(), TrErrorAt(), TrIndication(), TrIsOperator(), TrReadFloat(), TrReadIdent(), TrReadInt(), TrReadOperator(), and TrSkipWhitespace().

Referenced by ProcessDefinition().

static int ProcessSources | ( | TokenReaderT * | tr,
|  | HrirDataT * | hData
| ) |  |

static

Definition at line 2375 of file makehrtf.c.

References AverageHrirMagnitude(), calloc, CreateArray(), DestroyArray(), free, LoadSource(), NULL, ReadIndexPair(), ReadSourceRef(), TrError(), TrErrorAt(), TrIndication(), TrIsOperator(), TrLoad(), and TrReadOperator().

Referenced by ProcessDefinition().

static int ReadAsciiAsDouble | ( | TokenReaderT * | tr,
|  | const char * | filename,
|  | const ElementTypeT | type,
|  | const uint | bits,
|  | double * | out
| ) |  |

static

Definition at line 1379 of file makehrtf.c.

References ET_FP, TrIsOperator(), TrReadFloat(), TrReadInt(), and TrReadOperator().

Referenced by LoadAsciiSource().

static int ReadBin4 | ( | FILE * | fp,
|  | const char * | filename,
|  | const ByteOrderT | order,
|  | const uint | bytes,
|  | uint4 * | out
| ) |  |

static

Definition at line 1241 of file makehrtf.c.

References BO_BIG, BO_LITTLE, and i.

Referenced by LoadWaveSource(), ReadBinAsDouble(), ReadWaveFormat(), and ReadWaveList().

static int ReadBin8 | ( | FILE * | fp,
|  | const char * | filename,
|  | const ByteOrderT | order,
|  | uint8 * | out
| ) |  |

static

Definition at line 1269 of file makehrtf.c.

References BO_BIG, BO_LITTLE, and i.

Referenced by ReadBinAsDouble().

static int ReadBinAsDouble | ( | FILE * | fp,
|  | const char * | filename,
|  | const ByteOrderT | order,
|  | const ElementTypeT | type,
|  | const uint | bytes,
|  | const int | bits,
|  | double * | out
| ) |  |

static

Definition at line 1339 of file makehrtf.c.

References bits, ET_FP, i, ReadBin4(), and ReadBin8().

Referenced by LoadBinarySource(), and ReadWaveData().

static int ReadIndexPair | ( | TokenReaderT * | tr,
|  | const HrirDataT * | hData,
|  | uint * | ei,
|  | uint * | ai
| ) |  |

static

Definition at line 2237 of file makehrtf.c.

References TrReadInt(), and TrReadOperator().

Referenced by ProcessSources().

static int ReadSourceRef | ( | TokenReaderT * | tr,
|  | SourceRefT * | src
| ) |  |

static

Definition at line 2274 of file makehrtf.c.

References ET_INT, ET_NONE, int, MatchElementType(), MatchSourceFormat(), MAX_ASCII_BITS, MAX_BIN_SIZE, MAX_IDENT_LEN, MAX_PATH_LEN, MAX_WAVE_CHANNELS, MIN_ASCII_BITS, MIN_BIN_BITS, MIN_BIN_SIZE, SF_ASCII, SF_BIN_BE, SF_BIN_LE, SF_NONE, SF_WAVE, TrErrorAt(), TrIndication(), TrIsOperator(), TrReadIdent(), TrReadInt(), TrReadOperator(), and TrReadString().

Referenced by ProcessSources().

static int ReadWaveData | ( | FILE * | fp,
|  | const SourceRefT * | src,
|  | const ByteOrderT | order,
|  | const uint | n,
|  | double * | hrir
| ) |  |

static

Definition at line 1488 of file makehrtf.c.

References i, int, ReadBinAsDouble(), SEEK_CUR, and skip.

Referenced by ReadWaveList().

static int ReadWaveFormat | ( | FILE * | fp,
|  | const ByteOrderT | order,
|  | const uint | hrirRate,
|  | SourceRefT * | src
| ) |  |

static

Definition at line 1407 of file makehrtf.c.

References bits, BO_LITTLE, ET_FP, ET_INT, FOURCC_FMT, int, ReadBin4(), SEEK_CUR, WAVE_FORMAT_EXTENSIBLE, WAVE_FORMAT_IEEE_FLOAT, and WAVE_FORMAT_PCM.

Referenced by LoadWaveSource().

static int ReadWaveList | ( | FILE * | fp,
|  | const SourceRefT * | src,
|  | const ByteOrderT | order,
|  | const uint | n,
|  | double * | hrir
| ) |  |

static

Definition at line 1510 of file makehrtf.c.

References BO_LITTLE, FOURCC_DATA, FOURCC_LIST, FOURCC_SLNT, FOURCC_WAVL, i, ReadBin4(), ReadWaveData(), SEEK_CUR, and skip.

Referenced by LoadWaveSource().

static void ReconstructHrirs | ( | const HrirDataT * | hData | ) |

static

Definition at line 1818 of file makehrtf.c.

References CreateArray(), DestroyArray(), FftInverse(), i, j, MinimumPhase(), and NULL.

Referenced by ProcessDefinition().

static void ResampleHrirs | ( | const uint | rate,
|  | HrirDataT * | hData
| ) |  |

static

Definition at line 1839 of file makehrtf.c.

References j, ResamplerClear(), ResamplerRun(), and ResamplerSetup().

Referenced by ProcessDefinition().

static void ResamplerClear | ( | ResamplerT * | rs | ) |

static

Definition at line 1194 of file makehrtf.c.

References DestroyArray(), and NULL.

Referenced by ResampleHrirs().

static void ResamplerRun | ( | ResamplerT * | rs,
|  | const uint | inN,
|  | const double * | in,
|  | const uint | outN,
|  | double * | out
| ) |  |

static

Definition at line 1201 of file makehrtf.c.

References CreateArray(), DestroyArray(), i, and NULL.

Referenced by ResampleHrirs().

static void ResamplerSetup | ( | ResamplerT * | rs,
|  | const uint | srcRate,
|  | const uint | dstRate
| ) |  |

static

Definition at line 1164 of file makehrtf.c.

References CalcKaiserBeta(), CalcKaiserOrder(), CreateArray(), Gcd(), i, int, and SincFilter().

Referenced by ResampleHrirs().

static double Sinc | ( | const double | x | ) |

static

Definition at line 1022 of file makehrtf.c.

References EPSILON, fabs(), M_PI, and sin().

Referenced by SincFilter().

static double SincFilter | ( | const int | l,
|  | const double | b,
|  | const double | gain,
|  | const double | cutoff,
|  | const int | i
| ) |  |

static

Definition at line 1132 of file makehrtf.c.

References Kaiser(), and Sinc().

Referenced by ResamplerSetup().

static int StoreMhr | ( | const HrirDataT * | hData,
|  | const char * | filename
| ) |  |

static

Definition at line 1996 of file makehrtf.c.

References BO_LITTLE, e, HpTpdfDither(), i, int, j, MAX_HRTD, MHR_FORMAT, NULL, WriteAscii(), and WriteBin4().

Referenced by ProcessDefinition().

static int StoreTable | ( | const HrirDataT * | hData,
|  | const char * | filename
| ) |  |

static

Definition at line 2039 of file makehrtf.c.

References HpTpdfDither(), i, int, j, MAX_HRTD, NULL, and WriteAscii().

Referenced by ProcessDefinition().

static int StrSubst | ( | const char * | in,
|  | const char * | pat,
|  | const char * | rep,
|  | const size_t | maxLen,
|  | char * | out
| ) |  |

static

Definition at line 694 of file makehrtf.c.

Referenced by ProcessDefinition().

static void SynthesizeHrirs | ( | HrirDataT * | hData | ) |

static

Definition at line 1875 of file makehrtf.c.

References CalcAzIndices(), e, i, j, j1, Lerp(), and M_PI.

Referenced by ProcessDefinition().

static void TrError | ( | const TokenReaderT * | tr,
|  | const char * | format,
|  |  | ...
| ) |  |

static

Definition at line 374 of file makehrtf.c.

References TrErrorVA().

Referenced by ProcessMetrics(), and ProcessSources().

static void TrErrorAt | ( | const TokenReaderT * | tr,
|  | uint | line,
|  | uint | column,
|  | const char * | format,
|  |  | ...
| ) |  |

static

Definition at line 365 of file makehrtf.c.

References TrErrorVA().

Referenced by ProcessMetrics(), ProcessSources(), ReadSourceRef(), TrReadFloat(), TrReadIdent(), TrReadInt(), TrReadOperator(), and TrReadString().

static void TrErrorVA | ( | const TokenReaderT * | tr,
|  | uint | line,
|  | uint | column,
|  | const char * | format,
|  | va_list | argPtr
| ) |  |

static

Definition at line 357 of file makehrtf.c.

References NULL.

Referenced by TrError(), and TrErrorAt().

static void TrIndication | ( | TokenReaderT * | tr,
|  | uint * | line,
|  | uint * | column
| ) |  |

static

Definition at line 422 of file makehrtf.c.

References NULL, and TrSkipWhitespace().

Referenced by ProcessMetrics(), ProcessSources(), and ReadSourceRef().

static int TrIsOperator | ( | TokenReaderT * | tr,
|  | const char * | op
| ) |  |

static

Definition at line 432 of file makehrtf.c.

References TR_RING_MASK, and TrSkipWhitespace().

Referenced by ProcessMetrics(), ProcessSources(), ReadAsciiAsDouble(), and ReadSourceRef().

static int TrLoad | ( | TokenReaderT * | tr | ) |

static

Definition at line 331 of file makehrtf.c.

References TR_LOAD_SIZE, TR_RING_MASK, and TR_RING_SIZE.

Referenced by ProcessSources(), TrReadFloat(), TrReadIdent(), TrReadInt(), TrReadOperator(), TrReadString(), TrSkipLine(), and TrSkipWhitespace().

static int TrReadFloat | ( | TokenReaderT * | tr,
|  | const double | loBound,
|  | const double | hiBound,
|  | double * | value
| ) |  |

static

Definition at line 536 of file makehrtf.c.

References NULL, TR_RING_MASK, TrErrorAt(), TrLoad(), and TrSkipWhitespace().

Referenced by ProcessMetrics(), and ReadAsciiAsDouble().

static int TrReadIdent | ( | TokenReaderT * | tr,
|  | const uint | maxLen,
|  | char * | ident
| ) |  |

static

Definition at line 458 of file makehrtf.c.

References TR_RING_MASK, TrErrorAt(), TrLoad(), and TrSkipWhitespace().

Referenced by ProcessMetrics(), and ReadSourceRef().

static int TrReadInt | ( | TokenReaderT * | tr,
|  | const int | loBound,
|  | const int | hiBound,
|  | int * | value
| ) |  |

static

Definition at line 491 of file makehrtf.c.

References NULL, TR_RING_MASK, TrErrorAt(), TrLoad(), and TrSkipWhitespace().

Referenced by ProcessMetrics(), ReadAsciiAsDouble(), ReadIndexPair(), and ReadSourceRef().

static int TrReadOperator | ( | TokenReaderT * | tr,
|  | const char * | op
| ) |  |

static

Definition at line 667 of file makehrtf.c.

References TR_RING_MASK, TrErrorAt(), TrLoad(), and TrSkipWhitespace().

Referenced by ProcessMetrics(), ProcessSources(), ReadAsciiAsDouble(), ReadIndexPair(), and ReadSourceRef().

static int TrReadString | ( | TokenReaderT * | tr,
|  | const uint | maxLen,
|  | char * | text
| ) |  |

static

Definition at line 624 of file makehrtf.c.

References TR_RING_MASK, TrErrorAt(), TrLoad(), and TrSkipWhitespace().

Referenced by ReadSourceRef().

static void TrSetup | ( | FILE * | fp,
|  | const char * | filename,
|  | TokenReaderT * | tr
| ) |  |

static

Definition at line 308 of file makehrtf.c.

References sort_controllers::filename, and NULL.

Referenced by LoadAsciiSource(), and ProcessDefinition().

static void TrSkipLine | ( | TokenReaderT * | tr | ) |

static

Definition at line 383 of file makehrtf.c.

References TR_RING_MASK, and TrLoad().

Referenced by TrSkipWhitespace().

static int TrSkipWhitespace | ( | TokenReaderT * | tr | ) |

static

Definition at line 399 of file makehrtf.c.

References TR_RING_MASK, TrLoad(), and TrSkipLine().

Referenced by ProcessMetrics(), TrIndication(), TrIsOperator(), TrReadFloat(), TrReadIdent(), TrReadInt(), TrReadOperator(), and TrReadString().

static int WriteAscii | ( | const char * | out,
|  | FILE * | fp,
|  | const char * | filename
| ) |  |

static

Definition at line 1296 of file makehrtf.c.

Referenced by StoreMhr(), and StoreTable().

static int WriteBin4 | ( | const ByteOrderT | order,
|  | const uint | bytes,
|  | const uint4 | in,
|  | FILE * | fp,
|  | const char * | filename
| ) |  |

static

Definition at line 1310 of file makehrtf.c.

References BO_BIG, BO_LITTLE, and i.

Referenced by StoreMhr().