Mercurial > hg > x
comparison hsedit.cpp @ 5:5f3c32dc6e17
* Adjust comment syntax to permit Doxygen to generate HTML documentation; add Doxyfile
author | Chris Cannam |
---|---|
date | Wed, 06 Oct 2010 15:19:49 +0100 |
parents | 6422640a802f |
children | 977f541d6683 |
comparison
equal
deleted
inserted
replaced
4:92ee28024c05 | 5:5f3c32dc6e17 |
---|---|
1 //--------------------------------------------------------------------------- | 1 //--------------------------------------------------------------------------- |
2 | 2 |
3 #include "hsedit.h" | 3 #include "hsedit.h" |
4 #include "splines.h" | 4 #include "splines.h" |
5 | 5 |
6 /** \file hsedit.h */ | |
7 | |
6 //--------------------------------------------------------------------------- | 8 //--------------------------------------------------------------------------- |
7 | 9 |
8 /* | 10 /** |
9 function DeFM: frequency de-modulation | 11 function DeFM: frequency de-modulation |
10 | 12 |
11 In: peakfr[npfr]: segmentation into FM cycles, peakfr[0]=0, peakfr[npfr-1]=Fr-1 | 13 In: peakfr[npfr]: segmentation into FM cycles, peakfr[0]=0, peakfr[npfr-1]=Fr-1 |
12 a1[Fr], f1[Fr]: sequence of amplitudes and frequencies | 14 a1[Fr], f1[Fr]: sequence of amplitudes and frequencies |
13 arec[Fr]: amplitude-based weights for frequency averaging | 15 arec[Fr]: amplitude-based weights for frequency averaging |
32 CubicSpline(npfr-1, aa, ab, ac, ad, frs, a, 1, 1, a2); | 34 CubicSpline(npfr-1, aa, ab, ac, ad, frs, a, 1, 1, a2); |
33 CubicSpline(npfr-1, fa, fb, fc, fd, frs, f, 1, 1, f2); | 35 CubicSpline(npfr-1, fa, fb, fc, fd, frs, f, 1, 1, f2); |
34 delete[] frs; | 36 delete[] frs; |
35 }//DeFM | 37 }//DeFM |
36 | 38 |
37 /* | 39 /** |
38 function DFMSeg: segments HS frames into FM cycles | 40 function DFMSeg: segments HS frames into FM cycles |
39 | 41 |
40 In: partials[M][Fr]: HS partials | 42 In: partials[M][Fr]: HS partials |
41 Out: peakfr[npfr]: segmentation, peakfr[0]=0, peakfr[npfr-1]=Fr-1. | 43 Out: peakfr[npfr]: segmentation, peakfr[0]=0, peakfr[npfr-1]=Fr-1. |
42 arec[Fr]: total amplitudes of frames | 44 arec[Fr]: total amplitudes of frames |
60 } | 62 } |
61 peakfr[npfr++]=Fr-1; | 63 peakfr[npfr++]=Fr-1; |
62 delete[] frec; | 64 delete[] frec; |
63 }//DFMSeg | 65 }//DFMSeg |
64 | 66 |
65 /* | 67 /** |
66 function HSAM: harmonic sinusoid amplitude modulation | 68 function HSAM: harmonic sinusoid amplitude modulation |
67 | 69 |
68 In: SrcHS: source harmonic sinusoid | 70 In: SrcHS: source harmonic sinusoid |
69 dep: modulation depth | 71 dep: modulation depth |
70 fre: modulator frequency | 72 fre: modulator frequency |
79 for (int m=0; m<HS->M; m++) | 81 for (int m=0; m<HS->M; m++) |
80 for (int fr=0; fr<HS->Fr; fr++) | 82 for (int fr=0; fr<HS->Fr; fr++) |
81 HS->Partials[m][fr].a=SrcHS->Partials[m][fr].a*(1+dep*cos(omg*SrcHS->Partials[m][fr].t+ph)); | 83 HS->Partials[m][fr].a=SrcHS->Partials[m][fr].a*(1+dep*cos(omg*SrcHS->Partials[m][fr].t+ph)); |
82 }//HSAM | 84 }//HSAM |
83 | 85 |
84 /* | 86 /** |
85 function HSFM: harmonic sinusoid frequency modulation | 87 function HSFM: harmonic sinusoid frequency modulation |
86 | 88 |
87 In: SrcHS: source harmonic sinusoid | 89 In: SrcHS: source harmonic sinusoid |
88 a: modulation extent, in semitones | 90 a: modulation extent, in semitones |
89 fre: modulator frequency | 91 fre: modulator frequency |
98 for (int m=0; m<HS->M; m++) | 100 for (int m=0; m<HS->M; m++) |
99 for (int fr=0; fr<HS->Fr; fr++) | 101 for (int fr=0; fr<HS->Fr; fr++) |
100 HS->Partials[m][fr].f=SrcHS->Partials[m][fr].f*(1+pa*cos(omg*SrcHS->Partials[m][fr].t+ph)); | 102 HS->Partials[m][fr].f=SrcHS->Partials[m][fr].f*(1+pa*cos(omg*SrcHS->Partials[m][fr].t+ph)); |
101 }//HSFM | 103 }//HSFM |
102 | 104 |
103 /* | 105 /** |
104 function HSFM_SF: harmonic sinusoid frequency modulation with source-filter model | 106 function HSFM_SF: harmonic sinusoid frequency modulation with source-filter model |
105 | 107 |
106 In: SrcHS: source harmonic sinusoid | 108 In: SrcHS: source harmonic sinusoid |
107 a: modulation extent, in semitones | 109 a: modulation extent, in semitones |
108 fre: modulator frequency | 110 fre: modulator frequency |
122 HS->Partials[m][fr].f=f1; | 124 HS->Partials[m][fr].f=f1; |
123 HS->Partials[m][fr].a=SrcHS->Partials[m][fr].a*exp(SF->LogAF(f1)-SF->LogAF(f0)); | 125 HS->Partials[m][fr].a=SrcHS->Partials[m][fr].a*exp(SF->LogAF(f1)-SF->LogAF(f0)); |
124 } | 126 } |
125 }//HSFM_SF | 127 }//HSFM_SF |
126 | 128 |
127 /* | 129 /** |
128 function: HSPitchShift: harmonic sinusoid pitch shifting | 130 function: HSPitchShift: harmonic sinusoid pitch shifting |
129 | 131 |
130 In: SrcHS: source harmonic sinusoid | 132 In: SrcHS: source harmonic sinusoid |
131 ps12: amount of pitch shift, in semitones | 133 ps12: amount of pitch shift, in semitones |
132 Out: HS: destination harmonic sinusoid | 134 Out: HS: destination harmonic sinusoid |
137 { | 139 { |
138 double pa=pow(2, ps12/12.0); | 140 double pa=pow(2, ps12/12.0); |
139 for (int m=0; m<HS->M; m++) for (int fr=0; fr<HS->Fr; fr++) HS->Partials[m][fr].f=SrcHS->Partials[m][fr].f*pa; | 141 for (int m=0; m<HS->M; m++) for (int fr=0; fr<HS->Fr; fr++) HS->Partials[m][fr].f=SrcHS->Partials[m][fr].f*pa; |
140 }//HSPitchShift | 142 }//HSPitchShift |
141 | 143 |
142 /* | 144 /** |
143 function ReFM: frequency re-modulation | 145 function ReFM: frequency re-modulation |
144 | 146 |
145 In: partials[M][Fr]: HS partials | 147 In: partials[M][Fr]: HS partials |
146 amount: relative modulation depth after remodulation | 148 amount: relative modulation depth after remodulation |
147 rate: relateive modulation rate after remodulation | 149 rate: relateive modulation rate after remodulation |