1
/* ------------------------------------------------------------------
3
libofa -- the Open Fingerprint Architecture library
5
Copyright (C) 2006 MusicIP Corporation
8
-------------------------------------------------------------------*/
10
// MODULE: Class header for FFT_op
12
// DATE CREATED: 1/12/06
18
#include "../config_win32.h"
20
#include "../config.h"
22
#include "signal_op.h"
23
#include "fftlib_op.h"
25
enum { RECTANGULAR, TRIANGULAR, HAMMING };
26
const double TwoPI = 2.0 * 3.14159265358979324;
28
class FFT_op : public FFTLib_op {
32
void LoadSignal(Signal_op *sig);
33
void SetSize(int N, bool optimize);
34
void Compute(double ovlap);
35
void SetWindowShape(int shape) { WindowShape = shape; }
36
void ReSample(int nBins, bool melScale);
37
long GetNumFrames() const { return NumFrames; }
38
int GetNumBins() const { return NumBins; }
39
float* GetFrame(int frNum) { return &TimeSpectra[frNum * NumBins]; }
40
double GetFreqStep() { return (double)Rate/(GetNumBins()*2); }
41
double GetStepDur() const { return StepSize * 1000.0 / Rate; }
42
static int FreqToMidi(double hz);
44
void CreateBuffer(int numBins, int numFrames, bool init = false);
45
void SetStep(int step);
47
void ComputeWindow(double* in);
48
void SetNumFrames(long numFr) { NumFrames = numFr; }
49
void SetNumBins(int bins) { NumBins = bins; }
50
double GetFreq(int step) { return step * GetFreqStep(); }
53
double* InBuf; // Temporary holding buffer for fft input frames
54
double* OutBuf; // Temporary output buffer for one FFT frame
55
double* AmpSpectWin; // Buffer for amplitude spectrum of current frame
56
float* TimeSpectra; // Sequence of amp spectra for Signal, separated by NumBins
57
long BufSize; // Size of TimeSpectra buffer
58
int FrameSize; // in # of signal sample points
59
int StepSize; // in # of signal sample points
60
int NumBins; // # of spectrum points
61
int NumFrames; // # of analysis frames
62
int Rate; // Sample rate
63
double Overlap; // in percent (= 1 - StepSize/FrameSize)
64
int WindowShape; // Type of windowing
65
double* Hamming; // Hamming window