Mercurial > hg > silvet
comparison src/Silvet.cpp @ 57:49c0a139f165
Max, not median strength for velocity (duh)
author | Chris Cannam |
---|---|
date | Tue, 08 Apr 2014 13:36:07 +0100 |
parents | 384338fa460d |
children | d00a6f6c7fc9 |
comparison
equal
deleted
inserted
replaced
56:4fa3ea96eb65 | 57:49c0a139f165 |
---|---|
562 | 562 |
563 // the note was playing but just ended | 563 // the note was playing but just ended |
564 int end = width; | 564 int end = width; |
565 int start = end-1; | 565 int start = end-1; |
566 | 566 |
567 vector<double> strengths; | 567 double maxStrength = 0.0; |
568 | 568 |
569 while (m_pianoRoll[start].find(note) != m_pianoRoll[start].end()) { | 569 while (m_pianoRoll[start].find(note) != m_pianoRoll[start].end()) { |
570 strengths.push_back(m_pianoRoll[start][note]); | 570 double strength = m_pianoRoll[start][note]; |
571 if (strength > maxStrength) { | |
572 maxStrength = strength; | |
573 } | |
571 --start; | 574 --start; |
572 } | 575 } |
573 ++start; | 576 ++start; |
574 | 577 |
575 int duration = width - start; | 578 int duration = width - start; |
577 if (duration < durationThreshold) { | 580 if (duration < durationThreshold) { |
578 // spurious | 581 // spurious |
579 continue; | 582 continue; |
580 } | 583 } |
581 | 584 |
582 double medianStrength = MathUtilities::median | 585 int velocity = maxStrength * 2; |
583 (strengths.data(), strengths.size()); | |
584 int velocity = medianStrength * 2; | |
585 if (velocity > 127) velocity = 127; | 586 if (velocity > 127) velocity = 127; |
586 | 587 |
587 Feature nf; | 588 Feature nf; |
588 nf.hasTimestamp = true; | 589 nf.hasTimestamp = true; |
589 nf.timestamp = RealTime::fromSeconds(columnDuration * start); | 590 nf.timestamp = RealTime::fromSeconds(columnDuration * start); |