diff options
author | Be <be@mixxx.org> | 2018-11-01 06:01:54 -0500 |
---|---|---|
committer | Be <be@mixxx.org> | 2018-11-01 06:01:54 -0500 |
commit | 0d93f62170a0d1a6a09f9b17a942f3ed8a372305 (patch) | |
tree | 3ed629e1132da7fbf562c568a0fa6a2d78b720b4 /src/engine/bpmcontrol.cpp | |
parent | d27ce7a9e65ec1710f46f270d2c071d701d0341f (diff) | |
parent | 2fb8f08052c35ac3fce0566b2953db53bf027100 (diff) |
Merge remote-tracking branch 'upstream/2.1' into 2.2
Diffstat (limited to 'src/engine/bpmcontrol.cpp')
-rw-r--r-- | src/engine/bpmcontrol.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/engine/bpmcontrol.cpp b/src/engine/bpmcontrol.cpp index 17420204bd..66bd011d00 100644 --- a/src/engine/bpmcontrol.cpp +++ b/src/engine/bpmcontrol.cpp @@ -14,6 +14,7 @@ #include "util/math.h" #include "util/duration.h" +namespace { const int kMinBpm = 30; // Maximum allowed interval between beats (calculated from kMinBpm). const mixxx::Duration kMaxInterval = mixxx::Duration::fromMillis(1000.0 * (60.0 / kMinBpm)); @@ -21,6 +22,8 @@ const int kFilterLength = 5; // The local_bpm is calculated forward and backward this number of beats, so // the actual number of beats is this x2. const int kLocalBpmSpan = 4; +const SINT kSamplesPerFrame = 2; +} BpmControl::BpmControl(QString group, UserSettingsPointer pConfig) : @@ -849,8 +852,9 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const { dThisPrevBeat, dThisNextBeat, &dThisBeatLength, &dThisBeatFraction)) { pGroupFeatures->has_beat_length_sec = true; - // Note: dThisBeatLength is fractional frames count * 2 (stereo samples) - pGroupFeatures->beat_length_sec = dThisBeatLength / m_pTrack->getSampleRate() / 2 * calcRateRatio(); + // Note: dThisBeatLength is fractional frames count * 2 (stereo samples) + pGroupFeatures->beat_length_sec = dThisBeatLength / kSamplesPerFrame + / m_pTrack->getSampleRate() / calcRateRatio(); pGroupFeatures->has_beat_fraction = true; pGroupFeatures->beat_fraction = dThisBeatFraction; @@ -858,7 +862,6 @@ void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const { } double BpmControl::calcRateRatio() const { - double rateRatio = 1.0 + m_pRateDir->get() * m_pRateRange->get() * - m_pRateSlider->get(); - return rateRatio; + return std::max(1e-6, + 1.0 + m_pRateDir->get() * m_pRateRange->get() * m_pRateSlider->get()); } |