Mercurial > hg > silvet
comparison src/Silvet.cpp @ 160:58547262e735
Remove extra outputs
author | Chris Cannam |
---|---|
date | Tue, 20 May 2014 13:55:44 +0100 |
parents | 26d9a8b02adf |
children | 6003a9af43af |
comparison
equal
deleted
inserted
replaced
159:9d44ed673b85 | 160:58547262e735 |
---|---|
202 d.sampleRate = m_inputSampleRate / (m_cq ? m_cq->getColumnHop() : 62); | 202 d.sampleRate = m_inputSampleRate / (m_cq ? m_cq->getColumnHop() : 62); |
203 d.hasDuration = true; | 203 d.hasDuration = true; |
204 m_notesOutputNo = list.size(); | 204 m_notesOutputNo = list.size(); |
205 list.push_back(d); | 205 list.push_back(d); |
206 | 206 |
207 d.identifier = "cq"; | |
208 d.name = "Raw constant-Q"; | |
209 d.description = "Unfiltered constant-Q time-frequency distribution"; | |
210 d.unit = ""; | |
211 d.hasFixedBinCount = true; | |
212 d.binCount = processingHeight + 55; | |
213 d.binNames.clear(); | |
214 if (m_cq) { | |
215 //!!! I think this output is not working correctly, and these values may be wrong | |
216 char name[20]; | |
217 for (int i = 0; i < processingHeight + 55; ++i) { | |
218 float freq = m_cq->getBinFrequency(processingHeight + 54 - i); | |
219 sprintf(name, "%.1f Hz", freq); | |
220 d.binNames.push_back(name); | |
221 } | |
222 } | |
223 d.hasKnownExtents = false; | |
224 d.isQuantized = false; | |
225 d.sampleType = OutputDescriptor::FixedSampleRate; | |
226 d.sampleRate = m_inputSampleRate / (m_cq ? m_cq->getColumnHop() : 62); | |
227 d.hasDuration = false; | |
228 m_cqOutputNo = list.size(); | |
229 list.push_back(d); | |
230 | |
231 d.identifier = "inputgrid"; | |
232 d.name = "Filtered constant-Q"; | |
233 d.description = "Filtered constant-Q time-frequency distribution used as input to the PLCA step"; | |
234 d.unit = ""; | |
235 d.hasFixedBinCount = true; | |
236 d.binCount = processingHeight; | |
237 d.binNames.clear(); | |
238 if (m_cq) { | |
239 //!!! I think this output is not working correctly, and these values may be wrong | |
240 char name[20]; | |
241 for (int i = 0; i < processingHeight; ++i) { | |
242 float freq = m_cq->getBinFrequency(processingHeight + 54 - i); | |
243 sprintf(name, "%.1f Hz", freq); | |
244 d.binNames.push_back(name); | |
245 } | |
246 } | |
247 d.hasKnownExtents = false; | |
248 d.isQuantized = false; | |
249 d.sampleType = OutputDescriptor::FixedSampleRate; | |
250 d.sampleRate = 25; | |
251 d.hasDuration = false; | |
252 m_fcqOutputNo = list.size(); | |
253 list.push_back(d); | |
254 | |
255 d.identifier = "pitches"; | |
256 d.name = "Pitch activation"; | |
257 d.description = "Estimated pitch activation matrix"; | |
258 d.unit = ""; | |
259 d.hasFixedBinCount = true; | |
260 d.binCount = processingNotes; | |
261 d.binNames.clear(); | |
262 for (int i = 0; i < processingNotes; ++i) { | |
263 d.binNames.push_back(noteName(i)); | |
264 } | |
265 d.hasKnownExtents = false; | |
266 d.isQuantized = false; | |
267 d.sampleType = OutputDescriptor::FixedSampleRate; | |
268 d.sampleRate = 25; | |
269 d.hasDuration = false; | |
270 m_pitchOutputNo = list.size(); | |
271 list.push_back(d); | |
272 | |
273 return list; | 207 return list; |
274 } | 208 } |
275 | 209 |
276 std::string | 210 std::string |
277 Silvet::noteName(int i) const | 211 Silvet::noteName(int i) const |
372 data = m_resampler->process(data.data(), data.size()); | 306 data = m_resampler->process(data.data(), data.size()); |
373 } | 307 } |
374 | 308 |
375 Grid cqout = m_cq->process(data); | 309 Grid cqout = m_cq->process(data); |
376 FeatureSet fs = transcribe(cqout); | 310 FeatureSet fs = transcribe(cqout); |
377 | |
378 for (int i = 0; i < (int)cqout.size(); ++i) { | |
379 Feature f; | |
380 for (int j = 0; j < (int)cqout[i].size(); ++j) { | |
381 f.values.push_back(float(cqout[i][j])); | |
382 } | |
383 fs[m_cqOutputNo].push_back(f); | |
384 } | |
385 | |
386 return fs; | 311 return fs; |
387 } | 312 } |
388 | 313 |
389 Silvet::FeatureSet | 314 Silvet::FeatureSet |
390 Silvet::getRemainingFeatures() | 315 Silvet::getRemainingFeatures() |
391 { | 316 { |
392 Grid cqout = m_cq->getRemainingOutput(); | 317 Grid cqout = m_cq->getRemainingOutput(); |
393 FeatureSet fs = transcribe(cqout); | 318 FeatureSet fs = transcribe(cqout); |
394 | |
395 for (int i = 0; i < (int)cqout.size(); ++i) { | |
396 Feature f; | |
397 for (int j = 0; j < (int)cqout[i].size(); ++j) { | |
398 f.values.push_back(float(cqout[i][j])); | |
399 } | |
400 fs[m_cqOutputNo].push_back(f); | |
401 } | |
402 | |
403 return fs; | 319 return fs; |
404 } | 320 } |
405 | 321 |
406 Silvet::FeatureSet | 322 Silvet::FeatureSet |
407 Silvet::transcribe(const Grid &cqout) | 323 Silvet::transcribe(const Grid &cqout) |
409 Grid filtered = preProcess(cqout); | 325 Grid filtered = preProcess(cqout); |
410 | 326 |
411 FeatureSet fs; | 327 FeatureSet fs; |
412 | 328 |
413 if (filtered.empty()) return fs; | 329 if (filtered.empty()) return fs; |
414 | |
415 for (int i = 0; i < (int)filtered.size(); ++i) { | |
416 Feature f; | |
417 for (int j = 0; j < processingHeight; ++j) { | |
418 f.values.push_back(float(filtered[i][j])); | |
419 } | |
420 fs[m_fcqOutputNo].push_back(f); | |
421 } | |
422 | 330 |
423 int width = filtered.size(); | 331 int width = filtered.size(); |
424 | 332 |
425 int iterations = 12; //!!! more might be good? | 333 int iterations = 12; //!!! more might be good? |
426 | 334 |
453 } | 361 } |
454 } | 362 } |
455 | 363 |
456 for (int i = 0; i < width; ++i) { | 364 for (int i = 0; i < width; ++i) { |
457 | 365 |
458 Feature f; | |
459 for (int j = 0; j < processingNotes; ++j) { | |
460 f.values.push_back(float(pitchMatrix[i][j])); | |
461 } | |
462 fs[m_pitchOutputNo].push_back(f); | |
463 | |
464 FeatureList noteFeatures = postProcess(pitchMatrix[i]); | 366 FeatureList noteFeatures = postProcess(pitchMatrix[i]); |
465 | 367 |
466 for (FeatureList::const_iterator fi = noteFeatures.begin(); | 368 for (FeatureList::const_iterator fi = noteFeatures.begin(); |
467 fi != noteFeatures.end(); ++fi) { | 369 fi != noteFeatures.end(); ++fi) { |
468 fs[m_notesOutputNo].push_back(*fi); | 370 fs[m_notesOutputNo].push_back(*fi); |