Sunday, 22 April 2012

DSP.h Digital Signal Processing C++ Header


#pragma once
#include <vector>
#include <cmath>
#include <complex>
#include <iostream>
#include <algorithm>
using namespace std;

#define PI 3.1415926
#define FLOAT_MAX (float)1.0e37


class CDSP
{
public:
CDSP(void);
~CDSP(void);
void FFT(const vector<short>& s, vector<complex<float> >& spec, bool invert=false);
// void FFT (float *x, float *y, int n, int m);
float AutoCorrelate(const vector<short>& s, vector<float>& r, int p);
void Wave2LPC(const vector<short>& s, vector<float>& a, vector<float>& k, int p, float *re, float *te);
void LPC2RefC(const vector<float>& a, vector<float>& k);
void RefC2LPC(const vector<float>& k, vector<float>& a);
void LPC2Cepstrum(const vector<float>& a, vector<float>& c);
void Cepstrum2LPC(const vector<float>& c, vector<float>& a);
void SpecModulus(const vector<complex<float> >& spec, vector<float>& m);
void LSF2LPC(const vector<float>& lsf, vector<float>& a_coef);
void LPC2LSF(const vector<float>& a, vector<float>& lsf);
void window(vector<float>& wgt, int len, string type);
void LPCSpec(const vector<float>& a, int len, float G, vector<complex<float> >& spec);
float GetG(const vector<short>& s, const vector<float>& a);
void ExcitationSpec(const vector<complex<float> >& WavSpec, const vector<complex<float> >& LpcSpec, vector<complex<float> >& ExcSpec);
private:
float Durbin(vector<float>& k, vector<float>& a, vector<float>& r, float E, int p);
// void cheby(vector<float>& g, int order);
// void cacm283(vector<float>& a,int order,vector<float>& r);
template <typename T> inline void swap(T& a,T& b) { T temp=a; a = b; b = temp; }
};

No comments:

Post a Comment