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

Add some minor clarifications in BeatUtils::retrieveConstRegions() #4272

Merged
merged 3 commits into from
Sep 8, 2021
Merged
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
9 changes: 4 additions & 5 deletions src/track/beatutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr double kMaxSecsPhaseError = 0.025;
// This is set to avoid to use a constant region during an offset shift.
// That happens for instance when the beat instrument changes.
constexpr double kMaxSecsPhaseErrorSum = 0.1;
constexpr int kMaxOutlierCount = 1;
constexpr int kMaxOutliersCount = 1;
constexpr int kMinRegionBeatCount = 16;

} // namespace
Expand Down Expand Up @@ -72,8 +72,7 @@ QVector<BeatUtils::ConstRegion> BeatUtils::retrieveConstRegions(
// Than we start with the region from the found beat to the end.

QVector<ConstRegion> constantRegions;
if (!coarseBeats.size()) {
// no beats
if (coarseBeats.isEmpty()) {
return constantRegions;
}

Expand All @@ -97,7 +96,7 @@ QVector<BeatUtils::ConstRegion> BeatUtils::retrieveConstRegions(
phaseErrorSum += phaseError;
if (fabs(phaseError) > maxPhaseError) {
outliersCount++;
if (outliersCount > kMaxOutlierCount ||
if (outliersCount > kMaxOutliersCount ||
i == leftIndex + 1) { // the first beat must not be an outlier.
// region is not const.
break;
Expand Down Expand Up @@ -135,7 +134,7 @@ QVector<BeatUtils::ConstRegion> BeatUtils::retrieveConstRegions(
}

// Add a final region with zero length to mark the end.
constantRegions.append({coarseBeats[coarseBeats.size() - 1], 0});
constantRegions.append({coarseBeats.last(), 0});
return constantRegions;
}

Expand Down