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

Analysis: Add support for overriding variable/constant BPM on a per-track basis #10931

Merged
merged 11 commits into from
Oct 5, 2022
Prev Previous commit
Next Next commit
AnalyzerTrack: Pass it by const reference
...to make clazy happy!
  • Loading branch information
fwcd committed Oct 4, 2022
commit 163cee65795d4b71b85167a0c8f65b9da2535b55
8 changes: 5 additions & 3 deletions src/analyzer/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Analyzer {
// 1. Check if the track needs to be analyzed, otherwise return false.
// 2. Perform the initialization and return true on success.
// 3. If the initialization failed log the internal error and return false.
virtual bool initialize(AnalyzerTrack tio,
virtual bool initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) = 0;

Expand Down Expand Up @@ -70,7 +70,9 @@ class AnalyzerWithState final {
return m_active;
}

bool initialize(AnalyzerTrack tio, mixxx::audio::SampleRate sampleRate, int totalSamples) {
bool initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
DEBUG_ASSERT(!m_active);
return m_active = m_analyzer->initialize(tio, sampleRate, totalSamples);
}
Expand All @@ -86,7 +88,7 @@ class AnalyzerWithState final {
}
}

void finish(AnalyzerTrack tio) {
void finish(const AnalyzerTrack& tio) {
if (m_active) {
m_analyzer->storeResults(tio.getTrack());
m_analyzer->cleanup();
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AnalyzerBeats::AnalyzerBeats(UserSettingsPointer pConfig, bool enforceBpmDetecti
m_iCurrentSample(0) {
}

bool AnalyzerBeats::initialize(AnalyzerTrack track,
bool AnalyzerBeats::initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
if (totalSamples == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerbeats.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AnalyzerBeats : public Analyzer {
static QList<mixxx::AnalyzerPluginInfo> availablePlugins();
static mixxx::AnalyzerPluginInfo defaultPlugin();

bool initialize(AnalyzerTrack track,
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
int totalSamples) override;
bool processSamples(const CSAMPLE *pIn, const int iLen) override;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerebur128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AnalyzerEbur128::~AnalyzerEbur128() {
cleanup(); // ...to prevent memory leaks
}

bool AnalyzerEbur128::initialize(AnalyzerTrack tio,
bool AnalyzerEbur128::initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
if (m_rgSettings.isAnalyzerDisabled(2, tio.getTrack()) || totalSamples == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerebur128.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AnalyzerEbur128 : public Analyzer {
return rgSettings.isAnalyzerEnabled(2);
}

bool initialize(AnalyzerTrack track,
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
int totalSamples) override;
bool processSamples(const CSAMPLE* pIn, const int iLen) override;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzergain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AnalyzerGain::~AnalyzerGain() {
delete m_pReplayGain;
}

bool AnalyzerGain::initialize(AnalyzerTrack tio,
bool AnalyzerGain::initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
if (m_rgSettings.isAnalyzerDisabled(1, tio.getTrack()) || totalSamples == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzergain.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AnalyzerGain : public Analyzer {
return rgSettings.isAnalyzerEnabled(1);
}

bool initialize(AnalyzerTrack track,
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
int totalSamples) override;
bool processSamples(const CSAMPLE* pIn, const int iLen) override;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AnalyzerKey::AnalyzerKey(const KeyDetectionSettings& keySettings)
m_bPreferencesReanalyzeEnabled(false) {
}

bool AnalyzerKey::initialize(AnalyzerTrack tio,
bool AnalyzerKey::initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
if (totalSamples == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AnalyzerKey : public Analyzer {
static QList<mixxx::AnalyzerPluginInfo> availablePlugins();
static mixxx::AnalyzerPluginInfo defaultPlugin();

bool initialize(AnalyzerTrack tio,
bool initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) override;
bool processSamples(const CSAMPLE *pIn, const int iLen) override;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzersilence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AnalyzerSilence::AnalyzerSilence(UserSettingsPointer pConfig)
m_iSignalEnd(-1) {
}

bool AnalyzerSilence::initialize(AnalyzerTrack track,
bool AnalyzerSilence::initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
Q_UNUSED(sampleRate);
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzersilence.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AnalyzerSilence : public Analyzer {
explicit AnalyzerSilence(UserSettingsPointer pConfig);
~AnalyzerSilence() override = default;

bool initialize(AnalyzerTrack track,
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
int totalSamples) override;
bool processSamples(const CSAMPLE* pIn, const int iLen) override;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void AnalyzerThread::doRun() {
emitProgress(AnalyzerThreadState::Exit);
}

bool AnalyzerThread::submitNextTrack(AnalyzerTrack nextTrack) {
bool AnalyzerThread::submitNextTrack(const AnalyzerTrack& nextTrack) {
DEBUG_ASSERT(nextTrack.getTrack());
fwcd marked this conversation as resolved.
Show resolved Hide resolved
kLogger.debug()
<< "Enqueueing next track"
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AnalyzerThread : public WorkerThread {
// with state Idle has been received to avoid overwriting
// a previously sent track that has not been received by the
// worker thread, yet.
bool submitNextTrack(AnalyzerTrack nextTrack);
bool submitNextTrack(const AnalyzerTrack& nextTrack);

signals:
// Use a single signal for progress updates to ensure that all signals
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AnalyzerWaveform::~AnalyzerWaveform() {
destroyFilters();
}

bool AnalyzerWaveform::initialize(AnalyzerTrack tio,
bool AnalyzerWaveform::initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) {
if (totalSamples == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AnalyzerWaveform : public Analyzer {
const QSqlDatabase& dbConnection);
~AnalyzerWaveform() override;

bool initialize(AnalyzerTrack tio,
bool initialize(const AnalyzerTrack& tio,
mixxx::audio::SampleRate sampleRate,
int totalSamples) override;
bool processSamples(const CSAMPLE* buffer, const int bufferLength) override;
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/trackanalysisscheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TrackAnalysisScheduler : public QObject {
return m_analyzerProgress;
}

bool submitNextTrack(AnalyzerTrack track) {
bool submitNextTrack(const AnalyzerTrack& track) {
DEBUG_ASSERT(m_thread);
return m_thread->submitNextTrack(std::move(track));
}
Expand Down