Skip to content

Commit

Permalink
Beatgrid: Add debug asserts to ensure correct behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Dec 8, 2020
1 parent e0f70a2 commit 52ece75
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/track/beatgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ bool BeatGrid::isValid() const {
// This could be implemented in the Beats Class itself.
// If necessary, the child class can redefine it.
double BeatGrid::findNextBeat(double dSamples) const {
return findNthBeat(dSamples, +1);
const double position = findNthBeat(dSamples, +1);
DEBUG_ASSERT(position >= dSamples);
return position;
}

// This could be implemented in the Beats Class itself.
// If necessary, the child class can redefine it.
double BeatGrid::findPrevBeat(double dSamples) const {
return findNthBeat(dSamples, -1);
const double position = findNthBeat(dSamples, -1);
DEBUG_ASSERT(position <= dSamples);
return position;
}

// This is an internal call. This could be implemented in the Beats Class itself.
Expand Down

0 comments on commit 52ece75

Please sign in to comment.