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