summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2021-03-11 14:40:00 +0100
committerDaniel Schürmann <daschuer@mixxx.org>2021-03-11 14:40:00 +0100
commitde69d924ebf2a7356927a2202992cd1fafb054ed (patch)
tree5121eebc50458bd0d5888642f4ba6d0a5ac02141 /src
parent4f473a8c2a163d4e00b0bc9db5843fe468df6ded (diff)
parente24906fce042365a5bbdba2ad1bd84b323f8c20f (diff)
Merge remote-tracking branch 'upstream/2.3' into no_grid_from_bpm
Diffstat (limited to 'src')
-rw-r--r--src/analyzer/analyzerbeats.cpp17
-rw-r--r--src/analyzer/analyzerbeats.h4
-rw-r--r--src/library/dao/trackdao.cpp2
-rw-r--r--src/library/dlgtrackinfo.cpp13
-rw-r--r--src/library/mixxxlibraryfeature.cpp2
-rw-r--r--src/library/rekordbox/rekordboxfeature.cpp6
-rw-r--r--src/preferences/dialog/dlgpreflibrary.cpp6
-rw-r--r--src/preferences/dialog/dlgpreflibrarydlg.ui62
-rw-r--r--src/sources/soundsourcemediafoundation.cpp43
-rw-r--r--src/test/beatmaptest.cpp19
-rw-r--r--src/test/enginesynctest.cpp8
-rw-r--r--src/track/beatfactory.cpp43
-rw-r--r--src/track/beatfactory.h26
-rw-r--r--src/track/beatgrid.cpp25
-rw-r--r--src/track/beatgrid.h15
-rw-r--r--src/track/beatmap.cpp29
-rw-r--r--src/track/beatmap.h15
-rw-r--r--src/track/beats.h9
-rw-r--r--src/track/beatutils.cpp38
-rw-r--r--src/track/beatutils.h33
-rw-r--r--src/track/track.cpp4
-rw-r--r--src/track/track.h2
22 files changed, 234 insertions, 187 deletions
diff --git a/src/analyzer/analyzerbeats.cpp b/src/analyzer/analyzerbeats.cpp
index 0f0bf17e72..7d9339c9c9 100644
--- a/src/analyzer/analyzerbeats.cpp
+++ b/src/analyzer/analyzerbeats.cpp
@@ -38,8 +38,7 @@ AnalyzerBeats::AnalyzerBeats(UserSettingsPointer pConfig, bool enforceBpmDetecti
m_bPreferencesFixedTempo(true),
m_bPreferencesOffsetCorrection(false),
m_bPreferencesFastAnalysis(false),
- m_iSampleRate(0),
- m_iTotalSamples(0),
+ m_totalSamples(0),
m_iMaxSamplesToProcess(0),
m_iCurrentSample(0),
m_iMinBpm(0),
@@ -93,15 +92,15 @@ bool AnalyzerBeats::initialize(TrackPointer pTrack, int sampleRate, int totalSam
<< "\nRe-analyze when settings change:" << m_bPreferencesReanalyzeOldBpm
<< "\nFast analysis:" << m_bPreferencesFastAnalysis;
- m_iSampleRate = sampleRate;
- m_iTotalSamples = totalSamples;
+ m_sampleRate = sampleRate;
+ m_totalSamples = totalSamples;
// In fast analysis mode, skip processing after
// kFastAnalysisSecondsToAnalyze seconds are analyzed.
if (m_bPreferencesFastAnalysis) {
m_iMaxSamplesToProcess =
- mixxx::kFastAnalysisSecondsToAnalyze * m_iSampleRate * mixxx::kAnalysisChannels;
+ mixxx::kFastAnalysisSecondsToAnalyze * m_sampleRate * mixxx::kAnalysisChannels;
} else {
- m_iMaxSamplesToProcess = m_iTotalSamples;
+ m_iMaxSamplesToProcess = m_totalSamples;
}
m_iCurrentSample = 0;
@@ -244,8 +243,8 @@ void AnalyzerBeats::storeResults(TrackPointer pTrack) {
extraVersionInfo,
m_bPreferencesFixedTempo,
m_bPreferencesOffsetCorrection,
- m_iSampleRate,
- m_iTotalSamples,
+ m_sampleRate,
+ m_totalSamples,
m_iMinBpm,
m_iMaxBpm);
qDebug() << "AnalyzerBeats plugin detected" << beats.size()
@@ -253,7 +252,7 @@ void AnalyzerBeats::storeResults(TrackPointer pTrack) {
} else {
float bpm = m_pPlugin->getBpm();
qDebug() << "AnalyzerBeats plugin detected constant BPM: " << bpm;
- pBeats = BeatFactory::makeBeatGrid(m_iSampleRate, bpm, 0.0f);
+ pBeats = BeatFactory::makeBeatGrid(m_sampleRate, bpm, 0.0f);
}
pTrack->trySetBeats(pBeats);
diff --git a/src/analyzer/analyzerbeats.h b/src/analyzer/analyzerbeats.h
index 4efb2f3075..af9568477a 100644
--- a/src/analyzer/analyzerbeats.h
+++ b/src/analyzer/analyzerbeats.h
@@ -46,8 +46,8 @@ class AnalyzerBeats : public Analyzer {
bool m_bPreferencesOffsetCorrection;
bool m_bPreferencesFastAnalysis;
- int m_iSampleRate;
- int m_iTotalSamples;
+ mixxx::audio::SampleRate m_sampleRate;
+ SINT m_totalSamples;
int m_iMaxSamplesToProcess;
int m_iCurrentSample;
int m_iMinBpm, m_iMaxBpm;
diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp
index 0528825a1e..5dab5700fe 100644
--- a/src/library/dao/trackdao.cpp
+++ b/src/library/dao/trackdao.cpp
@@ -441,7 +441,7 @@ namespace {
pTrackLibraryQuery->bindValue(":replaygain_peak", track.getReplayGain().getPeak());
pTrackLibraryQuery->bindValue(":channels", track.getChannels());
- pTrackLibraryQuery->bindValue(":samplerate", track.getSampleRate());
+ pTrackLibraryQuery->bindValue(":samplerate", static_cast<int>(track.getSampleRate()));
pTrackLibraryQuery->bindValue(":bitrate", track.getBitrate());
pTrackLibraryQuery->bindValue(":duration", track.getDuration());
diff --git a/src/library/dlgtrackinfo.cpp b/src/library/dlgtrackinfo.cpp
index eb77924aaf..424fadbafb 100644
--- a/src/library/dlgtrackinfo.cpp
+++ b/src/library/dlgtrackinfo.cpp
@@ -268,15 +268,14 @@ void DlgTrackInfo::populateFields(const Track& track) {
}
void DlgTrackInfo::reloadTrackBeats(const Track& track) {
- const mixxx::BeatsPointer pBeats = track.getBeats();
- if (pBeats) {
- spinBpm->setValue(pBeats->getBpm());
- m_pBeatsClone = pBeats->clone();
+ m_pBeatsClone = track.getBeats();
+ if (m_pBeatsClone) {
+ spinBpm->setValue(m_pBeatsClone->getBpm());
} else {
- m_pBeatsClone.clear();
spinBpm->setValue(0.0);
}
- m_trackHasBeatMap = pBeats && !(pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_SETBPM);
+ m_trackHasBeatMap = m_pBeatsClone &&
+ !(m_pBeatsClone->getCapabilities() & mixxx::Beats::BEATSCAP_SETBPM);
bpmConst->setChecked(!m_trackHasBeatMap);
bpmConst->setEnabled(m_trackHasBeatMap); // We cannot make turn a BeatGrid to a BeatMap
spinBpm->setEnabled(!m_trackHasBeatMap); // We cannot change bpm continuously or tab them
@@ -569,7 +568,7 @@ void DlgTrackInfo::slotSpinBpmValueChanged(double value) {
}
if (m_pBeatsClone->getCapabilities() & mixxx::Beats::BEATSCAP_SETBPM) {
- m_pBeatsClone->setBpm(value);
+ m_pBeatsClone = m_pBeatsClone->setBpm(value);
}
// read back the actual value
diff --git a/src/library/mixxxlibraryfeature.cpp b/src/library/mixxxlibraryfeature.cpp
index 33ea90143c..d0119c734b 100644
--- a/src/library/mixxxlibraryfeature.cpp
+++ b/src/library/mixxxlibraryfeature.cpp
@@ -24,6 +24,7 @@ namespace {
const QStringList DEFAULT_COLUMNS = {
LIBRARYTABLE_ID,
+ LIBRARYTABLE_COLOR,
LIBRARYTABLE_PLAYED,
LIBRARYTABLE_TIMESPLAYED,
//has to be up here otherwise Played and TimesPlayed are not shown
@@ -50,7 +51,6 @@ const QStringList DEFAULT_COLUMNS = {
TRACKLOCATIONSTABLE_FSDELETED,
LIBRARYTABLE_COMMENT,
LIBRARYTABLE_MIXXXDELETED,
- LIBRARYTABLE_COLOR,
LIBRARYTABLE_COVERART_SOURCE,
LIBRARYTABLE_COVERART_TYPE,
LIBRARYTABLE_COVERART_LOCATION,
diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp
index f9bd652170..d5f4bb0302 100644
--- a/src/library/rekordbox/rekordboxfeature.cpp
+++ b/src/library/rekordbox/rekordboxfeature.cpp
@@ -825,7 +825,7 @@ void setHotCue(TrackPointer track,
}
void readAnalyze(TrackPointer track,
- double sampleRate,
+ mixxx::audio::SampleRate sampleRate,
int timingOffset,
bool ignoreCues,
const QString& anlzPath) {
@@ -867,7 +867,7 @@ void readAnalyze(TrackPointer track,
}
const auto pBeats = mixxx::BeatMap::makeBeatMap(
- static_cast<SINT>(sampleRate),
+ sampleRate,
mixxx::rekordboxconstants::beatsSubversion,
beats);
track->trySetBeats(pBeats);
@@ -1187,7 +1187,7 @@ TrackPointer RekordboxPlaylistModel::getTrack(const QModelIndex& index) const {
}
#endif
- double sampleRate = static_cast<double>(track->getSampleRate());
+ mixxx::audio::SampleRate sampleRate = track->getSampleRate();
QString anlzPath = index.sibling(index.row(), fieldIndex("analyze_path")).data().toString();
QString anlzPathExt = anlzPath.left(anlzPath.length() - 3) + "EXT";
diff --git a/src/preferences/dialog/dlgpreflibrary.cpp b/src/preferences/dialog/dlgpreflibrary.cpp
index 8c9bebdc9a..bdca756b77 100644
--- a/src/preferences/dialog/dlgpreflibrary.cpp
+++ b/src/preferences/dialog/dlgpreflibrary.cpp
@@ -56,6 +56,12 @@ DlgPrefLibrary::DlgPrefLibrary(
&QPushButton::clicked,
this,
&DlgPrefLibrary::slotRelocateDir);
+ const QString& settingsDir = m_pConfig->getSettingsPath();
+ connect(PushButtonOpenSettingsDir,
+ &QPushButton::clicked,
+ [settingsDir] {
+ QDesktopServices::openUrl(QUrl::fromLocalFile(settingsDir));
+ });
// Set default direction as stored in config file
int rowHeight = m_pLibrary->getTrackTableRowHeight();
diff --git a/src/preferences/dialog/dlgpreflibrarydlg.ui b/src/preferences/dialog/dlgpreflibrarydlg.ui
index 25d0a4c701..6b2f0f1a95 100644
--- a/src/preferences/dialog/dlgpreflibrarydlg.ui
+++ b/src/preferences/dialog/dlgpreflibrarydlg.ui
@@ -14,6 +14,7 @@
<string notr="true">Library Preferences</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+
<item>
<widget class="QGroupBox" name="groupBoxLibrary">
<property name="title">
@@ -100,6 +101,7 @@
</layout>
</widget>
</item>
+
<item>
<widget class="QGroupBox" name="groupBox_AudioFileFormats">
<property name="title">
@@ -122,6 +124,7 @@
</layout>
</widget>
</item>
+
<item>
<widget class="QGroupBox" name="groupBox_AudioFileTags">
<property name="title">
@@ -138,6 +141,7 @@
</layout>
</widget>
</item>
+
<item>
<widget class="QGroupBox" name="groupBox_Miscellaneous">
<property name="title">
@@ -238,6 +242,7 @@
</layout>
</widget>
</item>
+
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="toolTip">
@@ -281,6 +286,7 @@
</layout>
</widget>
</item>
+
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
@@ -348,20 +354,16 @@
</widget>
</item>
<item row="6" column="0">
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>All external libraries shown are write protected.</string>
</property>
+ <property name="topMargin">
+ <number>10</number>
+ </property>
</widget>
</item>
- <item row="8" column="0">
+ <item row="7" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>You will need to restart Mixxx for these settings to take effect.</string>
@@ -371,6 +373,49 @@
</layout>
</widget>
</item>
+
+ <item>
+ <widget class="QGroupBox" name="groupBox_settingsDir">
+ <property name="title">
+ <string>Settings Folder</string>
+ </property>
+ <layout class="QVBoxLayout" name="vlayout_settingsDir">
+ <item>
+ <widget class="QLabel" name="label_settingsDir">
+ <property name="text">
+ <string>The Mixxx settings folder contains the library database, various configuration files, log files, track analysis data, as well as custom controller mappings.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_settingsWarning">
+ <property name="text">
+ <string>Edit those files only if you know what you are doing and only while Mixxx is not running.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="PushButtonOpenSettingsDir">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Open Mixxx Settings Folder</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@@ -410,6 +455,7 @@
<tabstop>checkBox_show_traktor</tabstop>
<tabstop>checkBox_show_rekordbox</tabstop>
<tabstop>checkBox_show_serato</tabstop>
+ <tabstop>PushButtonOpenSettingsDir</tabstop>
</tabstops>
<resources/>
<connections/>
diff --git a/src/sources/soundsourcemediafoundation.cpp b/src/sources/soundsourcemediafoundation.cpp
index 74cfc5f643..5da31ba401 100644
--- a/src/sources/soundsourcemediafoundation.cpp
+++ b/src/sources/soundsourcemediafoundation.cpp
@@ -370,30 +370,31 @@ ReadableSampleFrames SoundSourceMediaFoundation::readSampleFramesClamped(
}
DEBUG_ASSERT(pSample != nullptr);
SINT readerFrameIndex = m_streamUnitConverter.toFrameIndex(streamPos);
+ // TODO: Fix debug assertion in else arm. It has been commented
+ // out deliberately to prevent crashes in debug builds.
+ // https://bugs.launchpad.net/mixxx/+bug/1899242
if (m_currentFrameIndex == kUnknownFrameIndex) {
// Unknown position after seeking
m_currentFrameIndex = readerFrameIndex;
- /*
- kLogger.debug()
- << "Stream position (in sample frames) after seeking:"
- << "target =" << writableSampleFrames.frameIndexRange().end()
- << "current =" << readerFrameIndex;
- */
- } else {
- // Both positions should match, otherwise readerFrameIndex
- // is inaccurate due to rounding errors after conversion from
- // stream units to frames! But if this ever happens we better
- // trust m_currentFrameIndex that is continuously updated while
- // reading in forward direction.
- VERIFY_OR_DEBUG_ASSERT(m_currentFrameIndex == readerFrameIndex) {
- kLogger.debug()
- << "streamPos [100 ns] =" << streamPos
- << ", sampleRate =" << getSignalInfo().getSampleRate();
- kLogger.warning()
- << "Stream position (in sample frames) while reading is inaccurate:"
- << "expected =" << m_currentFrameIndex
- << "actual =" << readerFrameIndex;
- }
+ // kLogger.debug()
+ // << "Stream position (in sample frames) after seeking:"
+ // << "target =" << writableSampleFrames.frameIndexRange().end()
+ // << "current =" << readerFrameIndex;
+ // } else {
+ // // Both positions should match, otherwise readerFrameIndex
+ // // is inaccurate due to rounding errors after conversion from
+ // // stream units to frames! But if this ever happens we better
+ // // trust m_currentFrameIndex that is continuously updated while
+ // // reading in forward direction.
+ // VERIFY_OR_DEBUG_ASSERT(m_currentFrameIndex == readerFrameIndex) {
+ // kLogger.debug()
+ // << "streamPos [100 ns] =" << streamPos
+ // << ", sampleRate =" << getSignalInfo().getSampleRate();
+ // kLogger.warning()
+ // << "Stream position (in sample frames) while reading is inaccurate:"
+ // << "expected =" << m_currentFrameIndex
+ // << "actual =" << readerFrameIndex;
+ // }
}
DWORD dwSampleBufferCount = 0;
diff --git a/src/test/beatmaptest.cpp b/src/test/beatmaptest.cpp
index bf246f9518..a6b7c22174 100644
--- a/src/test/beatmaptest.cpp
+++ b/src/test/beatmaptest.cpp
@@ -12,10 +12,9 @@ namespace {
class BeatMapTest : public testing::Test {
protected:
-
BeatMapTest()
: m_pTrack(Track::newTemporary()),
- m_iSampleRate(100),
+ m_iSampleRate(10000),
m_iFrameSize(2) {
m_pTrack->setAudioProperties(
mixxx::audio::ChannelCount(2),
@@ -279,15 +278,15 @@ TEST_F(BeatMapTest, TestBpmAround) {
// The average of the first 8 beats should be different than the average
// of the last 8 beats.
- EXPECT_DOUBLE_EQ(64.024390243902445,
- pMap->getBpmAroundPosition(4 * approx_beat_length, 4));
- EXPECT_DOUBLE_EQ(118.98016997167139,
- pMap->getBpmAroundPosition(60 * approx_beat_length, 4));
+ EXPECT_DOUBLE_EQ(63.937645572318047,
+ pMap->getBpmAroundPosition(4 * approx_beat_length, 4));
+ EXPECT_DOUBLE_EQ(118.96668932698844,
+ pMap->getBpmAroundPosition(60 * approx_beat_length, 4));
// Also test at the beginning and end of the track
- EXPECT_DOUBLE_EQ(62.968515742128936,
- pMap->getBpmAroundPosition(0, 4));
- EXPECT_DOUBLE_EQ(118.98016997167139,
- pMap->getBpmAroundPosition(65 * approx_beat_length, 4));
+ EXPECT_DOUBLE_EQ(62.937377309576974,
+ pMap->getBpmAroundPosition(0, 4));
+ EXPECT_DOUBLE_EQ(118.96668932698844,
+ pMap->getBpmAroundPosition(65 * approx_beat_length, 4));
// Try a really, really short track
beats = createBeatVector(10, 3, getBeatLengthFrames(filebpm));
diff --git a/src/test/enginesynctest.cpp b/src/test/enginesynctest.cpp
index 038393fb73..b34cafc1b2 100644
--- a/src/test/enginesynctest.cpp
+++ b/src/test/enginesynctest.cpp
@@ -2417,13 +2417,13 @@ TEST_F(EngineSyncTest, BeatMapQantizePlay) {
mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 120, 0.0);
m_pTrack1->trySetBeats(pBeats1);
- constexpr int kSampleRate = 44100;
+ constexpr auto kSampleRate = mixxx::audio::SampleRate(44100);
- auto pBeats2 = mixxx::BeatMap::makeBeatMap(
- kSampleRate,
+ auto pBeats2 = mixxx::BeatMap::makeBeatMap(kSampleRate,
QString(),
// Add two beats at 120 Bpm
- QVector<double>({kSampleRate / 2, kSampleRate}));
+ QVector<double>({static_cast<double>(kSampleRate) / 2,
+ static_cast<double>(kSampleRate)}));
m_pTrack2->trySetBeats(pBeats2);
ControlObject::set(ConfigKey(m_sGroup1, "quantize"), 1.0);
diff --git a/src/track/beatfactory.cpp b/src/track/beatfactory.cpp
index 2bf9c1e416..9929ff18fe 100644
--- a/src/track/beatfactory.cpp
+++ b/src/track/beatfactory.cpp
@@ -7,7 +7,7 @@
#include "track/beatutils.h"
mixxx::BeatsPointer BeatFactory::loadBeatsFromByteArray(
- SINT sampleRate,
+ mixxx::audio::SampleRate sampleRate,
const QString& beatsVersion,
const QString& beatsSubVersion,
const QByteArray& beatsSerialized) {
@@ -26,13 +26,15 @@ mixxx::BeatsPointer BeatFactory::loadBeatsFromByteArray(
}
mixxx::BeatsPointer BeatFactory::makeBeatGrid(
- SINT sampleRate, double dBpm, double dFirstBeatSample) {
+ mixxx::audio::SampleRate sampleRate,
+ double dBpm,
+ double dFirstBeatSample) {
return mixxx::BeatGrid::makeBeatGrid(sampleRate, QString(), dBpm, dFirstBeatSample);
}
// static
QString BeatFactory::getPreferredVersion(
- const bool bEnableFixedTempoCorrection) {
+ bool bEnableFixedTempoCorrection) {
if (bEnableFixedTempoCorrection) {
return BEAT_GRID_2_VERSION;
}
@@ -40,10 +42,10 @@ QString BeatFactory::getPreferredVersion(
}
QString BeatFactory::getPreferredSubVersion(
- const bool bEnableFixedTempoCorrection,
- const bool bEnableOffsetCorrection,
- const int iMinBpm,
- const int iMaxBpm,
+ bool bEnableFixedTempoCorrection,
+ bool bEnableOffsetCorrection,
+ int iMinBpm,
+ int iMaxBpm,
const QHash<QString, QString>& extraVersionInfo) {
const char* kSubVersionKeyValueSeparator = "=";
const char* kSubVersionFragmentSeparator = "|";
@@ -92,29 +94,32 @@ QString BeatFactory::getPreferredSubVersion(
mixxx::BeatsPointer BeatFactory::makePreferredBeats(
const QVector<double>& beats,
const QHash<QString, QString>& extraVersionInfo,
- const bool bEnableFixedTempoCorrection,
- const bool bEnableOffsetCorrection,
- const int iSampleRate,
- const int iTotalSamples,
- const int iMinBpm,
- const int iMaxBpm) {
+ bool bEnableFixedTempoCorrection,
+ bool bEnableOffsetCorrection,
+ mixxx::audio::SampleRate sampleRate,
+ SINT totalSamples,
+ int iMinBpm,
+ int iMaxBpm) {
const QString version = getPreferredVersion(bEnableFixedTempoCorrection);
const QString subVersion = getPreferredSubVersion(bEnableFixedTempoCorrection,
bEnableOffsetCorrection,
iMinBpm, iMaxBpm,
extraVersionInfo);
- BeatUtils::printBeatStatistics(beats, iSampleRate);
+ BeatUtils::printBeatStatistics(beats, sampleRate);
if (version == BEAT_GRID_2_VERSION) {
- double globalBpm = BeatUtils::calculateBpm(beats, iSampleRate, iMinBpm, iMaxBpm);
+ double globalBpm = BeatUtils::calculateBpm(beats, sampleRate, iMinBpm, iMaxBpm);
double firstBeat = BeatUtils::calculateFixedTempoFirstBeat(
- bEnableOffsetCorrection,
- beats, iSampleRate, iTotalSamples, globalBpm);
+ bEnableOffsetCorrection,
+ beats,
+ sampleRate,
+ totalSamples,
+ globalBpm);
auto pGrid = mixxx::BeatGrid::makeBeatGrid(
- iSampleRate, subVersion, globalBpm, firstBeat * 2);
+ sampleRate, subVersion, globalBpm, firstBeat * 2);
return pGrid;
} else if (version == BEAT_MAP_VERSION) {
- auto pBeatMap = mixxx::BeatMap::makeBeatMap(iSampleRate, subVersion, beats);
+ auto pBeatMap = mixxx::BeatMap::makeBeatMap(sampleRate, subVersion, beats);
return pBeatMap;
} else {
qDebug() << "ERROR: Could not determine what type of beatgrid to create.";
diff --git a/src/track/beatfactory.h b/src/track/beatfactory.h
index dda238bf4d..865dbeaaa0 100644
--- a/src/track/beatfactory.h
+++ b/src/track/beatfactory.h
@@ -9,31 +9,31 @@ class Track;
class BeatFactory {
public:
static mixxx::BeatsPointer loadBeatsFromByteArray(
- SINT sampleRat,
+ mixxx::audio::SampleRate sampleRate,
const QString& beatsVersion,
const QString& beatsSubVersion,
const QByteArray& beatsSerialized);
static mixxx::BeatsPointer makeBeatGrid(
- SINT sampleRat,
+ mixxx::audio::SampleRate sampleRate,
double dBpm,
double dFirstBeatSample);
- static QString getPreferredVersion(const bool bEnableFixedTempoCorrection);
+ static QString getPreferredVersion(bool bEnableFixedTempoCorrection);
static QString getPreferredSubVersion(
- const bool bEnableFixedTempoCorrection,
- const bool bEnableOffsetCorrection,
- const int iMinBpm,
- const int iMaxBpm,
+ bool bEnableFixedTempoCorrection,
+ bool bEnableOffsetCorrection,
+ int iMinBpm,
+ int iMaxBpm,
const QHash<QString, QString>& extraVersionInfo);
static mixxx::BeatsPointer makePreferredBeats(
const QVector<double>& beats,
const QHash<QString, QString>& extraVersionInfo,
- const bool bEnableFixedTempoCorrection,
- const bool bEnableOffsetCorrection,
- const int iSampleRate,
- const int iTotalSamples,
- const int iMinBpm,
- const int iMaxBpm);
+ bool bEnableFixedTempoCorrection,
+ bool bEnableOffsetCorrection,
+ mixxx::audio::SampleRate iSampleRate,
+ SINT totalSamples,
+ int iMinBpm,
+ int iMaxBpm);
};
diff --git a/src/track/beatgrid.cpp b/src/track/beatgrid.cpp
index 10aaa7e4a2..8b81e4d83c 100644
--- a/src/track/beatgrid.cpp
+++ b/src/track/beatgrid.cpp
@@ -40,12 +40,12 @@ class BeatGridIterator : public BeatIterator {
};
BeatGrid::BeatGrid(
- SINT iSampleRate,
+ audio::SampleRate sampleRate,
const QString& subVersion,
const mixxx::track::io::BeatGrid& grid,
double beatLength)
: m_subVersion(subVersion),
- m_iSampleRate(iSampleRate),
+ m_sampleRate(sampleRate),
m_grid(grid),
m_dBeatLength(beatLength) {
// BeatGrid should live in the same thread as the track it is associated
@@ -54,7 +54,7 @@ BeatGrid::BeatGrid(
BeatGrid::BeatGrid(const BeatGrid& other, const mixxx::track::io::BeatGrid& grid, double beatLength)
: m_subVersion(other.m_subVersion),
- m_iSampleRate(other.m_iSampleRate),
+ m_sampleRate(other.m_sampleRate),
m_grid(grid),
m_dBeatLength(beatLength) {
}
@@ -65,7 +65,7 @@ BeatGrid::BeatGrid(const BeatGrid& other)
// static
BeatsPointer BeatGrid::makeBeatGrid(
- SINT iSampleRate,
+ audio::SampleRate sampleRate,
const QString& subVersion,
double dBpm,
double dFirstBeatSample) {
@@ -79,14 +79,14 @@ BeatsPointer BeatGrid::makeBeatGrid(
grid.mutable_first_beat()->set_frame_position(
static_cast<google::protobuf::int32>(dFirstBeatSample / kFrameSize));
// Calculate beat length as sample offsets
- double beatLength = (60.0 * iSampleRate / dBpm) * kFrameSize;
+ double beatLength = (60.0 * sampleRate / dBpm) * kFrameSize;
- return BeatsPointer(new BeatGrid(iSampleRate, subVersion, grid, beatLength));
+ return BeatsPointer(new BeatGrid(sampleRate, subVersion, grid, beatLength));
}
// static
BeatsPointer BeatGrid::makeBeatGrid(
- SINT sampleRate,
+ audio::SampleRate sampleRate,
const QString& subVersion,
const QByteArray& byteArray) {
mixxx::track::io::BeatGrid grid;
@@ -111,11 +111,6 @@ QByteArray BeatGrid::toByteArray() const {
return QByteArray(output.data(), static_cast<int>(output.length()));
}
-BeatsPointer BeatGrid::clone() const {
- BeatsPointer other(new BeatGrid(*this));
- return other;
-}
-
double BeatGrid::firstBeatSample() const {
return m_grid.first_beat().frame_position() * kFrameSize;
}
@@ -134,7 +129,7 @@ QString BeatGrid::getSubVersion() const {
// internal use only
bool BeatGrid::isValid() const {
- return m_iSampleRate > 0 && bpm() > 0;
+ return m_sampleRate.isValid() && bpm() > 0;
}
// This could be implemented in the Beats Class itself.
@@ -333,7 +328,7 @@ BeatsPointer BeatGrid::scale(enum BPMScale scale) const {
}
grid.mutable_bpm()->set_bpm(bpm);
- double beatLength = (60.0 * m_iSampleRate / bpm) * kFrameSize;
+ double beatLength = (60.0 * m_sampleRate / bpm) * kFrameSize;
return BeatsPointer(new BeatGrid(*this, grid, beatLength));
}
@@ -343,7 +338,7 @@ BeatsPointer BeatGrid::setBpm(double dBpm) {
}
mixxx::track::io::BeatGrid grid = m_grid;
grid.mutable_bpm()->set_bpm(dBpm);
- double beatLength = (60.0 * m_iSampleRate / dBpm) * kFrameSize;
+ double beatLength = (60.0 * m_sampleRate / dBpm) * kFrameSize;
return BeatsPointer(new BeatGrid(*this, grid, beatLength));
}
diff --git a/src/track/beatgrid.h b/src/track/beatgrid.h
index 2a7a0cc7eb..886a814171 100644
--- a/src/track/beatgrid.h
+++ b/src/track/beatgrid.h
@@ -1,7 +1,5 @@
#pragma once
-#include <QMutex>
-
#include "proto/beats.pb.h"
#include "track/beats.h"
@@ -20,13 +18,13 @@ class BeatGrid final : public Beats {
~BeatGrid() override = default;
static BeatsPointer makeBeatGrid(
- SINT iSampleRate,
+ audio::SampleRate sampleRate,
const QString& subVersion,
double dBpm,
double dFirstBeatSample);
static BeatsPointer makeBeatGrid(
- SINT iSampleRate,
+ audio::SampleRate sampleRate,
const QString& subVersion,
const QByteArray& byteArray);
@@ -57,22 +55,21 @@ class BeatGrid final : public Beats {
double getBpm() const override;
double getBpmAroundPosition(double curSample, int n) const override;
- SINT getSampleRate() const override {
- return m_iSampleRate;
+ audio::SampleRate getSampleRate() const override {
+ return m_sampleRate;
}
////////////////////////////////////////////////////////////////////////////
// Beat mutations
////////////////////////////////////////////////////////////////////////////
- BeatsPointer clone() const override;
BeatsPointer translate(double dNumSamples) const override;
BeatsPointer scale(enum BPMScale scale) const override;
BeatsPointer setBpm(double dBpm) override;
private:
BeatGrid(
- SINT iSampleRate,
+ audio::SampleRate sampleRate,
const QString& subVersion,
const mixxx::track::io::BeatGrid& grid,
double beatLength);
@@ -89,7 +