summaryrefslogtreecommitdiffstats
path: root/src/engine/controls/enginecontrol.h
diff options
context:
space:
mode:
authorBe <be@mixxx.org>2019-01-06 10:40:02 -0600
committerBe <be@mixxx.org>2019-01-06 11:02:56 -0600
commit4257db41cccd9f5e0f1730aea86edbb1be240170 (patch)
tree80b030aa3ffcb664c4e1a4c101d1d6f621e31a7f /src/engine/controls/enginecontrol.h
parent603f5e5ee910b146f0d3d0a00af7acd5a5cdd291 (diff)
move EngineControls to their own folder
Diffstat (limited to 'src/engine/controls/enginecontrol.h')
-rw-r--r--src/engine/controls/enginecontrol.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/engine/controls/enginecontrol.h b/src/engine/controls/enginecontrol.h
new file mode 100644
index 0000000000..3d85173a1d
--- /dev/null
+++ b/src/engine/controls/enginecontrol.h
@@ -0,0 +1,108 @@
+// enginecontrol.h
+// Created 7/5/2009 by RJ Ryan (rryan@mit.edu)
+
+#ifndef ENGINECONTROL_H
+#define ENGINECONTROL_H
+
+#include <QObject>
+#include <QList>
+
+#include <gtest/gtest_prod.h>
+
+#include "preferences/usersettings.h"
+#include "track/track.h"
+#include "control/controlvalue.h"
+#include "engine/effects/groupfeaturestate.h"
+#include "engine/cachingreader.h"
+
+class EngineMaster;
+class EngineBuffer;
+
+const int kNoTrigger = -1;
+
+/**
+ * EngineControl is an abstract base class for objects which implement
+ * functionality pertaining to EngineBuffer. An EngineControl is meant to be a
+ * succinct implementation of a given EngineBuffer feature. Previously,
+ * EngineBuffer was an example of feature creep -- this is the result.
+ *
+ * When writing an EngineControl class, the following two properties hold:
+ *
+ * EngineControl::process will only be called during an EngineBuffer::process
+ * callback from the sound engine. This implies that any ControlObject accesses
+ * made in either of these methods are mutually exclusive, since one is
+ * exclusively in the call graph of the other.
+ */
+class EngineControl : public QObject {
+ Q_OBJECT
+ public:
+ EngineControl(QString group,
+ UserSettingsPointer pConfig);
+ ~EngineControl() override;
+
+ // Called by EngineBuffer::process every latency period. See the above
+ // comments for information about guarantees that hold during this call. An
+ // EngineControl can perform any upkeep operations that are necessary during
+ // this call.
+ virtual void process(const double dRate,
+ const double dCurrentSample,
+ const int iBufferSize);
+
+ // hintReader allows the EngineControl to provide hints to the reader to
+ // indicate that the given portion of a song is a potential imminent seek
+ // target.
+ virtual void hintReader(HintVector* pHintList);
+
+ virtual void setEngineMaster(EngineMaster* pEngineMaster);
+ void setEngineBuffer(EngineBuffer* pEngineBuffer);
+ virtual void setCurrentSample(const double dCurrentSample,
+ const double dTotalSamples, const double dTrackSampleRate);
+ QString getGroup() const;
+
+ // Called to collect player features for effects processing.
+ virtual void collectFeatureState(GroupFeatureState* pGroupFeatures) const {
+ Q_UNUSED(pGroupFeatures);
+ }
+
+ // Called whenever a seek occurs to allow the EngineControl to respond.
+ virtual void notifySeek(double dNewPlaypo, bool adjustingPhase);
+ virtual void trackLoaded(TrackPointer pNewTrack);
+
+ protected:
+ struct SampleOfTrack {
+ double current;
+ double total;
+ double rate;
+ };
+
+ SampleOfTrack getSampleOfTrack() const {
+ return m_sampleOfTrack.getValue();
+ }
+ void seek(double fractionalPosition);
+ void seekAbs(double sample);
+ // Seek to an exact sample and don't allow quantizing adjustment.
+ void seekExact(double sample);
+ EngineBuffer* pickSyncTarget();
+
+ UserSettingsPointer getConfig();
+ EngineMaster* getEngineMaster();
+ EngineBuffer* getEngineBuffer();
+
+ QString m_group;
+ UserSettingsPointer m_pConfig;
+
+ private:
+ ControlValueAtomic<SampleOfTrack> m_sampleOfTrack;
+ EngineMaster* m_pEngineMaster;
+ EngineBuffer* m_pEngineBuffer;
+
+
+ FRIEND_TEST(LoopingControlTest, ReloopToggleButton_DoesNotJumpAhead);
+ FRIEND_TEST(LoopingControlTest, ReloopAndStopButton);
+ FRIEND_TEST(LoopingControlTest, LoopScale_HalvesLoop);
+ FRIEND_TEST(LoopingControlTest, LoopMoveTest);
+ FRIEND_TEST(LoopingControlTest, LoopResizeSeek);
+ FRIEND_TEST(LoopingControlTest, Beatjump_JumpsByBeats);
+};
+
+#endif /* ENGINECONTROL_H */