# HG changeset patch # User Chris Cannam # Date 1435238324 -3600 # Node ID 806b2ea65416b320137ce1ab92c4560ce37eb46b # Parent 19c17cd0c7d8116225345191663c35cc114bfaa9 Detect repeated notes diff -r 19c17cd0c7d8 -r 806b2ea65416 Makefile.linux --- a/Makefile.linux Thu Jun 25 12:21:02 2015 +0100 +++ b/Makefile.linux Thu Jun 25 14:18:44 2015 +0100 @@ -6,7 +6,7 @@ CXXFLAGS := $(CFLAGS) -std=c++11 VAMPSDK_DIR := ../vamp-plugin-sdk -PLUGIN_LDFLAGS := -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map +PLUGIN_LDFLAGS := -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map -lpthread PLUGIN_EXT := .so diff -r 19c17cd0c7d8 -r 806b2ea65416 src/Silvet.cpp --- a/src/Silvet.cpp Thu Jun 25 12:21:02 2015 +0100 +++ b/src/Silvet.cpp Thu Jun 25 14:18:44 2015 +0100 @@ -1011,8 +1011,6 @@ return { noteFeatures, onsetFeatures }; } - //!!! try: repeated note detection? (look for change in first derivative of the pitch matrix) - for (map::const_iterator ni = m_pianoRoll[width-1].begin(); ni != m_pianoRoll[width-1].end(); ++ni) { @@ -1041,6 +1039,20 @@ // the note was playing but just ended m_current.erase(note); emitNote(start, end, note, shiftCount, noteFeatures); + } else { // still playing + // repeated note detection: if level is greater than this + // multiple of its previous value, then we end the note and + // restart it with the same pitch + double restartFactor = 1.5; + if (duration >= durationThreshold * 2 && + (active.find(note)->second > + restartFactor * m_pianoRoll[width-1][note])) { + m_current.erase(note); + emitNote(start, end-1, note, shiftCount, noteFeatures); + // and remove this so that we start counting the new + // note's duration from the current position + m_pianoRoll[width-1].erase(note); + } } }