Mercurial > hg > x
view vibrato.h @ 6:fda5b3561a13
some programming notes
author | Wen X <xue.wen@elec.qmul.ac.uk> |
---|---|
date | Wed, 06 Oct 2010 15:36:50 +0100 |
parents | 5f3c32dc6e17 |
children | 977f541d6683 |
line wrap: on
line source
#ifndef vibratoH #define vibratoH /** \file vibrato.h - vibrato analysis and synthesis using harmonic sinusoids Further reading: Wen X. and M. Sandler, "Analysis and synthesis of audio vibrato using harmonic sinusoids," in Proc. AES 124th Convention, Amsterdam, 2008. */ #include <stdio.h> #include "hs.h" //--------------------------------------------------------------------------- /** TVo is the data structure hosting descriptors of a vibrato representation of a harmonic sinusoid. Its basic framework is shared by the TSF object which hosts a more elaborate source-filter model than TVo, but does not look into vibrato-specific features such as modulator shape. An analysis/sythesis cycle converts THS to TVo and back. */ struct TVo { //basic characteristics int M; ///< number of partials int L; ///< number of frames int P; ///< number of F0 peaks double h; ///< hop size double* F0C; ///< [0:L-1] pitch carrier double* A0C; ///< [0:L-1] amplitude carreir int afres; ///< filter model bins double LogAF[4096]; ///< [0:afres-1] filter model int* peakfr; ///< [0:P-1] peak positions, in frames double* lp; ///< [0:P-1] peak positions, refined to floating-point values in frames double* Dp; ///< [1:P-1] single-cycle rms of F0D int* Kp; ///< [1:P-1] order of single-cycle modulator shape descriptor double** fxr; ///< [1:P-1][0:2K] single-cycle modulator shape coefficients - cosine, sine, cosine, ... double** LogASp; ///< [1:P-1][0:M-1] single-cycle source model int K; //other properties double rate; ///< vibrato rate double regularity;///< vibrato regularity double F0max; ///< maximal fundamental frequency double F0min; ///< minimal fundamental frequency double F0Cmax; ///< maximal fundamental carrier frequency double F0Cmin; ///< minimal fundamental carrier frequency double F0Overall; ///< overall average fundamental frequency double F0Dmax; ///< maximal fundamental modulator frequency double F0Dmin; ///< minimal fundamental modulator frequency double* F0; ///< [0:L-1] pitch double* F0D; ///< [0:L-1] pitch modulator double D; ///< rms of F0D, double LogAS[100];///< [0:M-1] source model double FXR[100]; ///< average cycle modulator shape coefficients double FRes[50]; ///< average modulator residues double** fres; ///< [1:P-1][0:K-1] single-cycle modulator residues TVo(); ~TVo(); void AllocateL(int AnL); void ReAllocateL(int newL); void AllocateP(); void AllocatePK(); void SaveToFile(char* filename); void SaveToFileHandle(FILE* file); void LoadFromFileHandle(FILE* file); double GetOldP(); }; //--tool procedures---------------------------------------------------------- double QIE(double* y); double QIE(double* y, double& x); //--demodulation routines---------------------------------------------------- void DeFM(double* f2, double* f1, double* AA, int npfr, int* peakfr, int Fr, double& fct, int& fcount, double* &frs, double* &f, bool furthersmoothing=false); void DeFM(double* f2, double* f1, double* AA, int npfr, double* lp, int Fr, double& fct, int& fcount, double* &frs, double* &f, bool furthersmoothing=false); void DeAM(double* A2, double* A1, int npfr, int* peakfr, int Fr); void DeAM(double* A2, double* A1, int npfr, double* lp, int Fr); //--source-filter analysis routine------------------------------------------- double S_F(int afres, double* LogAF, double* LogAS, int Fr, int M, atom** Partials, double* A0C, double* lp, int P, double F0Overall); double S_F_SV(int afres, double* LogAF, double* LogAS, int Fr, int M, atom** Partials, double* A0C, double* lp, int P, double F=0.005, int FScaleMode=0, double theta=0.5, double sps=44100); //--vibrato analysis and synthesis routines---------------------------------- void AnalyzeV(THS& HS, TVo& V, double*& peaky, double*& cyclefrs, double*& cyclefs, double sps, double h, int* cyclefrcount=0, int SFMode=0, double SFF=0.01, int SFFScale=0, double SFtheta=0); void RegularizeV(THS& HS, TVo& V, double sps, double h); void SynthesizeV(THS* HS, TVo* V, double sps, int UseK=0); TVo* InterpolateV(double newP, double rate, TVo& V); //--other functions---------------------------------------------------------- void FindPeaks(int* peakfr, int& npfr, double* F0, int Fr, double periodinframe, double*& peaky); void FS_QR(int& K, double* FXR, double* data, int Fr, double period, double shift, double* FRES); void RateAndReg(double& rate, double& regularity, double* data, int frst, int fren, int padrate, double sps, double offst); #endif