Skip to content

Commit

Permalink
Merge pull request #4272 from Holzhaus/beatutils-cleanup
Browse files Browse the repository at this point in the history
Add some minor clarifications in BeatUtils::retrieveConstRegions()
  • Loading branch information
uklotzde committed Sep 8, 2021
2 parents 0fef878 + c788690 commit dec27e2
Showing 1 changed file with 4 additions and 5 deletions.
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

0 comments on commit dec27e2

Please sign in to comment.