summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2019-12-17 23:45:02 +0100
committerGitHub <noreply@github.com>2019-12-17 23:45:02 +0100
commit6207c110dc2f540ee9d6cb07fb2b023cc4e9baff (patch)
treeaf39b6f0f3836524952836aa0fd511c0065a106b /src
parent272eec7abf3b5685339f5ac7cbb4981a166444db (diff)
parentbeb6f0ea50761af471502e593c10ed2e0d3159fc (diff)
Merge pull request #2380 from daschuer/PR1765_followup
Fix todo from #1765
Diffstat (limited to 'src')
-rw-r--r--src/library/autodj/autodjprocessor.cpp20
-rw-r--r--src/library/autodj/autodjprocessor.h8
-rw-r--r--src/test/autodjprocessor_test.cpp2
-rw-r--r--src/widget/wnumberrate.cpp6
-rw-r--r--src/widget/woverview.cpp40
-rw-r--r--src/widget/woverview.h6
6 files changed, 36 insertions, 46 deletions
diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp
index 45faf9cd34..726e383fd9 100644
--- a/src/library/autodj/autodjprocessor.cpp
+++ b/src/library/autodj/autodjprocessor.cpp
@@ -40,9 +40,7 @@ DeckAttributes::DeckAttributes(int index,
m_outroEndPos(group, "outro_end_position"),
m_sampleRate(group, "track_samplerate"),
m_duration(group, "duration"),
- m_rateDir(group, "rate_dir"),
- m_rateRange(group, "rateRange"),
- m_rateSlider(group, "rate"),
+ m_rateRatio(group, "rate_ratio"),
m_pPlayer(pPlayer) {
connect(m_pPlayer, &BaseTrackPlayer::newTrackLoaded,
this, &DeckAttributes::slotTrackLoaded);
@@ -56,9 +54,7 @@ DeckAttributes::DeckAttributes(int index,
m_introEndPos.connectValueChanged(this, &DeckAttributes::slotIntroEndPositionChanged);
m_outroStartPos.connectValueChanged(this, &DeckAttributes::slotOutroStartPositionChanged);
m_outroEndPos.connectValueChanged(this, &DeckAttributes::slotOutroEndPositionChanged);
- m_rateDir.connectValueChanged(this, &DeckAttributes::slotRateChanged);
- m_rateRange.connectValueChanged(this, &DeckAttributes::slotRateChanged);
- m_rateSlider.connectValueChanged(this, &DeckAttributes::slotRateChanged);
+ m_rateRatio.connectValueChanged(this, &DeckAttributes::slotRateChanged);
}
DeckAttributes::~DeckAttributes() {
@@ -110,16 +106,8 @@ TrackPointer DeckAttributes::getLoadedTrack() const {
return m_pPlayer != NULL ? m_pPlayer->getLoadedTrack() : TrackPointer();
}
-double DeckAttributes::calcRateRatio() const {
- double rateRatio = 1.0 + m_rateDir.get() * m_rateRange.get() * m_rateSlider.get();
- if (rateRatio == 0.0) {
- return 1.0;
- }
- return rateRatio;
-}
-
double DeckAttributes::trackTime() const {
- return trackDuration() / calcRateRatio();
+ return trackDuration() / rateRatio();
}
double DeckAttributes::timeElapsed() const {
@@ -1099,7 +1087,7 @@ double AutoDJProcessor::samplePositionToSeconds(double samplePosition, DeckAttri
if (sampleRate <= 0.0) {
return 0.0;
}
- return samplePosition / sampleRate / pDeck->calcRateRatio();
+ return samplePosition / sampleRate / pDeck->rateRatio();
}
void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
diff --git a/src/library/autodj/autodjprocessor.h b/src/library/autodj/autodjprocessor.h
index 411d28da13..4a3c7da337 100644
--- a/src/library/autodj/autodjprocessor.h
+++ b/src/library/autodj/autodjprocessor.h
@@ -90,7 +90,9 @@ class DeckAttributes : public QObject {
return m_duration.get();
}
- double calcRateRatio() const;
+ double rateRatio() const {
+ return m_rateRatio.get();
+ }
TrackPointer getLoadedTrack() const;
@@ -138,9 +140,7 @@ class DeckAttributes : public QObject {
ControlProxy m_outroEndPos;
ControlProxy m_sampleRate;
ControlProxy m_duration;
- ControlProxy m_rateDir;
- ControlProxy m_rateRange;
- ControlProxy m_rateSlider;
+ ControlProxy m_rateRatio;
BaseTrackPlayer* m_pPlayer;
};
diff --git a/src/test/autodjprocessor_test.cpp b/src/test/autodjprocessor_test.cpp
index ecef043a04..3cf15ed3d2 100644
--- a/src/test/autodjprocessor_test.cpp
+++ b/src/test/autodjprocessor_test.cpp
@@ -41,6 +41,7 @@ class FakeDeck : public BaseTrackPlayer {
: BaseTrackPlayer(NULL, group),
duration(ConfigKey(group, "duration")),
samplerate(ConfigKey(group, "track_samplerate")),
+ rateratio(ConfigKey(group, "rate_ratio"), true, false, false, 1.0),
playposition(ConfigKey(group, "playposition"), 0.0, 1.0, 0, 0, true),
play(ConfigKey(group, "play")),
repeat(ConfigKey(group, "repeat")),
@@ -95,6 +96,7 @@ class FakeDeck : public BaseTrackPlayer {
TrackPointer loadedTrack;
ControlObject duration;
ControlObject samplerate;
+ ControlObject rateratio;
ControlLinPotmeter playposition;
ControlPushButton play;
ControlPushButton repeat;
diff --git a/src/widget/wnumberrate.cpp b/src/widget/wnumberrate.cpp
index 17f53ce5df..ddcd23688d 100644
--- a/src/widget/wnumberrate.cpp
+++ b/src/widget/wnumberrate.cpp
@@ -21,11 +21,11 @@ WNumberRate::WNumberRate(const char * group, QWidget * parent)
m_pRateRatio = new ControlProxy(group, "rate_ratio", this);
m_pRateRatio->connectValueChanged(this, &WNumberRate::setValue);
// Initialize the widget.
- setValue(0);
+ setValue(m_pRateRatio->get());
}
-void WNumberRate::setValue(double /*dValue*/) {
- double vsign = m_pRateRatio->get() - 1;
+void WNumberRate::setValue(double dValue) {
+ double vsign = dValue - 1;
char sign = '+';
if (vsign < -0.00000001) {
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp
index 2ff97862f0..183e9e0844 100644
--- a/src/widget/woverview.cpp
+++ b/src/widget/woverview.cpp
@@ -73,12 +73,9 @@ WOverview::WOverview(
m_endOfTrackControl = new ControlProxy(
m_group, "end_of_track", this);
m_endOfTrackControl->connectValueChanged(this, &WOverview::onEndOfTrackChange);
- m_pRateDirControl = new ControlProxy(m_group, "rate_dir", this);
- m_pRateRangeControl = new ControlProxy(m_group, "rateRange", this);
- m_pRateSliderControl = new ControlProxy(m_group, "rate", this);
+ m_pRateRatioControl = new ControlProxy(m_group, "rate_ratio", this);
// Needed to recalculate range durations when rate slider is moved without the deck playing
- // TODO: connect to rate_ratio instead in PR #1765
- m_pRateSliderControl->connectValueChanged(this, &WOverview::onRateSliderChange);
+ m_pRateRatioControl->connectValueChanged(this, &WOverview::onRateRatioChange);
m_trackSampleRateControl = new ControlProxy(m_group, "track_samplerate", this);
m_trackSamplesControl =
new ControlProxy(m_group, "track_samples", this);
@@ -327,7 +324,8 @@ void WOverview::onEndOfTrackChange(double v) {
update();
}
-void WOverview::onMarkChanged(double /*v*/) {
+void WOverview::onMarkChanged(double v) {
+ Q_UNUSED(v);
//qDebug() << "WOverview::onMarkChanged()" << v;
if (m_pCurrentTrack) {
updateCues(m_pCurrentTrack->getCuePoints());
@@ -335,12 +333,14 @@ void WOverview::onMarkChanged(double /*v*/) {
}
}
-void WOverview::onMarkRangeChange(double /*v*/) {
+void WOverview::onMarkRangeChange(double v) {
+ Q_UNUSED(v);
//qDebug() << "WOverview::onMarkRangeChange()" << v;
update();
}
-void WOverview::onRateSliderChange(double /*v*/) {
+void WOverview::onRateRatioChange(double v) {
+ Q_UNUSED(v);
update();
}
@@ -520,8 +520,8 @@ void WOverview::slotCueMenuPopupAboutToHide() {
update();
}
-void WOverview::leaveEvent(QEvent* e) {
- Q_UNUSED(e);
+void WOverview::leaveEvent(QEvent* pEvent) {
+ Q_UNUSED(pEvent);
if (!m_bHotcueMenuShowing) {
m_pHoveredMark.clear();
}
@@ -530,7 +530,8 @@ void WOverview::leaveEvent(QEvent* e) {
update();
}
-void WOverview::paintEvent(QPaintEvent * /*unused*/) {
+void WOverview::paintEvent(QPaintEvent* pEvent) {
+ Q_UNUSED(pEvent);
ScopedTimer t("WOverview::paintEvent");
QPainter painter(this);
@@ -1089,12 +1090,13 @@ void WOverview::paintText(const QString& text, QPainter* pPainter) {
}
double WOverview::samplePositionToSeconds(double sample) {
- // TODO: replace with rate_ratio in PR #1765
- double rateRatio = 1.0 + m_pRateDirControl->get() * m_pRateRangeControl->get() * m_pRateSliderControl->get();
- return sample / m_trackSampleRateControl->get() / mixxx::kEngineChannelCount / rateRatio;
+ double trackTime = sample /
+ (m_trackSampleRateControl->get() * mixxx::kEngineChannelCount);
+ return trackTime / m_pRateRatioControl->get();
}
-void WOverview::resizeEvent(QResizeEvent * /*unused*/) {
+void WOverview::resizeEvent(QResizeEvent* pEvent) {
+ Q_UNUSED(pEvent);
// Play-position potmeters range from 0 to 1 but they allow out-of-range
// sets. This is to give VC access to the pre-roll area.
const double kMaxPlayposRange = 1.0;
@@ -1116,9 +1118,9 @@ void WOverview::resizeEvent(QResizeEvent * /*unused*/) {
Init();
}
-void WOverview::dragEnterEvent(QDragEnterEvent* event) {
- DragAndDropHelper::handleTrackDragEnterEvent(event, m_group, m_pConfig);
+void WOverview::dragEnterEvent(QDragEnterEvent* pEvent) {
+ DragAndDropHelper::handleTrackDragEnterEvent(pEvent, m_group, m_pConfig);
}
-void WOverview::dropEvent(QDropEvent* event) {
- DragAndDropHelper::handleTrackDropEvent(event, *this, m_group, m_pConfig);
+void WOverview::dropEvent(QDropEvent* pEvent) {
+ DragAndDropHelper::handleTrackDropEvent(pEvent, *this, m_group, m_pConfig);
}
diff --git a/src/widget/woverview.h b/src/widget/woverview.h
index ed856154ff..4837b89f00 100644
--- a/src/widget/woverview.h
+++ b/src/widget/woverview.h
@@ -97,7 +97,7 @@ class WOverview : public WWidget, public TrackDropTarget {
void onMarkChanged(double v);
void onMarkRangeChange(double v);
- void onRateSliderChange(double v);
+ void onRateRatioChange(double v);
void receiveCuesUpdated();
void slotWaveformSummaryUpdated();
@@ -132,9 +132,7 @@ class WOverview : public WWidget, public TrackDropTarget {
UserSettingsPointer m_pConfig;
ControlProxy* m_endOfTrackControl;
bool m_endOfTrack;
- ControlProxy* m_pRateDirControl;
- ControlProxy* m_pRateRangeControl;
- ControlProxy* m_pRateSliderControl;
+ ControlProxy* m_pRateRatioControl;
ControlProxy* m_trackSampleRateControl;
ControlProxy* m_trackSamplesControl;
ControlProxy* m_playpositionControl;