File: fft_op.h

package info (click to toggle)
libofa 0.9.3-21
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,080 kB
  • sloc: cpp: 24,487; sh: 8,366; makefile: 47; ansic: 14
file content (71 lines) | stat: -rw-r--r-- 2,243 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ------------------------------------------------------------------

   libofa -- the Open Fingerprint Architecture library

   Copyright (C) 2006 MusicIP Corporation
   All rights reserved.

-------------------------------------------------------------------*/
// FILE: "fft_op.h"
// MODULE: Class header for FFT_op
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06

#ifndef __FFT_OP_H
#define __FFT_OP_H 1

#ifdef WIN32
#include "../config_win32.h"
#else
#include "../config.h"
#endif
#include "signal_op.h"
#include "fftlib_op.h"

enum { RECTANGULAR, TRIANGULAR, HAMMING };
const double TwoPI = 2.0 * 3.14159265358979324;

class FFT_op : public FFTLib_op {
public:
	FFT_op();
	~FFT_op();
	void LoadSignal(Signal_op *sig);
	void SetSize(int N, bool optimize);
	void Compute(double ovlap);
	void SetWindowShape(int shape) { WindowShape = shape; }
	void ReSample(int nBins, bool melScale);
	long GetNumFrames() const { return NumFrames; }
	int GetNumBins() const { return NumBins; }
	float* GetFrame(int frNum) { return &TimeSpectra[frNum * NumBins]; }
	double GetFreqStep() { return (double)Rate/(GetNumBins()*2); }
	double GetStepDur() const { return StepSize * 1000.0 / Rate; }
	static int FreqToMidi(double hz);
private:
	void CreateBuffer(int numBins, int numFrames, bool init = false);
	void SetStep(int step);
	void WindowInit();
	void ComputeWindow(double* in);
	void SetNumFrames(long numFr) { NumFrames = numFr; }
	void SetNumBins(int bins) { NumBins = bins; }
	double GetFreq(int step) { return step * GetFreqStep(); }

	Signal_op* Signal;
	double* InBuf;			// Temporary holding buffer for fft input frames
	double* OutBuf;			// Temporary output buffer for one FFT frame
	double* AmpSpectWin;	// Buffer for amplitude spectrum of current frame
	float* TimeSpectra;		// Sequence of amp spectra for Signal, separated by NumBins
	long BufSize;			// Size of TimeSpectra buffer
	int FrameSize;			// in # of signal sample points
	int StepSize;			// in # of signal sample points
	int NumBins;			// # of spectrum points
	int NumFrames;			// # of analysis frames
	int Rate;				// Sample rate
	double Overlap;			// in percent (= 1 - StepSize/FrameSize)
	int WindowShape;		// Type of windowing
	double* Hamming;		// Hamming window

};



#endif