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

Ironing beats #3626

Merged
merged 27 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b211849
Added function calculateIronedGrid() to BeatUtils
daschuer Feb 4, 2021
c812a50
Introduce a new kMaxSecsPhaseErrorSum to avoid to use a constant area…
daschuer Feb 6, 2021
b6cfa32
Return constant regions instead of single beats
daschuer Feb 11, 2021
6615d49
Added makeConstBpm() and roundBpmWithinRange()
daschuer Feb 11, 2021
409b47c
Added adjustPhase() and getBeats()
daschuer Feb 11, 2021
e248465
Make use of the new rounding functions.
daschuer Feb 11, 2021
1abce54
Remove now unused functions
daschuer Feb 11, 2021
1eca938
Dispose now unused EnableOffsetCorrection and MinBpm and MaxBpm.
daschuer Feb 11, 2021
41d3aa0
Bump rounding version to "V2"
daschuer Feb 11, 2021
6f5edd6
use mixxx::audio::SampleRate type
daschuer Feb 11, 2021
c7118d4
Make use of new rounding functions in calculateBpm()
daschuer Feb 11, 2021
fa29425
Fix CheckBox ReanalyseImported
daschuer Feb 12, 2021
455a83a
Use american spelling for analyze
daschuer Feb 12, 2021
63d2b89
silence debug
daschuer Feb 12, 2021
8cb656a
rename fixedTempo flag to fixedTempo
daschuer Feb 12, 2021
84fdd34
Re-added lost final beat in beats maps
daschuer Feb 13, 2021
784b898
Verify that the regionBorderError is not too big
daschuer Feb 15, 2021
bd7a4f4
Fix offset correction.
daschuer Feb 15, 2021
1acde69
Fix sign when calculation the sample positions from beats
daschuer Feb 15, 2021
dd6cc40
Merge remote-tracking branch 'upstream/2.3' into ironbeats
daschuer Feb 28, 2021
58fffd2
Merge remote-tracking branch 'upstream/2.3' into ironbeats
daschuer Mar 5, 2021
2f4d89e
Merge remote-tracking branch 'upstream/2.3' into ironbeats
daschuer Mar 14, 2021
63d91ed
Make some local variables const
daschuer Mar 14, 2021
c1b4e14
fix typo
daschuer Mar 14, 2021
0e6dda6
replace 1/2 with 0.5
daschuer Mar 14, 2021
b3b7689
use double literals
daschuer Mar 14, 2021
384c0cb
fix shadowing issue
daschuer Mar 14, 2021
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
26 changes: 3 additions & 23 deletions src/analyzer/analyzerbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@ AnalyzerBeats::AnalyzerBeats(UserSettingsPointer pConfig, bool enforceBpmDetecti
m_bPreferencesReanalyzeOldBpm(false),
m_bPreferencesReanalyzeImported(false),
m_bPreferencesFixedTempo(true),
m_bPreferencesOffsetCorrection(false),
m_bPreferencesFastAnalysis(false),
m_totalSamples(0),
m_iMaxSamplesToProcess(0),
m_iCurrentSample(0),
m_iMinBpm(0),
m_iMaxBpm(9999) {
m_iCurrentSample(0) {
}

bool AnalyzerBeats::initialize(TrackPointer pTrack, int sampleRate, int totalSamples) {
Expand All @@ -63,11 +60,7 @@ bool AnalyzerBeats::initialize(TrackPointer pTrack, int sampleRate, int totalSam
return false;
}

m_iMinBpm = m_bpmSettings.getBpmRangeStart();
m_iMaxBpm = m_bpmSettings.getBpmRangeEnd();

m_bPreferencesFixedTempo = m_bpmSettings.getFixedTempoAssumption();
m_bPreferencesOffsetCorrection = m_bpmSettings.getFixedTempoOffsetCorrection();
m_bPreferencesReanalyzeOldBpm = m_bpmSettings.getReanalyzeWhenSettingsChange();
m_bPreferencesReanalyzeImported = m_bpmSettings.getReanalyzeImported();
m_bPreferencesFastAnalysis = m_bpmSettings.getFastAnalysis();
Expand All @@ -86,9 +79,7 @@ bool AnalyzerBeats::initialize(TrackPointer pTrack, int sampleRate, int totalSam

qDebug() << "AnalyzerBeats preference settings:"
<< "\nPlugin:" << m_pluginId
<< "\nMin/Max BPM:" << m_iMinBpm << m_iMaxBpm
<< "\nFixed tempo assumption:" << m_bPreferencesFixedTempo
<< "\nOffset correction:" << m_bPreferencesOffsetCorrection
<< "\nRe-analyze when settings change:" << m_bPreferencesReanalyzeOldBpm
<< "\nFast analysis:" << m_bPreferencesFastAnalysis;

Expand Down Expand Up @@ -135,9 +126,6 @@ bool AnalyzerBeats::initialize(TrackPointer pTrack, int sampleRate, int totalSam
}

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

bool bpmLock = pTrack->isBpmLocked();
if (bpmLock) {
qDebug() << "Track is BpmLocked: Beat calculation will not start";
Expand Down Expand Up @@ -182,12 +170,8 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer pTrack) const {
pluginID,
m_bPreferencesFastAnalysis);
QString newVersion = BeatFactory::getPreferredVersion(
m_bPreferencesOffsetCorrection);
m_bPreferencesFixedTempo);
QString newSubVersion = BeatFactory::getPreferredSubVersion(
m_bPreferencesFixedTempo,
m_bPreferencesOffsetCorrection,
iMinBpm,
iMaxBpm,
extraVersionInfo);

if (version == newVersion && subVersion == newSubVersion) {
Expand Down Expand Up @@ -242,11 +226,7 @@ void AnalyzerBeats::storeResults(TrackPointer pTrack) {
beats,
extraVersionInfo,
m_bPreferencesFixedTempo,
m_bPreferencesOffsetCorrection,
m_sampleRate,
m_totalSamples,
m_iMinBpm,
m_iMaxBpm);
m_sampleRate);
qDebug() << "AnalyzerBeats plugin detected" << beats.size()
<< "beats. Average BPM:" << (pBeats ? pBeats->getBpm() : 0.0);
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/analyzer/analyzerbeats.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ class AnalyzerBeats : public Analyzer {
bool m_bPreferencesReanalyzeOldBpm;
bool m_bPreferencesReanalyzeImported;
bool m_bPreferencesFixedTempo;
bool m_bPreferencesOffsetCorrection;
bool m_bPreferencesFastAnalysis;

mixxx::audio::SampleRate m_sampleRate;
SINT m_totalSamples;
int m_iMaxSamplesToProcess;
int m_iCurrentSample;
int m_iMinBpm, m_iMaxBpm;
};
4 changes: 3 additions & 1 deletion src/analyzer/plugins/analyzerqueenmarybeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ bool AnalyzerQueenMaryBeats::finalize() {

m_resultBeats.reserve(static_cast<int>(beats.size()));
for (size_t i = 0; i < beats.size(); ++i) {
double result = (beats.at(i) * m_stepSize) - m_stepSize / 2;
// we add the halve m_stepSize here, because the beat
// is detected between the two samples.
double result = (beats.at(i) * m_stepSize) + m_stepSize / 2;
m_resultBeats.push_back(result);
}

Expand Down
11 changes: 0 additions & 11 deletions src/preferences/beatdetectionsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,20 @@
// BPM_CONFIG_KEY Preferences
#define BPM_DETECTION_ENABLED "BPMDetectionEnabled"
#define BPM_FIXED_TEMPO_ASSUMPTION "BeatDetectionFixedTempoAssumption"
#define BPM_FIXED_TEMPO_OFFSET_CORRECTION "FixedTempoOffsetCorrection"
#define BPM_REANALYZE_WHEN_SETTINGS_CHANGE "ReanalyzeWhenSettingsChange"
#define BPM_REANALYZE_IMPORTED "ReanalyzeImported"
#define BPM_FAST_ANALYSIS_ENABLED "FastAnalysisEnabled"

#define BPM_RANGE_START "BPMRangeStart"
#define BPM_RANGE_END "BPMRangeEnd"

class BeatDetectionSettings {
public:
BeatDetectionSettings(UserSettingsPointer pConfig) : m_pConfig(pConfig) {}

DEFINE_PREFERENCE_HELPERS(BpmDetectionEnabled, bool,
BPM_CONFIG_KEY, BPM_DETECTION_ENABLED, true);

DEFINE_PREFERENCE_HELPERS(BpmRangeStart, int, BPM_CONFIG_KEY, BPM_RANGE_START, 70);

DEFINE_PREFERENCE_HELPERS(BpmRangeEnd, int, BPM_CONFIG_KEY, BPM_RANGE_END, 140);

DEFINE_PREFERENCE_HELPERS(FixedTempoAssumption, bool,
BPM_CONFIG_KEY, BPM_FIXED_TEMPO_ASSUMPTION, true);

DEFINE_PREFERENCE_HELPERS(FixedTempoOffsetCorrection, bool,
BPM_CONFIG_KEY, BPM_FIXED_TEMPO_OFFSET_CORRECTION, true);

DEFINE_PREFERENCE_HELPERS(ReanalyzeWhenSettingsChange, bool,
BPM_CONFIG_KEY, BPM_REANALYZE_WHEN_SETTINGS_CHANGE, false);

Expand Down
61 changes: 7 additions & 54 deletions src/preferences/dialog/dlgprefbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
DlgPrefBeats::DlgPrefBeats(QWidget* parent, UserSettingsPointer pConfig)
: DlgPreferencePage(parent),
m_bpmSettings(pConfig),
m_minBpm(m_bpmSettings.getBpmRangeStartDefault()),
m_maxBpm(m_bpmSettings.getBpmRangeEndDefault()),
m_bAnalyzerEnabled(m_bpmSettings.getBpmDetectionEnabledDefault()),
m_bFixedTempoEnabled(m_bpmSettings.getFixedTempoAssumptionDefault()),
m_bOffsetEnabled(m_bpmSettings.getFixedTempoOffsetCorrectionDefault()),
m_bFastAnalysisEnabled(m_bpmSettings.getFastAnalysisDefault()),
m_bReanalyze(m_bpmSettings.getReanalyzeWhenSettingsChangeDefault()),
m_bReanalyzeImported(m_bpmSettings.getReanalyzeImportedDefault()) {
Expand All @@ -38,27 +35,15 @@ DlgPrefBeats::DlgPrefBeats(QWidget* parent, UserSettingsPointer pConfig)
&QCheckBox::stateChanged,
this,
&DlgPrefBeats::fixedtempoEnabled);
connect(checkBoxOffsetCorr,
&QCheckBox::stateChanged,
this,
&DlgPrefBeats::offsetEnabled);
connect(checkBoxFastAnalysis,
&QCheckBox::stateChanged,
this,
&DlgPrefBeats::fastAnalysisEnabled);
connect(txtMinBpm,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefBeats::minBpmRangeChanged);
connect(txtMaxBpm,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefBeats::maxBpmRangeChanged);
connect(checkBoxReanalyse,
connect(checkBoxReanalyze,
&QCheckBox::stateChanged,
this,
&DlgPrefBeats::slotReanalyzeChanged);
connect(checkBoxReanalyseImported,
connect(checkBoxReanalyzeImported,
&QCheckBox::stateChanged,
this,
&DlgPrefBeats::slotReanalyzeImportedChanged);
Expand All @@ -75,14 +60,9 @@ void DlgPrefBeats::loadSettings() {
m_selectedAnalyzerId = m_bpmSettings.getBeatPluginId();
m_bAnalyzerEnabled = m_bpmSettings.getBpmDetectionEnabled();
m_bFixedTempoEnabled = m_bpmSettings.getFixedTempoAssumption();
m_bOffsetEnabled = m_bpmSettings.getFixedTempoOffsetCorrection();
m_bReanalyze = m_bpmSettings.getReanalyzeWhenSettingsChange();
m_bFastAnalysisEnabled = m_bpmSettings.getFastAnalysis();

// TODO(rryan): Above range enabled is not exposed?
m_minBpm = m_bpmSettings.getBpmRangeStart();
m_maxBpm = m_bpmSettings.getBpmRangeEnd();

slotUpdate();
}

Expand All @@ -92,12 +72,9 @@ void DlgPrefBeats::slotResetToDefaults() {
}
m_bAnalyzerEnabled = m_bpmSettings.getBpmDetectionEnabledDefault();
m_bFixedTempoEnabled = m_bpmSettings.getFixedTempoAssumptionDefault();
m_bOffsetEnabled = m_bpmSettings.getFixedTempoOffsetCorrectionDefault();
m_bFastAnalysisEnabled = m_bpmSettings.getFastAnalysisDefault();
m_bReanalyze = m_bpmSettings.getReanalyzeWhenSettingsChangeDefault();
// TODO(rryan): Above range enabled is not exposed?
m_minBpm = m_bpmSettings.getBpmRangeStartDefault();
m_maxBpm = m_bpmSettings.getBpmRangeEndDefault();

slotUpdate();
}

Expand All @@ -119,32 +96,14 @@ void DlgPrefBeats::fixedtempoEnabled(int i) {
slotUpdate();
}

void DlgPrefBeats::offsetEnabled(int i) {
m_bOffsetEnabled = static_cast<bool>(i);
slotUpdate();
}

void DlgPrefBeats::minBpmRangeChanged(int value) {
m_minBpm = value;
slotUpdate();
}

void DlgPrefBeats::maxBpmRangeChanged(int value) {
m_maxBpm = value;
slotUpdate();
}

void DlgPrefBeats::slotUpdate() {
checkBoxFixedTempo->setEnabled(m_bAnalyzerEnabled);
checkBoxOffsetCorr->setEnabled((m_bAnalyzerEnabled && m_bFixedTempoEnabled));
comboBoxBeatPlugin->setEnabled(m_bAnalyzerEnabled);
checkBoxAnalyzerEnabled->setChecked(m_bAnalyzerEnabled);
// Fast analysis cannot be combined with non-constant tempo beatgrids.
checkBoxFastAnalysis->setEnabled(m_bAnalyzerEnabled && m_bFixedTempoEnabled);
txtMaxBpm->setEnabled(m_bAnalyzerEnabled && m_bFixedTempoEnabled);
txtMinBpm->setEnabled(m_bAnalyzerEnabled && m_bFixedTempoEnabled);
checkBoxReanalyse->setEnabled(m_bAnalyzerEnabled);
checkBoxReanalyseImported->setEnabled(m_bReanalyzeImported);
checkBoxReanalyze->setEnabled(m_bAnalyzerEnabled);
checkBoxReanalyzeImported->setEnabled(m_bAnalyzerEnabled);

if (!m_bAnalyzerEnabled) {
return;
Expand All @@ -159,7 +118,6 @@ void DlgPrefBeats::slotUpdate() {
comboBoxBeatPlugin->setCurrentIndex(i);
if (!m_availablePlugins[i].constantTempoSupported) {
checkBoxFixedTempo->setEnabled(false);
checkBoxOffsetCorr->setEnabled(false);
}
break;
}
Expand All @@ -171,13 +129,11 @@ void DlgPrefBeats::slotUpdate() {
}

checkBoxFixedTempo->setChecked(m_bFixedTempoEnabled);
checkBoxOffsetCorr->setChecked(m_bOffsetEnabled);
// Fast analysis cannot be combined with non-constant tempo beatgrids.
checkBoxFastAnalysis->setChecked(m_bFastAnalysisEnabled && m_bFixedTempoEnabled);

txtMaxBpm->setValue(m_maxBpm);
txtMinBpm->setValue(m_minBpm);
checkBoxReanalyse->setChecked(m_bReanalyze);
checkBoxReanalyze->setChecked(m_bReanalyze);
checkBoxReanalyzeImported->setChecked(m_bReanalyzeImported);
}

void DlgPrefBeats::slotReanalyzeChanged(int value) {
Expand All @@ -199,10 +155,7 @@ void DlgPrefBeats::slotApply() {
m_bpmSettings.setBeatPluginId(m_selectedAnalyzerId);
m_bpmSettings.setBpmDetectionEnabled(m_bAnalyzerEnabled);
m_bpmSettings.setFixedTempoAssumption(m_bFixedTempoEnabled);
m_bpmSettings.setFixedTempoOffsetCorrection(m_bOffsetEnabled);
m_bpmSettings.setReanalyzeWhenSettingsChange(m_bReanalyze);
m_bpmSettings.setReanalyzeImported(m_bReanalyzeImported);
m_bpmSettings.setFastAnalysis(m_bFastAnalysisEnabled);
m_bpmSettings.setBpmRangeStart(m_minBpm);
m_bpmSettings.setBpmRangeEnd(m_maxBpm);
}
6 changes: 0 additions & 6 deletions src/preferences/dialog/dlgprefbeats.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ class DlgPrefBeats : public DlgPreferencePage, public Ui::DlgBeatsDlg {
void pluginSelected(int i);
void analyzerEnabled(int i);
void fixedtempoEnabled(int i);
void offsetEnabled(int i);
void fastAnalysisEnabled(int i);
void minBpmRangeChanged(int value);
void maxBpmRangeChanged(int value);
void slotReanalyzeChanged(int value);
void slotReanalyzeImportedChanged(int value);

Expand All @@ -41,11 +38,8 @@ class DlgPrefBeats : public DlgPreferencePage, public Ui::DlgBeatsDlg {
BeatDetectionSettings m_bpmSettings;
QList<mixxx::AnalyzerPluginInfo> m_availablePlugins;
QString m_selectedAnalyzerId;
int m_minBpm;
int m_maxBpm;
bool m_bAnalyzerEnabled;
bool m_bFixedTempoEnabled;
bool m_bOffsetEnabled;
bool m_bFastAnalysisEnabled;
bool m_bReanalyze;
bool m_bReanalyzeImported;
Expand Down
Loading