xue@1
|
1 #ifndef vibratoH
|
xue@1
|
2 #define vibratoH
|
xue@1
|
3
|
xue@1
|
4
|
Chris@5
|
5 /**
|
Chris@5
|
6 \file vibrato.h - vibrato analysis and synthesis using harmonic sinusoids
|
xue@1
|
7
|
xue@1
|
8 Further reading: Wen X. and M. Sandler, "Analysis and synthesis of audio vibrato using harmonic sinusoids,"
|
xue@1
|
9 in Proc. AES 124th Convention, Amsterdam, 2008.
|
xue@1
|
10 */
|
xue@1
|
11
|
xue@1
|
12 #include <stdio.h>
|
xue@1
|
13 #include "hs.h"
|
xue@1
|
14 //---------------------------------------------------------------------------
|
xue@1
|
15
|
Chris@5
|
16 /**
|
xue@1
|
17 TVo is the data structure hosting descriptors of a vibrato representation of a harmonic sinusoid. Its
|
xue@1
|
18 basic framework is shared by the TSF object which hosts a more elaborate source-filter model than TVo,
|
xue@1
|
19 but does not look into vibrato-specific features such as modulator shape.
|
xue@1
|
20
|
xue@1
|
21 An analysis/sythesis cycle converts THS to TVo and back.
|
xue@1
|
22 */
|
xue@1
|
23 struct TVo
|
xue@1
|
24 {
|
xue@1
|
25 //basic characteristics
|
Chris@5
|
26 int M; ///< number of partials
|
Chris@5
|
27 int L; ///< number of frames
|
Chris@5
|
28 int P; ///< number of F0 peaks
|
Chris@5
|
29 double h; ///< hop size
|
Chris@5
|
30 double* F0C; ///< [0:L-1] pitch carrier
|
Chris@5
|
31 double* A0C; ///< [0:L-1] amplitude carreir
|
Chris@5
|
32 int afres; ///< filter model bins
|
Chris@5
|
33 double LogAF[4096]; ///< [0:afres-1] filter model
|
xue@1
|
34
|
Chris@5
|
35 int* peakfr; ///< [0:P-1] peak positions, in frames
|
Chris@5
|
36 double* lp; ///< [0:P-1] peak positions, refined to floating-point values in frames
|
Chris@5
|
37 double* Dp; ///< [1:P-1] single-cycle rms of F0D
|
Chris@5
|
38 int* Kp; ///< [1:P-1] order of single-cycle modulator shape descriptor
|
Chris@5
|
39 double** fxr; ///< [1:P-1][0:2K] single-cycle modulator shape coefficients - cosine, sine, cosine, ...
|
Chris@5
|
40 double** LogASp; ///< [1:P-1][0:M-1] single-cycle source model
|
xue@1
|
41 int K;
|
xue@1
|
42
|
xue@1
|
43 //other properties
|
Chris@5
|
44 double rate; ///< vibrato rate
|
Chris@5
|
45 double regularity;///< vibrato regularity
|
Chris@5
|
46 double F0max; ///< maximal fundamental frequency
|
Chris@5
|
47 double F0min; ///< minimal fundamental frequency
|
Chris@5
|
48 double F0Cmax; ///< maximal fundamental carrier frequency
|
Chris@5
|
49 double F0Cmin; ///< minimal fundamental carrier frequency
|
Chris@5
|
50 double F0Overall; ///< overall average fundamental frequency
|
Chris@5
|
51 double F0Dmax; ///< maximal fundamental modulator frequency
|
Chris@5
|
52 double F0Dmin; ///< minimal fundamental modulator frequency
|
Chris@5
|
53 double* F0; ///< [0:L-1] pitch
|
Chris@5
|
54 double* F0D; ///< [0:L-1] pitch modulator
|
Chris@5
|
55 double D; ///< rms of F0D,
|
Chris@5
|
56 double LogAS[100];///< [0:M-1] source model
|
Chris@5
|
57 double FXR[100]; ///< average cycle modulator shape coefficients
|
Chris@5
|
58 double FRes[50]; ///< average modulator residues
|
Chris@5
|
59 double** fres; ///< [1:P-1][0:K-1] single-cycle modulator residues
|
xue@1
|
60
|
xue@1
|
61 TVo();
|
xue@1
|
62 ~TVo();
|
xue@1
|
63 void AllocateL(int AnL);
|
xue@1
|
64 void ReAllocateL(int newL);
|
xue@1
|
65 void AllocateP();
|
xue@1
|
66 void AllocatePK();
|
xue@1
|
67 void SaveToFile(char* filename);
|
xue@1
|
68 void SaveToFileHandle(FILE* file);
|
xue@1
|
69 void LoadFromFileHandle(FILE* file);
|
xue@1
|
70 double GetOldP();
|
xue@1
|
71 };
|
xue@1
|
72
|
xue@1
|
73 //--tool procedures----------------------------------------------------------
|
xue@1
|
74 double QIE(double* y);
|
xue@1
|
75 double QIE(double* y, double& x);
|
xue@1
|
76
|
xue@1
|
77 //--demodulation routines----------------------------------------------------
|
xue@1
|
78 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);
|
xue@1
|
79 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);
|
xue@1
|
80 void DeAM(double* A2, double* A1, int npfr, int* peakfr, int Fr);
|
xue@1
|
81 void DeAM(double* A2, double* A1, int npfr, double* lp, int Fr);
|
xue@1
|
82
|
xue@1
|
83 //--source-filter analysis routine-------------------------------------------
|
xue@1
|
84 double S_F(int afres, double* LogAF, double* LogAS, int Fr, int M, atom** Partials, double* A0C, double* lp, int P, double F0Overall);
|
xue@1
|
85 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);
|
xue@1
|
86
|
xue@1
|
87 //--vibrato analysis and synthesis routines----------------------------------
|
xue@1
|
88 void AnalyzeV(THS& HS, TVo& V, double*& peaky, double*& cyclefrs, double*& cyclefs, double sps, double h, int* cyclefrcount=0,
|
xue@1
|
89 int SFMode=0, double SFF=0.01, int SFFScale=0, double SFtheta=0);
|
xue@1
|
90 void RegularizeV(THS& HS, TVo& V, double sps, double h);
|
xue@1
|
91 void SynthesizeV(THS* HS, TVo* V, double sps, int UseK=0);
|
xue@1
|
92 TVo* InterpolateV(double newP, double rate, TVo& V);
|
xue@1
|
93
|
xue@1
|
94 //--other functions----------------------------------------------------------
|
xue@1
|
95 void FindPeaks(int* peakfr, int& npfr, double* F0, int Fr, double periodinframe, double*& peaky);
|
xue@1
|
96 void FS_QR(int& K, double* FXR, double* data, int Fr, double period, double shift, double* FRES);
|
xue@1
|
97 void RateAndReg(double& rate, double& regularity, double* data, int frst, int fren, int padrate, double sps, double offst);
|
xue@1
|
98
|
xue@1
|
99 #endif
|