comparison NNLSBase.cpp @ 41:d6bb9b43ac1c matthiasm-plugin

README and new parameters, not tested yet
author Matthias Mauch <mail@matthiasmauch.net>
date Fri, 22 Oct 2010 21:43:57 +0900
parents cf8898a0174c
children d01f94d58ef0
comparison
equal deleted inserted replaced
40:61d35e59ee2b 41:d6bb9b43ac1c
40 m_meanTuning1(0), 40 m_meanTuning1(0),
41 m_meanTuning2(0), 41 m_meanTuning2(0),
42 m_localTuning0(0), 42 m_localTuning0(0),
43 m_localTuning1(0), 43 m_localTuning1(0),
44 m_localTuning2(0), 44 m_localTuning2(0),
45 m_paling(1.0), 45 m_whitening(1.0),
46 m_preset(0.0), 46 m_preset(0.0),
47 m_localTuning(0), 47 m_localTuning(0),
48 m_kernelValue(0), 48 m_kernelValue(0),
49 m_kernelFftIndex(0), 49 m_kernelFftIndex(0),
50 m_kernelNoteIndex(0), 50 m_kernelNoteIndex(0),
52 m_tuneLocal(false), 52 m_tuneLocal(false),
53 m_dictID(0), 53 m_dictID(0),
54 m_chorddict(0), 54 m_chorddict(0),
55 m_chordnames(0), 55 m_chordnames(0),
56 m_doNormalizeChroma(0), 56 m_doNormalizeChroma(0),
57 m_rollon(0.01) 57 m_rollon(0.0),
58 m_s(0.7)
58 { 59 {
59 if (debug_on) cerr << "--> NNLSBase" << endl; 60 if (debug_on) cerr << "--> NNLSBase" << endl;
60 61
61 // make the *note* dictionary matrix 62 // make the *note* dictionary matrix
62 m_dict = new float[nNote * 84]; 63 m_dict = new float[nNote * 84];
63 for (unsigned i = 0; i < nNote * 84; ++i) m_dict[i] = 0.0; 64 for (unsigned i = 0; i < nNote * 84; ++i) m_dict[i] = 0.0;
64 dictionaryMatrix(m_dict); 65 dictionaryMatrix(m_dict, 0.7);
65 66
66 // get the *chord* dictionary from file (if the file exists) 67 // get the *chord* dictionary from file (if the file exists)
67 m_chordnames = chordDictionary(&m_chorddict); 68 m_chordnames = chordDictionary(&m_chorddict);
68 } 69 }
69 70
143 NNLSBase::getParameterDescriptors() const 144 NNLSBase::getParameterDescriptors() const
144 { 145 {
145 if (debug_on) cerr << "--> getParameterDescriptors" << endl; 146 if (debug_on) cerr << "--> getParameterDescriptors" << endl;
146 ParameterList list; 147 ParameterList list;
147 148
148 ParameterDescriptor d3; 149 ParameterDescriptor d0;
149 d3.identifier = "preset"; 150 d0.identifier = "rollon";
150 d3.name = "preset"; 151 d0.name = "spectral roll-on";
151 d3.description = "Spectral paling: no paling - 0; whitening - 1."; 152 d0.description = "The bins below the spectral roll-on quantile will be set to 0.";
152 d3.unit = ""; 153 d0.unit = "";
153 d3.isQuantized = true; 154 d0.minValue = 0;
154 d3.quantizeStep = 1; 155 d0.maxValue = 0.05;
155 d3.minValue = 0.0; 156 d0.defaultValue = 0;
156 d3.maxValue = 3.0; 157 d0.isQuantized = false;
157 d3.defaultValue = 0.0; 158 list.push_back(d0);
158 d3.valueNames.push_back("polyphonic pop");
159 d3.valueNames.push_back("polyphonic pop (fast)");
160 d3.valueNames.push_back("solo keyboard");
161 d3.valueNames.push_back("manual");
162 list.push_back(d3);
163
164 ParameterDescriptor d5;
165 d5.identifier = "rollon";
166 d5.name = "spectral roll-on";
167 d5.description = "The bins below the spectral roll-on quantile will be set to 0.";
168 d5.unit = "";
169 d5.minValue = 0;
170 d5.maxValue = 1;
171 d5.defaultValue = 0;
172 d5.isQuantized = false;
173 list.push_back(d5);
174
175 // ParameterDescriptor d0;
176 // d0.identifier = "notedict";
177 // d0.name = "note dictionary";
178 // d0.description = "Notes in different note dictionaries differ by their spectral shapes.";
179 // d0.unit = "";
180 // d0.minValue = 0;
181 // d0.maxValue = 1;
182 // d0.defaultValue = 0;
183 // d0.isQuantized = true;
184 // d0.valueNames.push_back("s = 0.6");
185 // d0.valueNames.push_back("no NNLS");
186 // d0.quantizeStep = 1.0;
187 // list.push_back(d0);
188 159
189 ParameterDescriptor d1; 160 ParameterDescriptor d1;
190 d1.identifier = "tuningmode"; 161 d1.identifier = "tuningmode";
191 d1.name = "tuning mode"; 162 d1.name = "tuning mode";
192 d1.description = "Tuning can be performed locally or on the whole extraction segment. Local tuning is only advisable when the tuning is likely to change over the audio, for example in podcasts, or in a cappella singing."; 163 d1.description = "Tuning can be performed locally or on the whole extraction segment. Local tuning is only advisable when the tuning is likely to change over the audio, for example in podcasts, or in a cappella singing.";
198 d1.valueNames.push_back("global tuning"); 169 d1.valueNames.push_back("global tuning");
199 d1.valueNames.push_back("local tuning"); 170 d1.valueNames.push_back("local tuning");
200 d1.quantizeStep = 1.0; 171 d1.quantizeStep = 1.0;
201 list.push_back(d1); 172 list.push_back(d1);
202 173
203 // ParameterDescriptor d2; 174 ParameterDescriptor d2;
204 // d2.identifier = "paling"; 175 d2.identifier = "whitening";
205 // d2.name = "spectral paling"; 176 d2.name = "spectral whitening";
206 // d2.description = "Spectral paling: no paling - 0; whitening - 1."; 177 d2.description = "Spectral whitening: no whitening - 0; whitening - 1.";
207 // d2.unit = ""; 178 d2.unit = "";
208 // d2.isQuantized = true; 179 d2.isQuantized = true;
209 // // d2.quantizeStep = 0.1; 180 d2.minValue = 0.0;
210 // d2.minValue = 0.0; 181 d2.maxValue = 1.0;
211 // d2.maxValue = 1.0; 182 d2.defaultValue = 1.0;
212 // d2.defaultValue = 1.0; 183 d2.isQuantized = false;
213 // d2.isQuantized = false; 184 list.push_back(d2);
214 // list.push_back(d2); 185
186 ParameterDescriptor d3;
187 d3.identifier = "s";
188 d3.name = "spectral shape";
189 d3.description = "Determines how individual notes in the note dictionary look: higher values mean more dominant higher harmonics.";
190 d3.unit = "";
191 d3.minValue = 0.5;
192 d3.maxValue = 0.9;
193 d3.defaultValue = 0.7;
194 d3.isQuantized = false;
195 list.push_back(d3);
196
215 ParameterDescriptor d4; 197 ParameterDescriptor d4;
216 d4.identifier = "chromanormalize"; 198 d4.identifier = "chromanormalize";
217 d4.name = "chroma normalization"; 199 d4.name = "chroma normalization";
218 d4.description = "How shall the chroma vector be normalized?"; 200 d4.description = "How shall the chroma vector be normalized?";
219 d4.unit = ""; 201 d4.unit = "";
237 if (debug_on) cerr << "--> getParameter" << endl; 219 if (debug_on) cerr << "--> getParameter" << endl;
238 if (identifier == "notedict") { 220 if (identifier == "notedict") {
239 return m_dictID; 221 return m_dictID;
240 } 222 }
241 223
242 if (identifier == "paling") { 224 if (identifier == "whitening") {
243 return m_paling; 225 return m_whitening;
226 }
227
228 if (identifier == "s") {
229 return m_s;
244 } 230 }
245 231
246 if (identifier == "rollon") { 232 if (identifier == "rollon") {
247 return m_rollon; 233 return m_rollon;
248 } 234 }
270 if (debug_on) cerr << "--> setParameter" << endl; 256 if (debug_on) cerr << "--> setParameter" << endl;
271 if (identifier == "notedict") { 257 if (identifier == "notedict") {
272 m_dictID = (int) value; 258 m_dictID = (int) value;
273 } 259 }
274 260
275 if (identifier == "paling") { 261 if (identifier == "whitening") {
276 m_paling = value; 262 m_whitening = value;
277 } 263 }
278 264
265 if (identifier == "s") {
266 m_s = value;
267 }
268
279 if (identifier == "tuningmode") { 269 if (identifier == "tuningmode") {
280 m_tuneLocal = (value > 0) ? true : false; 270 m_tuneLocal = (value > 0) ? true : false;
281 // cerr << "m_tuneLocal :" << m_tuneLocal << endl; 271 // cerr << "m_tuneLocal :" << m_tuneLocal << endl;
282 } 272 }
283 if (identifier == "preset") { 273 if (identifier == "preset") {
284 m_preset = value; 274 m_preset = value;
285 if (m_preset == 0.0) { 275 if (m_preset == 0.0) {
286 m_tuneLocal = false; 276 m_tuneLocal = false;
287 m_paling = 1.0; 277 m_whitening = 1.0;
288 m_dictID = 0.0; 278 m_dictID = 0.0;
289 } 279 }
290 if (m_preset == 1.0) { 280 if (m_preset == 1.0) {
291 m_tuneLocal = false; 281 m_tuneLocal = false;
292 m_paling = 1.0; 282 m_whitening = 1.0;
293 m_dictID = 1.0; 283 m_dictID = 1.0;
294 } 284 }
295 if (m_preset == 2.0) { 285 if (m_preset == 2.0) {
296 m_tuneLocal = false; 286 m_tuneLocal = false;
297 m_paling = 0.7; 287 m_whitening = 0.7;
298 m_dictID = 0.0; 288 m_dictID = 0.0;
299 } 289 }
300 } 290 }
301 if (identifier == "chromanormalize") { 291 if (identifier == "chromanormalize") {
302 m_doNormalizeChroma = value; 292 m_doNormalizeChroma = value;
563 runningstd = SpecialConvolution(runningstd,hw); // second step convolve 553 runningstd = SpecialConvolution(runningstd,hw); // second step convolve
564 for (int i = 0; i < 256; i++) { 554 for (int i = 0; i < 256; i++) {
565 runningstd[i] = sqrt(runningstd[i]); // square root to finally have running std 555 runningstd[i] = sqrt(runningstd[i]); // square root to finally have running std
566 if (runningstd[i] > 0) { 556 if (runningstd[i] > 0) {
567 // f2.values[i] = (f2.values[i] / runningmean[i]) > thresh ? 557 // f2.values[i] = (f2.values[i] / runningmean[i]) > thresh ?
568 // (f2.values[i] - runningmean[i]) / pow(runningstd[i],m_paling) : 0; 558 // (f2.values[i] - runningmean[i]) / pow(runningstd[i],m_whitening) : 0;
569 f2.values[i] = (f2.values[i] - runningmean[i]) > 0 ? 559 f2.values[i] = (f2.values[i] - runningmean[i]) > 0 ?
570 (f2.values[i] - runningmean[i]) / pow(runningstd[i],m_paling) : 0; 560 (f2.values[i] - runningmean[i]) / pow(runningstd[i],m_whitening) : 0;
571 } 561 }
572 if (f2.values[i] < 0) { 562 if (f2.values[i] < 0) {
573 cerr << "ERROR: negative value in logfreq spectrum" << endl; 563 cerr << "ERROR: negative value in logfreq spectrum" << endl;
574 } 564 }
575 } 565 }