Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.4' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Aug 17, 2023
2 parents f58dede + 7b1239f commit b9df1ff
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 39 deletions.
22 changes: 13 additions & 9 deletions src/analyzer/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ 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(const AnalyzerTrack& tio,
virtual bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT totalSamples) = 0;
SINT frameLength) = 0;

// Analyze the next chunk of audio samples and return true if successful.
// If processing fails the analysis can be aborted early by returning
// false. After aborting the analysis only cleanup() will be invoked,
// but not finalize()!
virtual bool processSamples(const CSAMPLE* pIn, SINT iLen) = 0;
virtual bool processSamples(const CSAMPLE* pIn, SINT count) = 0;

// Update the track object with the analysis results after
// processing finished successfully, i.e. all available audio
Expand Down Expand Up @@ -64,14 +66,16 @@ class AnalyzerWithState final {
return m_active;
}

bool initialize(TrackPointer pTrack, mixxx::audio::SampleRate sampleRate, SINT frameLength) {
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) {
DEBUG_ASSERT(!m_active);
return m_active = m_analyzer->initialize(pTrack, sampleRate, frameLength);
return m_active = m_analyzer->initialize(track, sampleRate, frameLength);
}

void processSamples(const CSAMPLE* pIn, SINT iLen) {
void processSamples(const CSAMPLE* pIn, const int count) {
if (m_active) {
m_active = m_analyzer->processSamples(pIn, iLen);
m_active = m_analyzer->processSamples(pIn, count);
if (!m_active) {
// Ensure that cleanup() is invoked after processing
// failed and the analyzer became inactive!
Expand All @@ -80,9 +84,9 @@ class AnalyzerWithState final {
}
}

void finish(const AnalyzerTrack& tio) {
void finish(const AnalyzerTrack& track) {
if (m_active) {
m_analyzer->storeResults(tio.getTrack());
m_analyzer->storeResults(track.getTrack());
m_analyzer->cleanup();
m_active = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ AnalyzerBeats::AnalyzerBeats(UserSettingsPointer pConfig, bool enforceBpmDetecti
bool AnalyzerBeats::initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) {
if (frameLength == 0) {
if (frameLength <= 0) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzerbeats.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AnalyzerBeats : public Analyzer {

bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT totalSamples) override;
SINT frameLength) override;
bool processSamples(const CSAMPLE* pIn, SINT count) override;
void storeResults(TrackPointer tio) override;
void cleanup() override;
Expand Down
5 changes: 3 additions & 2 deletions src/analyzer/analyzerebur128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ AnalyzerEbur128::~AnalyzerEbur128() {
cleanup(); // ...to prevent memory leaks
}

bool AnalyzerEbur128::initialize(const AnalyzerTrack& tio,
bool AnalyzerEbur128::initialize(
const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) {
if (m_rgSettings.isAnalyzerDisabled(2, tio.getTrack()) || frameLength <= 0) {
if (m_rgSettings.isAnalyzerDisabled(2, track.getTrack()) || frameLength <= 0) {
qDebug() << "Skipping AnalyzerEbur128";
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzergain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ AnalyzerGain::~AnalyzerGain() {
delete m_pReplayGain;
}

bool AnalyzerGain::initialize(const AnalyzerTrack& tio,
bool AnalyzerGain::initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) {
if (m_rgSettings.isAnalyzerDisabled(1, tio.getTrack()) || frameLength <= 0) {
if (m_rgSettings.isAnalyzerDisabled(1, track.getTrack()) || frameLength <= 0) {
qDebug() << "Skipping AnalyzerGain";
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions 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(const AnalyzerTrack& tio,
bool AnalyzerKey::initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) {
if (frameLength <= 0) {
Expand Down Expand Up @@ -87,7 +87,7 @@ bool AnalyzerKey::initialize(const AnalyzerTrack& tio,
m_currentFrame = 0;

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

DEBUG_ASSERT(!m_pPlugin);
if (bShouldAnalyze) {
Expand All @@ -104,7 +104,7 @@ bool AnalyzerKey::initialize(const AnalyzerTrack& tio,
}

if (m_pPlugin) {
if (m_pPlugin->initialize(m_sampleRate)) {
if (m_pPlugin->initialize(mixxx::audio::SampleRate(m_sampleRate))) {
qDebug() << "Key calculation started with plugin" << m_pluginId;
} else {
qDebug() << "Key calculation will not start.";
Expand All @@ -118,14 +118,14 @@ bool AnalyzerKey::initialize(const AnalyzerTrack& tio,
return bShouldAnalyze;
}

bool AnalyzerKey::shouldAnalyze(TrackPointer tio) const {
bool AnalyzerKey::shouldAnalyze(TrackPointer pTrack) const {
bool bPreferencesFastAnalysisEnabled = m_keySettings.getFastAnalysis();
QString pluginID = m_keySettings.getKeyPluginId();
if (pluginID.isEmpty()) {
pluginID = defaultPlugin().id();
}

const Keys keys = tio->getKeys();
const Keys keys = pTrack->getKeys();
if (keys.getGlobalKey() != mixxx::track::io::key::INVALID) {
QString version = keys.getVersion();
QString subVersion = keys.getSubVersion();
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(const AnalyzerTrack& tio,
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) override;
bool processSamples(const CSAMPLE* pIn, SINT count) override;
Expand Down
1 change: 0 additions & 1 deletion src/analyzer/analyzersilence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ bool AnalyzerSilence::processSamples(const CSAMPLE* pIn, SINT count) {
}

m_framesProcessed += count / mixxx::kAnalysisChannels;

return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/analyzer/analyzersilence.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class AnalyzerSilence : public Analyzer {
private:
UserSettingsPointer m_pConfig;
SINT m_framesProcessed;
bool m_bPrevSilence;
SINT m_signalStart;
SINT m_signalEnd;
};
2 changes: 1 addition & 1 deletion src/analyzer/analyzerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void AnalyzerThread::doRun() {
kLogger.debug() << "Analyzing" << m_currentTrack->getTrack()->getLocation();

// Get the audio
const auto audioSource =
const mixxx::AudioSourcePointer audioSource =
SoundSourceProxy(m_currentTrack->getTrack()).openAudioSource(openParams);
if (!audioSource) {
kLogger.warning()
Expand Down
8 changes: 4 additions & 4 deletions src/analyzer/analyzerwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ AnalyzerWaveform::~AnalyzerWaveform() {
destroyFilters();
}

bool AnalyzerWaveform::initialize(const AnalyzerTrack& tio,
bool AnalyzerWaveform::initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) {
if (frameLength <= 0) {
Expand All @@ -48,7 +48,7 @@ bool AnalyzerWaveform::initialize(const AnalyzerTrack& tio,
}

// If we don't need to calculate the waveform/wavesummary, skip.
if (!shouldAnalyze(tio.getTrack())) {
if (!shouldAnalyze(track.getTrack())) {
return false;
}

Expand All @@ -71,8 +71,8 @@ bool AnalyzerWaveform::initialize(const AnalyzerTrack& tio,
// Now, that the Waveform memory is initialized, we can set set them to
// the TIO. Be aware that other threads of Mixxx can touch them from
// now.
tio.getTrack()->setWaveform(m_waveform);
tio.getTrack()->setWaveformSummary(m_waveformSummary);
track.getTrack()->setWaveform(m_waveform);
track.getTrack()->setWaveformSummary(m_waveformSummary);

m_waveformData = m_waveform->data();
m_waveformSummaryData = m_waveformSummary->data();
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(const AnalyzerTrack& tio,
bool initialize(const AnalyzerTrack& track,
mixxx::audio::SampleRate sampleRate,
SINT frameLength) override;
bool processSamples(const CSAMPLE* buffer, SINT count) override;
Expand Down
2 changes: 2 additions & 0 deletions src/engine/bufferscalers/enginebufferscalerubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ double EngineBufferScaleRubberBand::scaleBuffer(
const SINT next_block_frames_required =
static_cast<SINT>(m_pRubberBand->getSamplesRequired());
if (remaining_frames > 0 && next_block_frames_required > 0) {
// The requested setting becomes effective after all previous frames have been processed
m_effectiveRate = m_dBaseRate * m_dTempoRatio;
const SINT available_samples = m_pReadAheadManager->getNextSamples(
// The value doesn't matter here. All that matters is we
// are going forward or backward.
Expand Down
7 changes: 6 additions & 1 deletion src/library/parsercsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ QList<QString> ParserCsv::parseAllLocations(const QString& playlistFile) {
}
file.close();
}

qDebug() << "ParserCsv::parse() failed"
<< playlistFile
<< file.errorString();

return locations;
}

Expand Down Expand Up @@ -228,7 +233,7 @@ bool ParserCsv::writeReadableTextFile(const QString &file_str, BaseSqlTableModel
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr,
QObject::tr("Readable text Export Failed"),
QObject::tr("Could not create file") + " " + file_str + +"\n" + file.errorString());
QObject::tr("Could not create file") + " " + file_str + "\n" + file.errorString());
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions src/library/parserpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ QList<QString> ParserPls::parseAllLocations(const QString& playlistFile) {

file.close();
}

qDebug() << "ParserPls::parse() failed"
<< playlistFile
<< file.errorString();

return locations;
}

Expand Down
18 changes: 9 additions & 9 deletions src/track/keyutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ namespace {
// instead do what QRegularExpression::anchoredPattern by wrapping each regex in \\A(?: ... )\\z

// OpenKey notation, the numbers 1-12 followed by d (dur, major) or m (moll, minor).
static const QRegularExpression s_openKeyRegex(QStringLiteral(
const QRegularExpression s_openKeyRegex(QStringLiteral(
"\\A(?:^\\s*(1[0-2]|[1-9])([dm])\\s*$)\\z"));

// Lancelot notation, the numbers 1-12 followed by a (minor) or b (major).
static const QRegularExpression s_lancelotKeyRegex(
QStringLiteral("\\A(?:^\\s*0*(1[0-2]|[1-9])([ABILMDPC])\\s*$)\\z"),
QRegularExpression::CaseInsensitiveOption);
// Lancelot notation, the numbers 1-12 followed by A (minor) or B(I) (major).
// or "I", "L", "M", "D", "P", "C" for the advanced modes
const QRegularExpression s_lancelotKeyRegex(
QStringLiteral("\\A(?:^\\s*0*(1[0-2]|[1-9])([ABILMDPC])\\s*$)\\z"));
constexpr std::string_view s_lancelotMajorModes = "BILM";

// a-g followed by any number of sharps or flats, optionally followed by
// a scale mode spec (m = minor, min, maj ..)
// Note: ## = x exists: https://jadebultitude.com/double-sharp-sign-in-music
static const QRegularExpression s_keyRegex(QString::fromUtf8(
"\\A(?:^\\s*([a-g])([#♯b♭]*) *"
"([a-z]{3}.*|m)?\\s*$)\\z"),
const QRegularExpression s_keyRegex(
QString::fromUtf8(
"\\A(?:^\\s*([a-g])([#♯b♭]*) *([a-z]{3}.*|m)?\\s*$)\\z"),
QRegularExpression::CaseInsensitiveOption);

const QString s_sharpSymbol = QString::fromUtf8("");
Expand Down Expand Up @@ -360,7 +360,7 @@ ChromaticKey KeyUtils::guessKeyFromText(const QString& text) {
}

bool major = openKeyMatch.captured(2)
.compare("d", Qt::CaseInsensitive) == 0;
.compare("d") == 0;

return openKeyNumberToKey(openKeyNumber, major);
}
Expand Down

0 comments on commit b9df1ff

Please sign in to comment.