Mercurial > hg > silvet
comparison src/Silvet.cpp @ 323:6f8fa7fc8fdc livemode
Fix oversight which saw note tracking use pre-filtered pitches (resulting in many short notes)
author | Chris Cannam |
---|---|
date | Wed, 29 Apr 2015 10:56:30 +0100 |
parents | 213a51e197c8 |
children | 4cf4313d7e30 e8e37f471650 |
comparison
equal
deleted
inserted
replaced
322:7dda913d820b | 323:6f8fa7fc8fdc |
---|---|
253 m_notesOutputNo = list.size(); | 253 m_notesOutputNo = list.size(); |
254 list.push_back(d); | 254 list.push_back(d); |
255 | 255 |
256 d.identifier = "onsets"; | 256 d.identifier = "onsets"; |
257 d.name = "Note onsets"; | 257 d.name = "Note onsets"; |
258 d.description = "Note onsets, without durations. These can be calculated sooner than complete notes as it isn't necessary to wait for the note to finish. Each event has time, estimated fundamental frequency in Hz, and a synthetic MIDI velocity (1-127) estimated from the strength of the pitch in the mixture."; | 258 d.description = "Note onsets, without durations. These can be calculated sooner than complete notes, because it isn't necessary to wait for a note to finish before returning its feature. Each event has time, estimated fundamental frequency in Hz, and a synthetic MIDI velocity (1-127) estimated from the strength of the pitch in the mixture."; |
259 d.unit = "Hz"; | 259 d.unit = "Hz"; |
260 d.hasFixedBinCount = true; | 260 d.hasFixedBinCount = true; |
261 d.binCount = 2; | 261 d.binCount = 2; |
262 d.binNames.push_back("Frequency"); | 262 d.binNames.push_back("Frequency"); |
263 d.binNames.push_back("Velocity"); | 263 d.binNames.push_back("Velocity"); |
735 } | 735 } |
736 fs[m_chromaOutputNo].push_back(f); | 736 fs[m_chromaOutputNo].push_back(f); |
737 | 737 |
738 // This pushes the up-to-max-polyphony activation column to | 738 // This pushes the up-to-max-polyphony activation column to |
739 // m_pianoRoll | 739 // m_pianoRoll |
740 postProcess(localPitches[i], localBestShifts[i], wantShifts); | 740 postProcess(filtered, localBestShifts[i], wantShifts); |
741 | 741 |
742 auto events = noteTrack(shiftCount); | 742 auto events = noteTrack(shiftCount); |
743 | 743 |
744 FeatureList noteFeatures = events.first; | 744 FeatureList noteFeatures = events.first; |
745 for (FeatureList::const_iterator fi = noteFeatures.begin(); | 745 for (FeatureList::const_iterator fi = noteFeatures.begin(); |
925 // neighbouring semitones. Eliminate these by picking only the | 925 // neighbouring semitones. Eliminate these by picking only the |
926 // peaks. This means we can't recognise actual semitone chords | 926 // peaks. This means we can't recognise actual semitone chords |
927 // if they ever appear, but it's not as if live mode is good | 927 // if they ever appear, but it's not as if live mode is good |
928 // enough for that to be a big deal anyway. | 928 // enough for that to be a big deal anyway. |
929 if (m_mode == LiveMode) { | 929 if (m_mode == LiveMode) { |
930 if (j == 0 || j + 1 == pack.templateNoteCount || | 930 if (j == 0 || |
931 j + 1 == pack.templateNoteCount || | |
931 pitches[j] < pitches[j-1] || | 932 pitches[j] < pitches[j-1] || |
932 pitches[j] < pitches[j+1]) { | 933 pitches[j] < pitches[j+1]) { |
933 continue; | 934 continue; |
934 } | 935 } |
935 } | 936 } |
936 | 937 |
937 strengths.insert(ValueIndexMap::value_type(strength, j)); | 938 strengths.insert(ValueIndexMap::value_type(strength, j)); |
938 } | 939 } |
939 | 940 |
940 ValueIndexMap::const_iterator si = strengths.end(); | 941 ValueIndexMap::const_iterator si = strengths.end(); |
941 | 942 |
980 const map<int, double> &active = m_pianoRoll[width]; | 981 const map<int, double> &active = m_pianoRoll[width]; |
981 | 982 |
982 double columnDuration = 1.0 / m_colsPerSec; | 983 double columnDuration = 1.0 / m_colsPerSec; |
983 | 984 |
984 // only keep notes >= 100ms or thereabouts | 985 // only keep notes >= 100ms or thereabouts |
985 double durationThreshSec = 0.1; | 986 double durationThrSec = 0.1; |
986 if (m_mode == LiveMode) durationThreshSec = 0.07; | 987 if (m_mode == LiveMode) durationThrSec = 0.07; |
987 int durationThreshold = floor(durationThreshSec / columnDuration); // in cols | 988 int durationThreshold = floor(durationThrSec / columnDuration); // in cols |
988 if (durationThreshold < 1) durationThreshold = 1; | 989 if (durationThreshold < 1) durationThreshold = 1; |
989 | 990 |
990 FeatureList noteFeatures, onsetFeatures; | 991 FeatureList noteFeatures, onsetFeatures; |
991 | 992 |
992 if (width < durationThreshold + 1) { | 993 if (width < durationThreshold + 1) { |