vibrato.h
Go to the documentation of this file.
1 /*
2  Harmonic sinusoidal modelling and tools
3 
4  C++ code package for harmonic sinusoidal modelling and relevant signal processing.
5  Centre for Digital Music, Queen Mary, University of London.
6  This file copyright 2011 Wen Xue.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 */
13 #ifndef vibratoH
14 #define vibratoH
15 
16 
24 #include <stdio.h>
25 #include "hs.h"
26 //---------------------------------------------------------------------------
27 
35 struct TVo
36 {
37  //basic characteristics
38  int M;
39  int L;
40  int P;
41  double h;
42  double* F0C;
43  double* A0C;
44  int afres;
45  double LogAF[4096];
46 
47  int* peakfr;
48  double* lp;
49  double* Dp;
50  int* Kp;
51  double** fxr;
52  double** LogASp;
53  int K;
54 
55  //other properties
56  double rate;
57  double regularity;
58  double F0max;
59  double F0min;
60  double F0Cmax;
61  double F0Cmin;
62  double F0Overall;
63  double F0Dmax;
64  double F0Dmin;
65  double* F0;
66  double* F0D;
67  double D;
68  double LogAS[100];
69  double FXR[100];
70  double FRes[50];
71  double** fres;
72 
73  TVo();
74  ~TVo();
75  void AllocateL(int AnL);
76  void ReAllocateL(int newL);
77  void AllocateP();
78  void AllocatePK();
79  void SaveToFile(char* filename);
80  void SaveToFileHandle(FILE* file);
81  void LoadFromFileHandle(FILE* file);
82  double GetOldP();
83 };
84 
85 //--tool procedures----------------------------------------------------------
86 double QIE(double* y);
87 double QIE(double* y, double& x);
88 
89 //--demodulation routines----------------------------------------------------
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);
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);
92 void DeAM(double* A2, double* A1, int npfr, int* peakfr, int Fr);
93 void DeAM(double* A2, double* A1, int npfr, double* lp, int Fr);
94 
95 //--source-filter analysis routine-------------------------------------------
96 double S_F(int afres, double* LogAF, double* LogAS, int Fr, int M, atom** Partials, double* A0C, double* lp, int P, double F0Overall);
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);
98 
99 //--vibrato analysis and synthesis routines----------------------------------
100 void AnalyzeV(THS& HS, TVo& V, double*& peaky, double*& cyclefrs, double*& cyclefs, double sps, double h, int* cyclefrcount=0,
101  int SFMode=0, double SFF=0.01, int SFFScale=0, double SFtheta=0);
102 void RegularizeV(THS& HS, TVo& V, double sps, double h);
103 void SynthesizeV(THS* HS, TVo* V, double sps, int UseK=0);
104 TVo* InterpolateV(double newP, double rate, TVo& V);
105 
106 //--other functions----------------------------------------------------------
107 void FindPeaks(int* peakfr, int& npfr, double* F0, int Fr, double periodinframe, double*& peaky);
108 void FS_QR(int& K, double* FXR, double* data, int Fr, double period, double shift, double* FRES);
109 void RateAndReg(double& rate, double& regularity, double* data, int frst, int fren, int padrate, double sps, double offst);
110 
111 #endif
double rate
vibrato rate
Definition: vibrato.h:56
void FindPeaks(int *peakfr, int &npfr, double *F0, int Fr, double periodinframe, double *&peaky)
Definition: vibrato.cpp:588
double F0Dmax
maximal fundamental modulator frequency
Definition: vibrato.h:63
double LogAF[4096]
[0:afres-1] filter model
Definition: vibrato.h:45
double h
hop size
Definition: vibrato.h:41
double FXR[100]
average cycle modulator shape coefficients
Definition: vibrato.h:69
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)
Definition: vibrato.cpp:496
double regularity
vibrato regularity
Definition: vibrato.h:57
double S_F(int afres, double *LogAF, double *LogAS, int Fr, int M, atom **Partials, double *A0C, double *lp, int P, double F0Overall)
Definition: vibrato.cpp:1055
Definition: vibrato.h:35
Definition: hs.h:49
double ** fres
[1:P-1][0:K-1] single-cycle modulator residues
Definition: vibrato.h:71
double * lp
[0:P-1] peak positions, refined to floating-point values in frames
Definition: vibrato.h:48
int M
number of partials
Definition: vibrato.h:38
void DeAM(double *A2, double *A1, int npfr, int *peakfr, int Fr)
Definition: vibrato.cpp:425
int * peakfr
[0:P-1] peak positions, in frames
Definition: vibrato.h:47
int L
number of frames
Definition: vibrato.h:39
void RateAndReg(double &rate, double &regularity, double *data, int frst, int fren, int padrate, double sps, double offst)
Definition: vibrato.cpp:918
void RegularizeV(THS &HS, TVo &V, double sps, double h)
Definition: vibrato.cpp:978
double ** LogASp
[1:P-1][0:M-1] single-cycle source model
Definition: vibrato.h:52
double F0Cmin
minimal fundamental carrier frequency
Definition: vibrato.h:61
double QIE(double *y)
Definition: vibrato.cpp:1020
double D
rms of F0D,
Definition: vibrato.h:67
double * F0C
[0:L-1] pitch carrier
Definition: vibrato.h:42
double * Dp
[1:P-1] single-cycle rms of F0D
Definition: vibrato.h:49
double F0Dmin
minimal fundamental modulator frequency
Definition: vibrato.h:64
void FS_QR(int &K, double *FXR, double *data, int Fr, double period, double shift, double *FRES)
Definition: vibrato.cpp:759
double * F0
[0:L-1] pitch
Definition: vibrato.h:65
int P
number of F0 peaks
Definition: vibrato.h:40
double F0Cmax
maximal fundamental carrier frequency
Definition: vibrato.h:60
double * A0C
[0:L-1] amplitude carreir
Definition: vibrato.h:43
double FRes[50]
average modulator residues
Definition: vibrato.h:70
int * Kp
[1:P-1] order of single-cycle modulator shape descriptor
Definition: vibrato.h:50
void AllocateP()
Definition: vibrato.cpp:62
double * F0D
[0:L-1] pitch modulator
Definition: vibrato.h:66
Definition: hs.h:147
void LoadFromFileHandle(FILE *file)
Definition: vibrato.cpp:96
void ReAllocateL(int newL)
Definition: vibrato.cpp:120
double F0Overall
overall average fundamental frequency
Definition: vibrato.h:62
TVo * InterpolateV(double newP, double rate, TVo &V)
Definition: vibrato.cpp:833
void SaveToFileHandle(FILE *file)
Definition: vibrato.cpp:154
int afres
filter model bins
Definition: vibrato.h:44
void AllocatePK()
Definition: vibrato.cpp:74
double LogAS[100]
[0:M-1] source model
Definition: vibrato.h:68
double F0max
maximal fundamental frequency
Definition: vibrato.h:58
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)
Definition: vibrato.cpp:1182
double GetOldP()
Definition: vibrato.cpp:88
double F0min
minimal fundamental frequency
Definition: vibrato.h:59
void AllocateL(int AnL)
Definition: vibrato.cpp:50
void SaveToFile(char *filename)
Definition: vibrato.cpp:137
double ** fxr
[1:P-1][0:2K] single-cycle modulator shape coefficients - cosine, sine, cosine, ...
Definition: vibrato.h:51
void SynthesizeV(THS *HS, TVo *V, double sps, int UseK=0)
Definition: vibrato.cpp:1251
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)
Definition: vibrato.cpp:196