Mercurial > hg > silvet
comparison src/Silvet.cpp @ 127:df05f855f63b
Merge from branch bqvec-openmp
author | Chris Cannam |
---|---|
date | Wed, 07 May 2014 11:55:32 +0100 |
parents | 230920148ee5 |
children | 450f9987f041 |
comparison
equal
deleted
inserted
replaced
110:e282930cfca7 | 127:df05f855f63b |
---|---|
39 | 39 |
40 Silvet::Silvet(float inputSampleRate) : | 40 Silvet::Silvet(float inputSampleRate) : |
41 Plugin(inputSampleRate), | 41 Plugin(inputSampleRate), |
42 m_resampler(0), | 42 m_resampler(0), |
43 m_cq(0), | 43 m_cq(0), |
44 m_hqMode(false) | 44 m_hqMode(true) |
45 { | 45 { |
46 } | 46 } |
47 | 47 |
48 Silvet::~Silvet() | 48 Silvet::~Silvet() |
49 { | 49 { |
136 desc.name = "Processing mode"; | 136 desc.name = "Processing mode"; |
137 desc.unit = ""; | 137 desc.unit = ""; |
138 desc.description = "Determines the tradeoff of processing speed against transcription quality"; | 138 desc.description = "Determines the tradeoff of processing speed against transcription quality"; |
139 desc.minValue = 0; | 139 desc.minValue = 0; |
140 desc.maxValue = 1; | 140 desc.maxValue = 1; |
141 desc.defaultValue = 0; | 141 desc.defaultValue = 1; |
142 desc.isQuantized = true; | 142 desc.isQuantized = true; |
143 desc.quantizeStep = 1; | 143 desc.quantizeStep = 1; |
144 desc.valueNames.push_back("Draft (faster)"); | 144 desc.valueNames.push_back("Draft (faster)"); |
145 desc.valueNames.push_back("Intensive (higher quality)"); | 145 desc.valueNames.push_back("Intensive (higher quality)"); |
146 list.push_back(desc); | 146 list.push_back(desc); |
395 { | 395 { |
396 Grid filtered = preProcess(cqout); | 396 Grid filtered = preProcess(cqout); |
397 | 397 |
398 FeatureSet fs; | 398 FeatureSet fs; |
399 | 399 |
400 if (filtered.empty()) return fs; | |
401 | |
400 for (int i = 0; i < (int)filtered.size(); ++i) { | 402 for (int i = 0; i < (int)filtered.size(); ++i) { |
401 Feature f; | 403 Feature f; |
402 for (int j = 0; j < processingHeight; ++j) { | 404 for (int j = 0; j < processingHeight; ++j) { |
403 f.values.push_back(float(filtered[i][j])); | 405 f.values.push_back(float(filtered[i][j])); |
404 } | 406 } |
407 | 409 |
408 int width = filtered.size(); | 410 int width = filtered.size(); |
409 | 411 |
410 int iterations = 12; | 412 int iterations = 12; |
411 | 413 |
414 Grid pitchMatrix(width, vector<double>(processingNotes)); | |
415 | |
416 #pragma omp parallel for | |
412 for (int i = 0; i < width; ++i) { | 417 for (int i = 0; i < width; ++i) { |
413 | 418 |
414 double sum = 0.0; | 419 double sum = 0.0; |
415 for (int j = 0; j < processingHeight; ++j) { | 420 for (int j = 0; j < processingHeight; ++j) { |
416 sum += filtered[i][j]; | 421 sum += filtered.at(i).at(j); |
417 } | 422 } |
418 | 423 |
419 if (sum < 1e-5) continue; | 424 if (sum < 1e-5) continue; |
420 | 425 |
421 EM em(m_hqMode); | 426 EM em(m_hqMode); |
427 | |
422 for (int j = 0; j < iterations; ++j) { | 428 for (int j = 0; j < iterations; ++j) { |
423 em.iterate(filtered[i]); | 429 em.iterate(filtered.at(i).data()); |
424 } | 430 } |
425 | 431 |
426 vector<double> pitches = em.getPitchDistribution(); | 432 const double *pitches = em.getPitchDistribution(); |
427 | 433 |
428 for (int j = 0; j < processingNotes; ++j) { | 434 for (int j = 0; j < processingNotes; ++j) { |
429 pitches[j] *= sum; | 435 pitchMatrix[i][j] = pitches[j] * sum; |
430 } | 436 } |
431 | 437 } |
438 | |
439 for (int i = 0; i < width; ++i) { | |
440 | |
432 Feature f; | 441 Feature f; |
433 for (int j = 0; j < processingNotes; ++j) { | 442 for (int j = 0; j < processingNotes; ++j) { |
434 f.values.push_back(float(pitches[j])); | 443 f.values.push_back(float(pitchMatrix[i][j])); |
435 } | 444 } |
436 fs[m_pitchOutputNo].push_back(f); | 445 fs[m_pitchOutputNo].push_back(f); |
437 | 446 |
438 FeatureList noteFeatures = postProcess(pitches); | 447 FeatureList noteFeatures = postProcess(pitchMatrix[i]); |
439 | 448 |
440 for (FeatureList::const_iterator fi = noteFeatures.begin(); | 449 for (FeatureList::const_iterator fi = noteFeatures.begin(); |
441 fi != noteFeatures.end(); ++fi) { | 450 fi != noteFeatures.end(); ++fi) { |
442 fs[m_notesOutputNo].push_back(*fi); | 451 fs[m_notesOutputNo].push_back(*fi); |
443 } | 452 } |