Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix in line 56 for pitchcontour segmentation #1165

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/algorithms/tonal/pitchcontours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ void PitchContours::compute() {
if (peakBins.size() != peakSaliences.size()) {
throw EssentiaException("PitchContours: peakBins and peakSaliences input vectors must have the same size");
}


// set duration to zero with empty input and exit
if (peakBins.size() ==0 ) {
contoursBins.clear();
contoursStartTimes.clear();
contoursSaliences.clear();
duration = 0;
return;
}

_numberFrames = peakBins.size();
duration = _numberFrames * _frameDuration;

Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/tonal/pitchcontours.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PitchContours : public Algorithm {
declareParameter("binResolution", "salience function bin resolution [cents]", "(0,inf)", 10.0);
declareParameter("peakFrameThreshold", "per-frame salience threshold factor (fraction of the highest peak salience in a frame)", "[0,1]", 0.9);
declareParameter("peakDistributionThreshold", "allowed deviation below the peak salience mean over all frames (fraction of the standard deviation)", "[0,2]", 0.9);
declareParameter("pitchContinuity", "pitch continuity cue (maximum allowed pitch change durig 1 ms time period) [cents]", "[0,inf)", 27.5625);
declareParameter("pitchContinuity", "pitch continuity cue (maximum allowed pitch change during 1 ms time period) [cents]", "[0,inf)", 27.5625);
declareParameter("timeContinuity", "time continuity cue (the maximum allowed gap duration for a pitch contour) [ms]", "(0,inf)", 100.);
declareParameter("minDuration", "the minimum allowed contour duration [ms]", "(0,inf)", 100.);
}
Expand Down
14 changes: 14 additions & 0 deletions src/algorithms/tonal/pitchcontoursegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ void PitchContourSegmentation::reSegment() {
// find sequences of consecutive non-zero pitch values
startC.clear();
endC.clear();

if (pitch.size()==0){
throw(EssentiaException("PitchContourSegmentation, resegment: Empty pitch values."));
}

if (pitch[0] > 0) {
startC.push_back(0);
Expand Down Expand Up @@ -79,6 +83,16 @@ void PitchContourSegmentation::compute() {
vector<Real>& duration = _duration.get();
vector<Real>& MIDIpitch = _MIDIpitch.get();



if (pitchGlob.size()==0){
throw(EssentiaException("PitchContourSegmentation: Empty pitch values."));
}


if (signal.size()==0){
throw(EssentiaException("PitchContourSegmentation: Empty signal values."));
}
// we do not want to access the actual pitch contour -> create copy
pitch = pitchGlob;

Expand Down
Loading