Mercurial > hg > silvet
comparison src/Silvet.cpp @ 150:d2bc51cc7f57
Some comments on things to try next...
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 18:09:06 +0100 |
parents | 450f9987f041 |
children | fc06b6f33021 |
comparison
equal
deleted
inserted
replaced
149:315986140a70 | 150:d2bc51cc7f57 |
---|---|
407 fs[m_fcqOutputNo].push_back(f); | 407 fs[m_fcqOutputNo].push_back(f); |
408 } | 408 } |
409 | 409 |
410 int width = filtered.size(); | 410 int width = filtered.size(); |
411 | 411 |
412 int iterations = 12; | 412 int iterations = 12; //!!! more might be good? |
413 | 413 |
414 Grid pitchMatrix(width, vector<double>(processingNotes)); | 414 Grid pitchMatrix(width, vector<double>(processingNotes)); |
415 | 415 |
416 #pragma omp parallel for | 416 #pragma omp parallel for |
417 for (int i = 0; i < width; ++i) { | 417 for (int i = 0; i < width; ++i) { |
428 for (int j = 0; j < iterations; ++j) { | 428 for (int j = 0; j < iterations; ++j) { |
429 em.iterate(filtered.at(i).data()); | 429 em.iterate(filtered.at(i).data()); |
430 } | 430 } |
431 | 431 |
432 const double *pitches = em.getPitchDistribution(); | 432 const double *pitches = em.getPitchDistribution(); |
433 | |
434 //!!! note: check the CQ output (and most immediately, the sum values here) against the MATLAB implementation | |
433 | 435 |
434 for (int j = 0; j < processingNotes; ++j) { | 436 for (int j = 0; j < processingNotes; ++j) { |
435 pitchMatrix[i][j] = pitches[j] * sum; | 437 pitchMatrix[i][j] = pitches[j] * sum; |
436 } | 438 } |
437 } | 439 } |
541 int postFilterLatency = int(m_postFilter[0]->getSize() / 2); | 543 int postFilterLatency = int(m_postFilter[0]->getSize() / 2); |
542 | 544 |
543 // Threshold for level and reduce number of candidate pitches | 545 // Threshold for level and reduce number of candidate pitches |
544 | 546 |
545 int polyphony = 5; | 547 int polyphony = 5; |
546 double threshold = 4.8; | 548 |
549 //!!! make this a parameter (was 4.8, try adjusting, compare levels against matlab code) | |
550 double threshold = 6; | |
547 | 551 |
548 typedef std::multimap<double, int> ValueIndexMap; | 552 typedef std::multimap<double, int> ValueIndexMap; |
549 | 553 |
550 ValueIndexMap strengths; | 554 ValueIndexMap strengths; |
551 for (int j = 0; j < processingNotes; ++j) { | 555 for (int j = 0; j < processingNotes; ++j) { |
569 // already, and if they haven't ended, we don't know their | 573 // already, and if they haven't ended, we don't know their |
570 // duration. | 574 // duration. |
571 | 575 |
572 int width = m_pianoRoll.size(); | 576 int width = m_pianoRoll.size(); |
573 | 577 |
578 //!!! adjust to only keep notes >= 100ms? or so | |
574 int durationThreshold = 2; // columns | 579 int durationThreshold = 2; // columns |
575 | 580 |
576 FeatureList noteFeatures; | 581 FeatureList noteFeatures; |
577 | 582 |
578 if (width < durationThreshold + 1) { | 583 if (width < durationThreshold + 1) { |
581 } | 586 } |
582 | 587 |
583 // we have 25 columns per second | 588 // we have 25 columns per second |
584 double columnDuration = 1.0 / 25.0; | 589 double columnDuration = 1.0 / 25.0; |
585 | 590 |
591 //!!! try: 20ms intervals in intensive mode | |
592 //!!! try: repeated note detection? (look for change in first derivative of the pitch matrix) | |
593 | |
586 for (map<int, double>::const_iterator ni = m_pianoRoll[width-1].begin(); | 594 for (map<int, double>::const_iterator ni = m_pianoRoll[width-1].begin(); |
587 ni != m_pianoRoll[width-1].end(); ++ni) { | 595 ni != m_pianoRoll[width-1].end(); ++ni) { |
588 | 596 |
589 int note = ni->first; | 597 int note = ni->first; |
590 | 598 |
621 cerr << "Found a genuine note, starting at " << columnDuration * start << " with duration " << columnDuration * duration << endl; | 629 cerr << "Found a genuine note, starting at " << columnDuration * start << " with duration " << columnDuration * duration << endl; |
622 | 630 |
623 Feature nf; | 631 Feature nf; |
624 nf.hasTimestamp = true; | 632 nf.hasTimestamp = true; |
625 nf.timestamp = RealTime::fromSeconds | 633 nf.timestamp = RealTime::fromSeconds |
626 (columnDuration * (start - postFilterLatency)); | 634 (columnDuration * (start - postFilterLatency) + 0.02); |
627 nf.hasDuration = true; | 635 nf.hasDuration = true; |
628 nf.duration = RealTime::fromSeconds | 636 nf.duration = RealTime::fromSeconds |
629 (columnDuration * duration); | 637 (columnDuration * duration); |
630 nf.values.push_back(noteFrequency(note)); | 638 nf.values.push_back(noteFrequency(note)); |
631 nf.values.push_back(velocity); | 639 nf.values.push_back(velocity); |