AlgorithmStatus Key::process() { if (!shouldStop()) return PASS; const vector<vector<Real> >& hpcpKey = _pool.value<vector<vector<Real> > >("internal.hpcp"); vector<Real> hpcpAverage = meanFrames(hpcpKey); if (_pcpThreshold > 0.f) { normalizePcpPeak(hpcpAverage); pcpGate(hpcpAverage, _pcpThreshold); } if (_averageDetuningCorrection == true) { shiftPcp(hpcpAverage); } string key; string scale; Real strength; Real firstToSecondRelativeStrength; _keyAlgo->input("pcp").set(hpcpAverage); _keyAlgo->output("key").set(key); _keyAlgo->output("scale").set(scale); _keyAlgo->output("strength").set(strength); _keyAlgo->output("firstToSecondRelativeStrength").set(firstToSecondRelativeStrength); _keyAlgo->compute(); _key.push(key); _scale.push(scale); _strength.push(strength); return FINISHED; }
AlgorithmStatus ChordsDetection::process() { if (!shouldStop()) return PASS; const vector<vector<Real> >& hpcp = _pool.value<vector<vector<Real> > >("internal.hpcp"); string key; string scale; Real strength; Real firstToSecondRelativeStrength; // This is very strange, because we jump by a single frame each time, not by // the defined windowSize. Is that the expected behavior or is it a bug? // eaylon: windowSize is not intended for advancing, but for searching // nwack: maybe it could be a smart idea to jump from 1 beat to another instead // of a fixed amount a time (arbitrary frame size) for (int i=0; i<(int)hpcp.size(); i++) { int indexStart = max(0, i - _numFramesWindow/2); int indexEnd = min(i + _numFramesWindow/2, (int)hpcp.size()); vector<Real> hpcpAverage = meanFrames(hpcp, indexStart, indexEnd); normalize(hpcpAverage); _chordsAlgo->input("pcp").set(hpcpAverage); _chordsAlgo->output("key").set(key); _chordsAlgo->output("scale").set(scale); _chordsAlgo->output("strength").set(strength); _chordsAlgo->output("firstToSecondRelativeStrength").set(firstToSecondRelativeStrength); _chordsAlgo->compute(); if (scale == "minor") { _chords.push(key + 'm'); } else { _chords.push(key); } _strength.push(strength); } return FINISHED; }
void ChordsDetection::compute() { const vector<vector<Real> >& hpcp = _pcp.get(); vector<string>& chords= _chords.get(); vector<Real>& strength= _strength.get(); string key; string scale; Real firstToSecondRelativeStrength; Real str; // strength chords.reserve(int(hpcp.size()/_numFramesWindow)); strength.reserve(int(hpcp.size()/_numFramesWindow)); for (int i=0; i<int(hpcp.size()); ++i) { int indexStart = max(0, i - _numFramesWindow/2); int indexEnd = min(i + _numFramesWindow/2, (int)hpcp.size()); vector<Real> hpcpAverage = meanFrames(hpcp, indexStart, indexEnd); normalize(hpcpAverage); _chordsAlgo->input("pcp").set(hpcpAverage); _chordsAlgo->output("key").set(key); _chordsAlgo->output("scale").set(scale); _chordsAlgo->output("strength").set(str); _chordsAlgo->output("firstToSecondRelativeStrength").set(firstToSecondRelativeStrength); _chordsAlgo->compute(); if (scale == "minor") { chords.push_back(key + 'm'); } else { chords.push_back(key); } strength.push_back(str); } }
AlgorithmStatus Key::process() { if (!shouldStop()) return PASS; const vector<vector<Real> >& hpcpKey = _pool.value<vector<vector<Real> > >("internal.hpcp"); vector<Real> hpcpAverage = meanFrames(hpcpKey); string key; string scale; Real strength; Real firstToSecondRelativeStrength; _keyAlgo->configure("profileType", "temperley"); _keyAlgo->input("pcp").set(hpcpAverage); _keyAlgo->output("key").set(key); _keyAlgo->output("scale").set(scale); _keyAlgo->output("strength").set(strength); _keyAlgo->output("firstToSecondRelativeStrength").set(firstToSecondRelativeStrength); _keyAlgo->compute(); _key.push(key); _scale.push(scale); _strength.push(strength); return FINISHED; }