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

Fix const beat grid first beat placement #3965

Merged
merged 4 commits into from
Jun 10, 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
15 changes: 11 additions & 4 deletions src/track/beatutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,23 @@ double BeatUtils::makeConstBpm(

// Create a const region region form the first beat of the first region to the last beat of the last region.

const double minRoundBpm = 60 * sampleRate / longestRegionBeatLengthMax;
const double maxRoundBpm = 60 * sampleRate / longestRegionBeatLengthMin;
const double centerBpm = 60 * sampleRate / longestRegionBeatLength;
const double minRoundBpm = 60.0 * sampleRate / longestRegionBeatLengthMax;
const double maxRoundBpm = 60.0 * sampleRate / longestRegionBeatLengthMin;
const double centerBpm = 60.0 * sampleRate / longestRegionBeatLength;

//qDebug() << "minRoundBpm" << minRoundBpm;
//qDebug() << "maxRoundBpm" << maxRoundBpm;
const double roundBpm = roundBpmWithinRange(minRoundBpm, centerBpm, maxRoundBpm);

if (pFirstBeat) {
*pFirstBeat = constantRegions[startRegionIndex].firstBeat;
// Move the first beat as close to the start of the track as we can. This is
// a constant beatgrid so "first beat" only affects the anchor point where
// bpm adjustments are made.
ywwg marked this conversation as resolved.
Show resolved Hide resolved
// This is a temporary fix, ideally the anchor point for the BPM grid should
// be the first proper downbeat, or perhaps the CUE point.
const double roundedBeatLength = 60.0 * sampleRate / roundBpm;
*pFirstBeat = fmod(constantRegions[startRegionIndex].firstBeat,
roundedBeatLength);
}
return roundBpm;
}
Expand Down