Mercurial > hg > silvet
diff src/Silvet.cpp @ 337:3c6f5d2d33e8 simultaneities
An abortive attempt at this (doesn't compile)
author | Chris Cannam |
---|---|
date | Sat, 27 Jun 2015 14:37:13 +0100 |
parents | d25e4aee73d7 |
children |
line wrap: on
line diff
--- a/src/Silvet.cpp Fri Jun 26 10:23:54 2015 +0100 +++ b/src/Silvet.cpp Sat Jun 27 14:37:13 2015 +0100 @@ -285,6 +285,20 @@ m_onOffsetsOutputNo = list.size(); list.push_back(d); + d.identifier = "simultaneities"; + d.name = "Simultaneities"; + d.description = "Events indicating which notes are active together. Whenever a note begins, it is collected with any other notes which begin during a short period of time immediately after, and the set of currently playing notes is reported as an event with the timestamp of the first note. Each feature has a variable number of values, depending on how many simultaneous notes are active."; + d.unit = "Hz"; + d.hasFixedBinCount = false; + d.binNames.clear(); + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::VariableSampleRate; + d.sampleRate = processingSampleRate / (m_cq ? m_cq->getColumnHop() : 62); + d.hasDuration = false; + m_simultaneitiesOutputNo = list.size(); + list.push_back(d); + d.identifier = "timefreq"; d.name = "Time-frequency distribution"; d.description = "Filtered constant-Q time-frequency distribution as used as input to the expectation-maximisation algorithm."; @@ -555,6 +569,7 @@ } m_pianoRoll.clear(); m_inputGains.clear(); + m_simultaneity = Simultaneity(); m_columnCount = 0; m_resampledCount = 0; m_startTime = RealTime::zeroTime; @@ -648,6 +663,10 @@ for (const auto &f : events.onOffsets) { fs[m_onOffsetsOutputNo].push_back(f); } + + for (const auto &f : events.simultaneities) { + fs[m_simultaneitiesOutputNo].push_back(f); + } } return fs; @@ -812,6 +831,10 @@ for (const auto &f : events.onOffsets) { fs[m_onOffsetsOutputNo].push_back(f); } + + for (const auto &f : events.simultaneities) { + fs[m_simultaneitiesOutputNo].push_back(f); + } } } @@ -1050,10 +1073,10 @@ int durationThreshold = floor(durationThrSec / columnDuration); // in cols if (durationThreshold < 1) durationThreshold = 1; - FeatureList noteFeatures, onsetFeatures, onOffsetFeatures; + FeatureList noteFeatures, onsetFeatures, onOffsetFeatures, simultaneousFeatures; if (width < durationThreshold + 1) { - return { noteFeatures, onsetFeatures, onOffsetFeatures }; + return { noteFeatures, onsetFeatures, onOffsetFeatures, simultaneousFeatures }; } for (map<int, double>::const_iterator ni = m_pianoRoll[width-1].begin(); @@ -1106,7 +1129,7 @@ // cerr << "returning " << noteFeatures.size() << " complete note(s) " << endl; - return { noteFeatures, onsetFeatures, onOffsetFeatures }; + return { noteFeatures, onsetFeatures, onOffsetFeatures, simultaneousFeatures }; } void @@ -1202,6 +1225,25 @@ shift)); } +void +Silvet::emitSimultaneity(int start, FeatureList &simultaneousFeatures) +{ + Feature f; + f.hasTimestamp = true; + f.timestamp = getColumnTimestamp(start); + f.hasDuration = false; + f.values.clear(); + for (auto ¬eShift : m_simultaneity.notesShifts) { + f.values.push_back(getNoteFrequency(noteShift.first, noteShift.second)); + } + f.label = ""; + for (auto ¬eShift : m_simultaneity.notesShifts) { + if (f.label != "") f.label += ","; + f.label += getNoteName(noteShift.first, noteShift.second); + } + simultaneousFeatures.push_back(f); +} + RealTime Silvet::getColumnTimestamp(int column) {