comparison src/Silvet.cpp @ 334:806b2ea65416 livemode

Detect repeated notes
author Chris Cannam
date Thu, 25 Jun 2015 14:18:44 +0100
parents 19c17cd0c7d8
children d861f86f2b17
comparison
equal deleted inserted replaced
333:19c17cd0c7d8 334:806b2ea65416
1009 1009
1010 if (width < durationThreshold + 1) { 1010 if (width < durationThreshold + 1) {
1011 return { noteFeatures, onsetFeatures }; 1011 return { noteFeatures, onsetFeatures };
1012 } 1012 }
1013 1013
1014 //!!! try: repeated note detection? (look for change in first derivative of the pitch matrix)
1015
1016 for (map<int, double>::const_iterator ni = m_pianoRoll[width-1].begin(); 1014 for (map<int, double>::const_iterator ni = m_pianoRoll[width-1].begin();
1017 ni != m_pianoRoll[width-1].end(); ++ni) { 1015 ni != m_pianoRoll[width-1].end(); ++ni) {
1018 1016
1019 int note = ni->first; 1017 int note = ni->first;
1020 1018
1039 1037
1040 if (active.find(note) == active.end()) { 1038 if (active.find(note) == active.end()) {
1041 // the note was playing but just ended 1039 // the note was playing but just ended
1042 m_current.erase(note); 1040 m_current.erase(note);
1043 emitNote(start, end, note, shiftCount, noteFeatures); 1041 emitNote(start, end, note, shiftCount, noteFeatures);
1042 } else { // still playing
1043 // repeated note detection: if level is greater than this
1044 // multiple of its previous value, then we end the note and
1045 // restart it with the same pitch
1046 double restartFactor = 1.5;
1047 if (duration >= durationThreshold * 2 &&
1048 (active.find(note)->second >
1049 restartFactor * m_pianoRoll[width-1][note])) {
1050 m_current.erase(note);
1051 emitNote(start, end-1, note, shiftCount, noteFeatures);
1052 // and remove this so that we start counting the new
1053 // note's duration from the current position
1054 m_pianoRoll[width-1].erase(note);
1055 }
1044 } 1056 }
1045 } 1057 }
1046 1058
1047 // cerr << "returning " << noteFeatures.size() << " complete note(s) " << endl; 1059 // cerr << "returning " << noteFeatures.size() << " complete note(s) " << endl;
1048 1060