Mercurial > hg > silvet
comparison src/Silvet.cpp @ 152:74f14efe032f
Update subrepo to new structure
author | Chris Cannam |
---|---|
date | Thu, 15 May 2014 15:25:03 +0100 |
parents | fc06b6f33021 |
children | c6b6d6ea1c3d |
comparison
equal
deleted
inserted
replaced
151:fc06b6f33021 | 152:74f14efe032f |
---|---|
14 */ | 14 */ |
15 | 15 |
16 #include "Silvet.h" | 16 #include "Silvet.h" |
17 #include "EM.h" | 17 #include "EM.h" |
18 | 18 |
19 #include "maths/MedianFilter.h" | 19 #include <cq/CQSpectrogram.h> |
20 #include "maths/MathUtilities.h" | 20 |
21 #include "dsp/rateconversion/Resampler.h" | 21 #include "MedianFilter.h" |
22 | 22 #include "constant-q-cpp/src/dsp/Resampler.h" |
23 #include "constant-q-cpp/cpp-qm-dsp/CQSpectrogram.h" | |
24 | 23 |
25 #include <vector> | 24 #include <vector> |
26 | 25 |
27 #include <cstdio> | 26 #include <cstdio> |
28 | 27 |
419 double sum = 0.0; | 418 double sum = 0.0; |
420 for (int j = 0; j < processingHeight; ++j) { | 419 for (int j = 0; j < processingHeight; ++j) { |
421 sum += filtered.at(i).at(j); | 420 sum += filtered.at(i).at(j); |
422 } | 421 } |
423 | 422 |
423 // cerr << "sum: " << sum << endl; | |
424 | |
424 if (sum < 1e-5) continue; | 425 if (sum < 1e-5) continue; |
425 | 426 |
426 EM em(m_hqMode); | 427 EM em(m_hqMode); |
427 | 428 |
428 for (int j = 0; j < iterations; ++j) { | 429 for (int j = 0; j < iterations; ++j) { |
559 map<int, double> active; | 560 map<int, double> active; |
560 ValueIndexMap::const_iterator si = strengths.end(); | 561 ValueIndexMap::const_iterator si = strengths.end(); |
561 while (int(active.size()) < polyphony) { | 562 while (int(active.size()) < polyphony) { |
562 --si; | 563 --si; |
563 if (si->first < threshold) break; | 564 if (si->first < threshold) break; |
564 cerr << si->second << " : " << si->first << endl; | 565 // cerr << si->second << " : " << si->first << endl; |
565 active[si->second] = si->first; | 566 active[si->second] = si->first; |
566 if (si == strengths.begin()) break; | 567 if (si == strengths.begin()) break; |
567 } | 568 } |
568 | 569 |
569 // Minimum duration pruning, and conversion to notes. We can only | 570 // Minimum duration pruning, and conversion to notes. We can only |
574 // duration. | 575 // duration. |
575 | 576 |
576 int width = m_pianoRoll.size(); | 577 int width = m_pianoRoll.size(); |
577 | 578 |
578 //!!! adjust to only keep notes >= 100ms? or so | 579 //!!! adjust to only keep notes >= 100ms? or so |
579 int durationThreshold = 2; // columns | 580 int durationThreshold = 3; // columns |
580 | 581 |
581 FeatureList noteFeatures; | 582 FeatureList noteFeatures; |
582 | 583 |
583 if (width < durationThreshold + 1) { | 584 if (width < durationThreshold + 1) { |
584 m_pianoRoll.push_back(active); | 585 m_pianoRoll.push_back(active); |
624 } | 625 } |
625 | 626 |
626 int velocity = maxStrength * 2; | 627 int velocity = maxStrength * 2; |
627 if (velocity > 127) velocity = 127; | 628 if (velocity > 127) velocity = 127; |
628 | 629 |
629 cerr << "Found a genuine note, starting at " << columnDuration * start << " with duration " << columnDuration * duration << endl; | 630 // cerr << "Found a genuine note, starting at " << columnDuration * start << " with duration " << columnDuration * duration << endl; |
630 | 631 |
631 Feature nf; | 632 Feature nf; |
632 nf.hasTimestamp = true; | 633 nf.hasTimestamp = true; |
633 nf.timestamp = RealTime::fromSeconds | 634 nf.timestamp = RealTime::fromSeconds |
634 (columnDuration * (start - postFilterLatency) + 0.02); | 635 (columnDuration * (start - postFilterLatency) + 0.02); |