Skip to content

Commit

Permalink
fix first beat: Use fmod
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Jun 9, 2021
1 parent 4355611 commit 554c2f0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/track/beatutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,9 @@ double BeatUtils::makeConstBpm(
// bpm adjustments are made.
// This is a temporary fix, ideally the anchor point for the BPM grid should
// be the first proper downbeat, or perhaps the CUE point.
*pFirstBeat = constantRegions[startRegionIndex].firstBeat;
const double roundedBeatLength = 60.0 * sampleRate / roundBpm;
const double beatsBeforeFirst = std::floor(*pFirstBeat / roundedBeatLength);
*pFirstBeat -= (roundedBeatLength * beatsBeforeFirst);
*pFirstBeat = fmod(constantRegions[startRegionIndex].firstBeat,
roundedBeatLength);
}
return roundBpm;
}
Expand Down

0 comments on commit 554c2f0

Please sign in to comment.