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

Beats: Remove unnecessary capabilities #4103

Merged
merged 1 commit into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ void BpmControl::slotTranslateBeatsEarlier(double v) {
return;
}
const mixxx::BeatsPointer pBeats = pTrack->getBeats();
if (pBeats &&
(pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_TRANSLATE)) {
if (pBeats) {
const double sampleOffset = getSampleOfTrack().rate * -0.01;
const mixxx::audio::FrameDiff_t frameOffset = sampleOffset / mixxx::kEngineChannelCount;
pTrack->trySetBeats(pBeats->translate(frameOffset));
Expand All @@ -221,8 +220,7 @@ void BpmControl::slotTranslateBeatsLater(double v) {
return;
}
const mixxx::BeatsPointer pBeats = pTrack->getBeats();
if (pBeats &&
(pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_TRANSLATE)) {
if (pBeats) {
// TODO(rryan): Track::getSampleRate is possibly inaccurate!
const double sampleOffset = getSampleOfTrack().rate * 0.01;
const mixxx::audio::FrameDiff_t frameOffset = sampleOffset / mixxx::kEngineChannelCount;
Expand Down Expand Up @@ -1043,7 +1041,7 @@ void BpmControl::slotBeatsTranslate(double v) {
return;
}
const mixxx::BeatsPointer pBeats = pTrack->getBeats();
if (pBeats && (pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_TRANSLATE)) {
if (pBeats) {
const auto currentPosition =
mixxx::audio::FramePos::fromEngineSamplePos(
getSampleOfTrack().current)
Expand All @@ -1063,7 +1061,7 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) {
return;
}
const mixxx::BeatsPointer pBeats = pTrack->getBeats();
if (pBeats && (pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_TRANSLATE)) {
if (pBeats) {
// Must reset the user offset *before* calling getPhaseOffset(),
// otherwise it will always return 0 if master sync is active.
m_dUserOffset.setValue(0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/track/beatgrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BeatGrid final : public Beats {
// comments in beats.h

Beats::CapabilitiesFlags getCapabilities() const override {
return BEATSCAP_TRANSLATE | BEATSCAP_SCALE | BEATSCAP_SETBPM;
return BEATSCAP_SETBPM;
}

QByteArray toByteArray() const override;
Expand Down
3 changes: 1 addition & 2 deletions src/track/beatmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class BeatMap final : public Beats {
const QVector<mixxx::audio::FramePos>& beats);

Beats::CapabilitiesFlags getCapabilities() const override {
return BEATSCAP_TRANSLATE | BEATSCAP_SCALE | BEATSCAP_ADDREMOVE |
BEATSCAP_MOVEBEAT;
return BEATSCAP_NONE;
}

QByteArray toByteArray() const override;
Expand Down
18 changes: 4 additions & 14 deletions src/track/beats.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ class Beats {
virtual ~Beats() = default;

enum Capabilities {
BEATSCAP_NONE = 0x0000,
/// Add or remove a single beat
BEATSCAP_ADDREMOVE = 0x0001,
/// Move all beat markers earlier or later
BEATSCAP_TRANSLATE = 0x0002,
/// Scale beat distance by a fixed ratio
BEATSCAP_SCALE = 0x0004,
/// Move a single Beat
BEATSCAP_MOVEBEAT = 0x0008,
BEATSCAP_NONE = 0,
/// Set new bpm, beat grid only
BEATSCAP_SETBPM = 0x0010
BEATSCAP_SETBPM = 1
};
/// Allows us to do ORing
typedef int CapabilitiesFlags;
Expand Down Expand Up @@ -153,12 +145,10 @@ class Beats {

/// Translate all beats in the song by `offset` frames. Beats that lie
/// before the start of the track or after the end of the track are *not*
/// removed. The `Beats` instance must have the capability
/// `BEATSCAP_TRANSLATE`.
/// removed.
virtual BeatsPointer translate(audio::FrameDiff_t offset) const = 0;

/// Scale the position of every beat in the song by `scale`. The `Beats`
/// class must have the capability `BEATSCAP_SCALE`.
/// Scale the position of every beat in the song by `scale`.
virtual BeatsPointer scale(BpmScale scale) const = 0;

/// Adjust the beats so the global average BPM matches `bpm`. The `Beats`
Expand Down