~ubuntu-branches/debian/lenny/libofa/lenny

« back to all changes in this revision

Viewing changes to lib/fft_op.h

  • Committer: Bazaar Package Importer
  • Author(s): Lukáš Lalinský
  • Date: 2006-08-21 23:06:01 UTC
  • Revision ID: james.westby@ubuntu.com-20060821230601-ik253yugpxbbo9xt
Tags: upstream-0.9.3
Import upstream version 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ------------------------------------------------------------------
 
2
 
 
3
   libofa -- the Open Fingerprint Architecture library
 
4
 
 
5
   Copyright (C) 2006 MusicIP Corporation
 
6
   All rights reserved.
 
7
 
 
8
-------------------------------------------------------------------*/
 
9
// FILE: "fft_op.h"
 
10
// MODULE: Class header for FFT_op
 
11
// AUTHOR: Frode Holm
 
12
// DATE CREATED: 1/12/06
 
13
 
 
14
#ifndef __FFT_OP_H
 
15
#define __FFT_OP_H 1
 
16
 
 
17
#ifdef WIN32
 
18
#include "../config_win32.h"
 
19
#else
 
20
#include "../config.h"
 
21
#endif
 
22
#include "signal_op.h"
 
23
#include "fftlib_op.h"
 
24
 
 
25
enum { RECTANGULAR, TRIANGULAR, HAMMING };
 
26
const double TwoPI = 2.0 * 3.14159265358979324;
 
27
 
 
28
class FFT_op : public FFTLib_op {
 
29
public:
 
30
        FFT_op();
 
31
        ~FFT_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);
 
43
private:
 
44
        void CreateBuffer(int numBins, int numFrames, bool init = false);
 
45
        void SetStep(int step);
 
46
        void WindowInit();
 
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(); }
 
51
 
 
52
        Signal_op* Signal;
 
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
 
66
 
 
67
};
 
68
 
 
69
 
 
70
 
 
71
#endif