Skip to content
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.
Comment thread
ywwg marked this conversation as 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