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

[WIP] Remove beatmap and beatgrid #2861

Closed
wants to merge 162 commits into from
Closed
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
148e216
Improvement in proto for beats blob
JaviVilarroig Aug 21, 2019
39a90b4
Added Signature class for storing track time signature information
JaviVilarroig Nov 20, 2019
dc8fbe7
Added Signature class
JaviVilarroig Dec 9, 2019
9ee4695
Added Beats::getSignature
JaviVilarroig Dec 16, 2019
05a4720
Merge branch 'bars_phrases_and_variable_BPM_in_beats_class' of https:…
JaviVilarroig Dec 17, 2019
2d38e75
Fix repo
JaviVilarroig Dec 17, 2019
c1428f0
Merge remote-tracking branch 'upstream/master' into bars_phrases_and_…
JaviVilarroig Dec 19, 2019
590be5d
Added Signature manipulation to BeatGrid.
JaviVilarroig Jan 13, 2020
b2c9eca
BeatGrid/BeatMap Signature support
JaviVilarroig Jan 16, 2020
0084ddc
Removed forgotten qDebug unneeded trace
JaviVilarroig Jan 16, 2020
c8b8ae4
- Added button in Tango skin for setting bar beat
JaviVilarroig Feb 17, 2020
fa68e2d
Presentaion of Bar beats in Waveform for BeatMap.
JaviVilarroig Feb 22, 2020
87cc607
Merge remote-tracking branch 'upstream/master' into bars_phrases_and_…
JaviVilarroig Feb 22, 2020
01583e8
Adds null_signature and default_signature constants.
JaviVilarroig Feb 25, 2020
b533ac4
Rename Signature to TimeSignature in protobuff and wrapper class.
JaviVilarroig Feb 25, 2020
72e030a
Fixes in TimeSignature class.
JaviVilarroig Feb 26, 2020
9d652ca
Protect naked pointers in BpmControl.
JaviVilarroig Feb 28, 2020
91c9930
BeatMap::SetBar to use the real Signature of the track to calculate the
JaviVilarroig Feb 28, 2020
df0f083
Fix issue with set bar button nor properly reacting to press an hover.
JaviVilarroig Mar 4, 2020
26b358f
Multiple small fixes on Beats. Added default value to TimeSignature
JaviVilarroig Mar 5, 2020
f97cd1e
BeatGrid removal and BeatMap consolidation into Beats
JaviVilarroig Apr 19, 2020
48ec71b
Forgoten update on cmake list for previous commit
JaviVilarroig Apr 19, 2020
1b4a0d8
Merge commit 'f1e13f93ad35dc1de34a6e8741f369cbb95bc71e' into bars_phr…
daschuer Jun 13, 2020
769e922
Improve variable names for Track pointers.
JaviVilarroig Apr 21, 2020
3647af9
Improve variable names for Track pointers (2)
JaviVilarroig Apr 21, 2020
fcdc116
Document Beats class for Doxygen
JaviVilarroig Apr 21, 2020
4c54b7c
Fix if's without closing brackets.
JaviVilarroig Apr 21, 2020
dccf044
Ads operator<< to Beats and cleanup of misc malformed make_shared
JaviVilarroig Apr 22, 2020
331ef5a
Improvements in Timesignature
JaviVilarroig Apr 22, 2020
0a7baad
Use mixxx::kEngineChannelCount for consistency
JaviVilarroig Apr 22, 2020
04d89ea
Rename Beats::setBar to Beats::setDownBeat
JaviVilarroig Apr 22, 2020
800adf6
Rename Beats::setBar to Beats::setDownBeat and some adpaters
JaviVilarroig Apr 22, 2020
a7cf0d0
Remove ascii art from Beats header
JaviVilarroig Apr 22, 2020
865caf5
Replace BeatsPointer constructor by make_shared
JaviVilarroig Apr 22, 2020
730abaa
Adapt comment to clang-format
JaviVilarroig Apr 22, 2020
7f857a6
Fix BeatsFactory method signatures to use references.
JaviVilarroig Apr 22, 2020
9f1039d
Remove anonymous namespace from beats.h
JaviVilarroig Apr 22, 2020
b3ecb4e
Remove spurious property from Beats
JaviVilarroig Apr 22, 2020
1485e8a
Fixes in BeatIterator
JaviVilarroig May 4, 2020
58dbf80
Waveformrenderbeat to interact with beats using frames
JaviVilarroig May 5, 2020
49e3d09
pre-commit configuration taken from master
JaviVilarroig May 6, 2020
c628235
Small general fixes in BeatFactory.
JaviVilarroig May 6, 2020
1b90cc3
Comments added to const_cas in BeatIterator
JaviVilarroig May 7, 2020
3512947
Change name of method toByteArray to toProtobuff
JaviVilarroig May 7, 2020
20cd34c
Fix in indentation
JaviVilarroig May 7, 2020
d663f04
Add comments to clearly mark temporary methods
JaviVilarroig May 7, 2020
cbdba12
BeatTrtanslateTest is now OK.
JaviVilarroig May 10, 2020
22d6d19
Beats to use Bpm type
JaviVilarroig May 21, 2020
f81f1fd
Merge commit '18e6e1ed60af1fc9a39bda7302f48743085d8844' into bars_phr…
daschuer Jun 14, 2020
b7c8f7b
Fix segfault during tests
daschuer Jun 14, 2020
dde8b8f
fix some tests
daschuer Jun 14, 2020
85c85f5
Use double precision for beat positions
daschuer Jun 14, 2020
10715cd
Beats: Fix build
uklotzde Jun 13, 2020
0ef78f3
Fix dependency ordering issues
uklotzde Jun 15, 2020
03afb56
beats.proto: rename beats to beats_per_bar
hacksdump Jun 12, 2020
f432e59
beats.h: make class final
hacksdump Jun 13, 2020
0dc057d
beats.h: remove version names from macros
hacksdump Jun 13, 2020
51fdd42
remove adapter for calculateBpm
hacksdump Jun 13, 2020
0f8009b
remove adapter for setGrid
hacksdump Jun 13, 2020
2a4bffb
add frame class to avoid sample/frame ambiguity
hacksdump Jun 13, 2020
56e9051
use single f in protobuf
hacksdump Jun 13, 2020
8e6625a
remove all adapters from main source
hacksdump Jun 15, 2020
ec62228
adapt tests to frame class
hacksdump Jun 16, 2020
91eb3d8
remove residual beats subclasses and corresponding tests
hacksdump Jun 16, 2020
f9fd333
add channel count to beatstest
hacksdump Jun 16, 2020
9b962d7
frame: add multiply and divide operations
hacksdump Jun 16, 2020
480f7f7
beats: use Frame vector in constructor
hacksdump Jun 16, 2020
65a0d84
beatfactory: write adapter to store beatgrid in beats
hacksdump Jun 16, 2020
a49ebe0
beatfactory: use common serialized data for all beatgrid version
hacksdump Jun 16, 2020
3e4664e
beats: remove unused code | rename proto
hacksdump Jun 16, 2020
a7b6d01
beats: remove unused function getMaxBpm
hacksdump Jun 16, 2020
919e1b9
beats: remove extraneous helper functions
hacksdump Jun 16, 2020
84d689c
beats: remove derivable state variable
hacksdump Jun 16, 2020
fe7fd32
beats: remove capability flags
hacksdump Jun 17, 2020
8957a08
beats:doc: describe source of data in constructor
hacksdump Jun 18, 2020
e6b0383
beats: remove optional sample rate parameter
hacksdump Jun 18, 2020
b156cd5
bpm: remove redundant parantheses
hacksdump Jun 18, 2020
e67686f
Merge branch 'ambigous-sample-rate' into remove-beatmap-beatgrid
hacksdump Jun 18, 2020
eab8bb0
beats: simplify bpm scale function
hacksdump Jun 18, 2020
43acd8f
timesignature: modify getters setters
hacksdump Jun 18, 2020
df01cce
beats: remove test logic from main source
hacksdump Jun 18, 2020
bff9917
fix typo
hacksdump Jun 18, 2020
754ecfe
beatutils: don't use framerate for audio
hacksdump Jun 18, 2020
4b515f2
beats: use double instead of rounding
hacksdump Jun 18, 2020
a1dc778
beats: define iterator
hacksdump Jun 18, 2020
e32a19c
timesignature: move symmetrical operations outside class
hacksdump Jun 18, 2020
454ba2c
remove redundant copying of member variable
hacksdump Jun 18, 2020
7eb655c
timesignature: use protobuf object to store signature
hacksdump Jun 19, 2020
9c981fb
beats: enable setBpm for all Beat detection modes
hacksdump Jun 20, 2020
4329021
frame: replace forward declaration with include
hacksdump Jun 20, 2020
1356ccb
frame.h refactor: use FramePos and FrameDiff_t
hacksdump Jun 21, 2020
9e04891
beats: update outdated constructor documentation
hacksdump Jun 21, 2020
43e16c1
bpmcontrol: use parented pointers
hacksdump Jun 21, 2020
f46860f
bpmcontrol: use unique pointers
hacksdump Jun 21, 2020
ea4447a
beatiterator: pointer comparison and exclude end
hacksdump Jun 21, 2020
33b6a4f
change control name
hacksdump Jun 21, 2020
79ecd2a
bpm: pass trivially copyable types by value
hacksdump Jun 21, 2020
c013576
bpm:use double for multiple and divide operations
hacksdump Jun 21, 2020
0576be8
beatiterator: remove destructor
hacksdump Jun 21, 2020
cbc7977
beats.proto: make fields required
hacksdump Jun 21, 2020
d255364
beatutils: remove unnecessary const
hacksdump Jun 21, 2020
397b338
beatutils: remove rounding for frame sample conversion
hacksdump Jun 21, 2020
a0ff6d9
beats: use correct range while returning iterator
hacksdump Jun 21, 2020
cf75244
beatstest: fix time signature test
hacksdump Jun 21, 2020
074a921
beatstest: remove redundant state variable
hacksdump Jun 21, 2020
136060b
waveformrenderbeat: enable beat pen
hacksdump Jun 21, 2020
86b834a
beatstest: fix NthBeatWhenNotOnBeat
hacksdump Jun 21, 2020
cab96a2
track: remove obsolete comments and debug info
hacksdump Jun 22, 2020
be68912
bpmcontrol_test: fix BeatContext_BeatGrid
hacksdump Jun 22, 2020
a9707f8
beatstest: fix BpmAround
hacksdump Jun 24, 2020
33bf4c9
searchqueryparsertest: fuzzy comparison to fix tests
hacksdump Jun 24, 2020
34c35d7
bpm: pass qstring by reference
hacksdump Jun 24, 2020
fe266d0
beats: cleaner debug output
hacksdump Jun 25, 2020
4d8f2f2
engine: use inline functions for frame conversion
hacksdump Jun 25, 2020
0534db3
remove unnecessary frame quantization
hacksdump Jun 25, 2020
915a671
beats: rename method
hacksdump Jun 25, 2020
ca4425a
beats: remove copy to self
hacksdump Jun 25, 2020
540c749
engine: update function to use FramePos instead of samples
hacksdump Jun 25, 2020
c00da80
engine: refactor to use FramePos instead of sample
hacksdump Jun 26, 2020
5f0ce46
beats: don't delete beats on translate
hacksdump Jun 26, 2020
fa86f2a
frame: use constant for invalid frame instead of -1
hacksdump Jun 26, 2020
38555e0
beatstranslatetest: fix SimpleTranslateMatch
hacksdump Jun 26, 2020
7f89649
frame: use C++ style limits
hacksdump Jun 26, 2020
68a1949
use inline functions for sample frame conversion
hacksdump Jun 28, 2020
c19d2f2
fix wrong assignment to beats
hacksdump Jun 29, 2020
55d7784
loopingcontrol: use inline functions for sample frame conversion
hacksdump Jun 29, 2020
1fff80c
Merge branch 'master' into remove-beatmap-beatgrid
hacksdump Jun 29, 2020
4f28348
loopingcontroltest: beat size within track duration
hacksdump Jun 30, 2020
8506d0b
use correct epsilon for finding nearby beat
hacksdump Jun 30, 2020
71bf183
fix enginesynctest failing due to typo
hacksdump Jun 30, 2020
3933e76
fix searchqueryparser test by reducing double precision
hacksdump Jun 30, 2020
85e75c9
remove unused functions
hacksdump Jul 1, 2020
425c7fd
remove unnecesary debug function
hacksdump Jul 2, 2020
2ca2be4
searchquery: improve comment on precision downgrading
hacksdump Jul 2, 2020
0710437
beats: use namespaced constants
hacksdump Jul 2, 2020
006cd74
factor out frame sample adapter functions
hacksdump Jul 2, 2020
cd80c28
loopingcontol: replace wrong variable
hacksdump Jul 2, 2020
bcd32c1
move frameadapter to util
hacksdump Jul 2, 2020
a7a7edd
use frameadapter in track
hacksdump Jul 2, 2020
6268b30
fix scons build
hacksdump Jul 2, 2020
b2a9bcf
frameadapter: change comment
hacksdump Jul 2, 2020
792c682
beats: temporary dirty workaround for copy constructor
hacksdump Jul 2, 2020
8452657
beatsproto: make all fields optional
hacksdump Jul 2, 2020
8134eae
create new internal beats class independent of QObject
hacksdump Jul 7, 2020
a60beee
simplify copy constructor
hacksdump Jul 7, 2020
9a08d05
beats: move findNthBeat to plain class
hacksdump Jul 7, 2020
13538d3
beats: move more code to plain class
hacksdump Jul 7, 2020
0a5fba3
beats: move scale functions to plain class
hacksdump Jul 8, 2020
274c9fa
beats: move all implementation to plain class
hacksdump Jul 8, 2020
49686eb
beats: use function to calculate beat length
hacksdump Jul 11, 2020
eb3b6c9
beats: add back old protobuf types for backwards compatibility
hacksdump Jul 12, 2020
d3b7a5a
beats: add version to distinguish from earlier versions
hacksdump Jul 13, 2020
79f5b2a
beats: add migration code
hacksdump Jul 14, 2020
6a52cab
merge from master and resolve conflicts
hacksdump Jul 14, 2020
abf9694
update comments
hacksdump Jul 14, 2020
7302922
revert all UI changes
hacksdump Jul 14, 2020
77c8d82
use beat indices as marker basis
hacksdump Jul 16, 2020
1e2565a
change section message
hacksdump Jul 16, 2020
cc0d8ef
remove redundant ctor initializer
hacksdump Jul 16, 2020
de26dd4
remove legacy name from comment
hacksdump Jul 16, 2020
e76bfc3
add debug asserts
hacksdump Jul 16, 2020
1967c0f
add placeholder parameters
hacksdump Jul 16, 2020
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
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/sources/soundsourcesndfile.cpp
src/track/albuminfo.cpp
src/track/beatfactory.cpp
src/track/beatgrid.cpp
src/track/beatmap.cpp
src/track/beats.cpp
src/track/beatutils.cpp
src/track/bpm.cpp
Expand Down Expand Up @@ -1197,8 +1195,7 @@ add_executable(mixxx-test
src/test/audiotaperpot_test.cpp
src/test/autodjprocessor_test.cpp
src/test/baseeffecttest.cpp
src/test/beatgridtest.cpp
src/test/beatmaptest.cpp
src/test/beatstest.cpp
src/test/beatstranslatetest.cpp
src/test/bpmcontrol_test.cpp
src/test/broadcastprofile_test.cpp
Expand Down
2 changes: 0 additions & 2 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,6 @@ def sources(self, build):
"src/skin/launchimage.cpp",

"src/track/beatfactory.cpp",
"src/track/beatgrid.cpp",
"src/track/beatmap.cpp",
"src/track/beatutils.cpp",
"src/track/beats.cpp",
"src/track/bpm.cpp",
Expand Down
7 changes: 6 additions & 1 deletion res/skins/Tango/buttons/btn_beats_curpos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions res/skins/Tango/buttons/btn_beats_set_bar_beat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions res/skins/Tango/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ WWidgetGroup {
#BeatgridFaster,
#BeatgridEarlier,
#BeatgridLater,
#BeatgridSetBarBeat,
#HotcuesEarlier,
#HotcuesLater {
background-color: #333;
Expand All @@ -467,13 +468,17 @@ WWidgetGroup {
#BeatgridFaster:hover,
#BeatgridEarlier:hover,
#BeatgridLater:hover,
#BeatgridSetBarBeat:hover,
#HotcuesEarlier:hover,
#HotcuesLater:hover {
background-color: #0f0f0f;
}
#BeatgridCurpos {
image: url(skin:/buttons/btn_beats_curpos.svg) no-repeat center center;
}
#BeatgridSetBarBeat {
image: url(skin:/buttons/btn_beats_set_bar_beat.svg) no-repeat center center;
}
#BeatgridSlower {
image: url(skin:/buttons/btn_beats_slower.svg) no-repeat center center;
}
Expand Down
23 changes: 23 additions & 0 deletions res/skins/Tango/waveform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Variables:
<SignalRGBMidColor><Variable name="SignalRGBMidColor"/></SignalRGBMidColor>
<SignalRGBHighColor><Variable name="SignalRGBHighColor"/></SignalRGBHighColor>
<BeatColor>#ffffff</BeatColor>
<BarColor>#ffff00</BarColor>
<PlayPosColor>#FF4300</PlayPosColor>
<EndOfTrackColor><Variable name="EndOfTrackColor"/></EndOfTrackColor>
<DefaultMark>
Expand Down Expand Up @@ -161,6 +162,28 @@ Variables:
</Connection>
</WidgetGroup>

<WidgetGroup><!-- Set Bar and Phrase beat -->
<Layout>vertical</Layout>
<SizePolicy>f,f</SizePolicy>
<Children>
<Template src="skin:button_1state.xml">
<SetVariable name="TooltipId">beats_set_downbeat</SetVariable>
<SetVariable name="ObjectName">BeatgridSetBarBeat</SetVariable>
<SetVariable name="Size">28f,24f</SetVariable>
<SetVariable name="ConfigKey"><Variable name="group"/>,beats_set_downbeat</SetVariable>
</Template>

<WidgetGroup><Size>1min,1f</Size></WidgetGroup>

<Template src="skin:button_1state.xml">
<SetVariable name="TooltipId">beats_adjust_faster</SetVariable>
<SetVariable name="ObjectName">BeatgridFaster</SetVariable>
<SetVariable name="Size">28f,24f</SetVariable>
<SetVariable name="ConfigKey"><Variable name="group"/>,beats_adjust_faster</SetVariable>
</Template>
</Children>
</WidgetGroup><!-- Set Bar and Phrase beat -->

<WidgetGroup>
<Layout>vertical</Layout>
<SizePolicy>f,f</SizePolicy>
Expand Down
54 changes: 27 additions & 27 deletions src/analyzer/analyzerbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "analyzer/plugins/analyzerqueenmarybeats.h"
#include "analyzer/plugins/analyzersoundtouchbeats.h"
#include "track/beatfactory.h"
#include "track/beatmap.h"
#include "track/beats.h"
#include "track/beatutils.h"
#include "track/track.h"

Expand Down Expand Up @@ -43,7 +43,7 @@ AnalyzerBeats::AnalyzerBeats(UserSettingsPointer pConfig, bool enforceBpmDetecti
m_iMaxBpm(9999) {
}

bool AnalyzerBeats::initialize(TrackPointer tio, int sampleRate, int totalSamples) {
bool AnalyzerBeats::initialize(TrackPointer pTrack, int sampleRate, int totalSamples) {
if (totalSamples == 0) {
return false;
}
Expand All @@ -55,7 +55,7 @@ bool AnalyzerBeats::initialize(TrackPointer tio, int sampleRate, int totalSample
return false;
}

bool bpmLock = tio->isBpmLocked();
bool bpmLock = pTrack->isBpmLocked();
if (bpmLock) {
qDebug() << "Track is BpmLocked: Beat calculation will not start";
return false;
Expand Down Expand Up @@ -101,8 +101,7 @@ bool AnalyzerBeats::initialize(TrackPointer tio, int sampleRate, int totalSample
m_iCurrentSample = 0;

// if we can load a stored track don't reanalyze it
bool bShouldAnalyze = shouldAnalyze(tio);

bool bShouldAnalyze = shouldAnalyze(pTrack);

DEBUG_ASSERT(!m_pPlugin);
if (bShouldAnalyze) {
Expand Down Expand Up @@ -131,11 +130,11 @@ bool AnalyzerBeats::initialize(TrackPointer tio, int sampleRate, int totalSample
return bShouldAnalyze;
}

bool AnalyzerBeats::shouldAnalyze(TrackPointer tio) const {
bool AnalyzerBeats::shouldAnalyze(TrackPointer pTrack) const {
int iMinBpm = m_bpmSettings.getBpmRangeStart();
int iMaxBpm = m_bpmSettings.getBpmRangeEnd();

bool bpmLock = tio->isBpmLocked();
bool bpmLock = pTrack->isBpmLocked();
if (bpmLock) {
qDebug() << "Track is BpmLocked: Beat calculation will not start";
return false;
Expand All @@ -148,11 +147,11 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer tio) const {

// If the track already has a Beats object then we need to decide whether to
// analyze this track or not.
mixxx::BeatsPointer pBeats = tio->getBeats();
mixxx::BeatsPointer pBeats = pTrack->getBeats();
if (!pBeats) {
return true;
}
if (!mixxx::Bpm::isValidValue(pBeats->getBpm())) {
if (!mixxx::Bpm::isValidValue(pBeats->getBpm().getValue())) {
// Tracks with an invalid bpm <= 0 should be re-analyzed,
// independent of the preference settings. We expect that
// all tracks have a bpm > 0 when analyzed. Users that want
Expand All @@ -161,7 +160,7 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer tio) const {
qDebug() << "Re-analyzing track with invalid BPM despite preference settings.";
return true;
}
if (pBeats->findNextBeat(0) <= 0.0) {
if (pBeats->findNextBeat(mixxx::FramePos(0)) <= mixxx::FramePos(0.0)) {
qDebug() << "First beat is 0 for grid so analyzing track to find first beat.";
return true;
}
Expand All @@ -188,8 +187,8 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer tio) const {
// Beat grid exists but version and settings differ
if (!m_bPreferencesReanalyzeOldBpm) {
qDebug() << "Beat calculation skips analyzing because the track has"
<< "a BPM computed by a previous Mixxx version and user"
<< "preferences indicate we should not change it.";
<< "a BPM computed by a previous Mixxx version and user"
<< "preferences indicate we should not change it.";
return false;
}

Expand All @@ -213,7 +212,7 @@ void AnalyzerBeats::cleanup() {
m_pPlugin.reset();
}

void AnalyzerBeats::storeResults(TrackPointer tio) {
void AnalyzerBeats::storeResults(TrackPointer pTrack) {
VERIFY_OR_DEBUG_ASSERT(m_pPlugin) {
return;
}
Expand All @@ -229,57 +228,58 @@ void AnalyzerBeats::storeResults(TrackPointer tio) {
QHash<QString, QString> extraVersionInfo = getExtraVersionInfo(
m_pluginId, m_bPreferencesFastAnalysis);
pBeats = BeatFactory::makePreferredBeats(
*tio,
pTrack,
beats,
extraVersionInfo,
m_bPreferencesFixedTempo,
m_bPreferencesOffsetCorrection,
m_iSampleRate,
m_iTotalSamples,
m_iMinBpm,
m_iMaxBpm);
qDebug() << "AnalyzerBeats plugin detected" << beats.size()
<< "beats. Average BPM:" << (pBeats ? pBeats->getBpm() : 0.0);
<< "beats. Average BPM:" << (pBeats ? pBeats->getBpm().getValue() : 0.0);
} else {
float bpm = m_pPlugin->getBpm();
mixxx::Bpm bpm = mixxx::Bpm(m_pPlugin->getBpm());
qDebug() << "AnalyzerBeats plugin detected constant BPM: " << bpm;
pBeats = BeatFactory::makeBeatGrid(*tio, bpm, 0.0f);
pBeats = std::make_shared<mixxx::Beats>(pTrack.get());
pBeats->setGrid(bpm);
pTrack->setBeats(pBeats);
}

mixxx::BeatsPointer pCurrentBeats = tio->getBeats();
mixxx::BeatsPointer pCurrentBeats = pTrack->getBeats();

// If the track has no beats object then set our newly generated one
// regardless of beat lock.
if (!pCurrentBeats) {
tio->setBeats(pBeats);
pTrack->setBeats(pBeats);
return;
}

// If the track received the beat lock while we were analyzing it then we
// abort setting it.
if (tio->isBpmLocked()) {
if (pTrack->isBpmLocked()) {
qDebug() << "Track was BPM-locked as we were analyzing it. Aborting analysis.";
return;
}

// If the user prefers to replace old beatgrids with newly generated ones or
// the old beatgrid has 0-bpm then we replace it.
bool zeroCurrentBpm = pCurrentBeats->getBpm() == 0.0;
bool zeroCurrentBpm = pCurrentBeats->getBpm().getValue() == 0.0;
if (m_bPreferencesReanalyzeOldBpm || zeroCurrentBpm) {
if (zeroCurrentBpm) {
qDebug() << "Replacing 0-BPM beatgrid with a" << pBeats->getBpm()
<< "beatgrid.";
}
tio->setBeats(pBeats);
pTrack->setBeats(pBeats);
return;
}

// If we got here then the user doesn't want to replace the beatgrid but
// since the first beat is zero we'll apply the offset we just detected.
double currentFirstBeat = pCurrentBeats->findNextBeat(0);
double newFirstBeat = pBeats->findNextBeat(0);
if (currentFirstBeat == 0.0 && newFirstBeat > 0) {
pCurrentBeats->translate(newFirstBeat);
mixxx::FramePos currentFirstBeat = pCurrentBeats->findNextBeat(mixxx::FramePos(0));
mixxx::FramePos newFirstBeat = pBeats->findNextBeat(mixxx::FramePos(0));
if (currentFirstBeat == mixxx::FramePos(0.0) && newFirstBeat > mixxx::FramePos(0)) {
pCurrentBeats->translate(newFirstBeat - currentFirstBeat);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/analyzer/analyzerbeats.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class AnalyzerBeats : public Analyzer {
static QList<mixxx::AnalyzerPluginInfo> availablePlugins();
static mixxx::AnalyzerPluginInfo defaultPlugin();

bool initialize(TrackPointer tio, int sampleRate, int totalSamples) override;
bool initialize(TrackPointer pTrack, int sampleRate, int totalSamples) override;
bool processSamples(const CSAMPLE *pIn, const int iLen) override;
void storeResults(TrackPointer tio) override;
void storeResults(TrackPointer pTrack) override;
void cleanup() override;

private:
bool shouldAnalyze(TrackPointer tio) const;
bool shouldAnalyze(TrackPointer pTrack) const;
static QHash<QString, QString> getExtraVersionInfo(
QString pluginId, bool bPreferencesFastAnalysis);

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
addDeckControl("beats_translate_match_alignment", tr("Adjust Beatgrid - Match Alignment"),
tr("Adjust beatgrid to match another playing deck."), bpmMenu);
addDeckAndSamplerControl("quantize", tr("Quantize Mode"), tr("Toggle quantize mode"), bpmMenu);
addDeckAndSamplerControl("beats_set_downbeat",
tr("Set Downbeat"),
tr("Make the current beat a Downbeat"),
bpmMenu);

QMenu* syncMenu = addSubmenu(tr("Sync"));
addDeckAndSamplerControl("sync_enabled", tr("Sync Mode"),
Expand Down
Loading