diff options
Diffstat (limited to 'src/library/autodj/autodjprocessor.h')
-rw-r--r-- | src/library/autodj/autodjprocessor.h | 103 |
1 files changed, 71 insertions, 32 deletions
diff --git a/src/library/autodj/autodjprocessor.h b/src/library/autodj/autodjprocessor.h index c24f17b295..411d28da13 100644 --- a/src/library/autodj/autodjprocessor.h +++ b/src/library/autodj/autodjprocessor.h @@ -14,7 +14,7 @@ #include "util/class.h" class ControlPushButton; -class TrackCollection; +class TrackCollectionManager; class PlayerManagerInterface; class BaseTrackPlayer; @@ -50,6 +50,10 @@ class DeckAttributes : public QObject { return m_playPos.get(); } + double trackTime() const; + + double timeElapsed() const; + void setPlayPosition(double playpos) { m_playPos.set(playpos); } @@ -62,18 +66,14 @@ class DeckAttributes : public QObject { m_repeat.set(enabled ? 1.0 : 0.0); } - SeekOnLoadMode seekOnLoadMode() const { - return seekOnLoadModeFromDouble(m_seekOnLoadMode.get()); - } - - void setSeekOnLoadMode(SeekOnLoadMode mode) { - m_seekOnLoadMode.set(mode); - } - double introStartPosition() const { return m_introStartPos.get(); } + double introEndPosition() const { + return m_introEndPos.get(); + } + double outroStartPosition() const { return m_outroStartPos.get(); } @@ -86,50 +86,61 @@ class DeckAttributes : public QObject { return m_sampleRate.get(); } - double duration() const { + double trackDuration() const { return m_duration.get(); } + double calcRateRatio() const; + TrackPointer getLoadedTrack() const; signals: void playChanged(DeckAttributes* pDeck, bool playing); void playPositionChanged(DeckAttributes* pDeck, double playPosition); void introStartPositionChanged(DeckAttributes* pDeck, double introStartPosition); - void outroStartPositionChanged(DeckAttributes* pDeck, double introStartPosition); + void introEndPositionChanged(DeckAttributes* pDeck, double introEndPosition); + void outroStartPositionChanged(DeckAttributes* pDeck, double outtroStartPosition); void outroEndPositionChanged(DeckAttributes* pDeck, double outroEndPosition); void trackLoaded(DeckAttributes* pDeck, TrackPointer pTrack); void loadingTrack(DeckAttributes* pDeck, TrackPointer pNewTrack, TrackPointer pOldTrack); void playerEmpty(DeckAttributes* pDeck); + void rateChanged(DeckAttributes* pDeck); private slots: void slotPlayPosChanged(double v); void slotPlayChanged(double v); void slotIntroStartPositionChanged(double v); + void slotIntroEndPositionChanged(double v); void slotOutroStartPositionChanged(double v); void slotOutroEndPositionChanged(double v); void slotTrackLoaded(TrackPointer pTrack); void slotLoadingTrack(TrackPointer pNewTrack, TrackPointer pOldTrack); void slotPlayerEmpty(); + void slotRateChanged(double v); public: int index; QString group; - double startPos; - double posThreshold; - double fadeDuration; + double startPos; // Set in toDeck nature + double fadeBeginPos; // set in fromDeck nature + double fadeEndPos; // set in fromDeck nature + bool isFromDeck; + bool loading; // The data is inconsistent during loading a deck private: EngineChannel::ChannelOrientation m_orientation; ControlProxy m_playPos; ControlProxy m_play; ControlProxy m_repeat; - ControlProxy m_seekOnLoadMode; ControlProxy m_introStartPos; + ControlProxy m_introEndPos; ControlProxy m_outroStartPos; ControlProxy m_outroEndPos; ControlProxy m_sampleRate; ControlProxy m_duration; + ControlProxy m_rateDir; + ControlProxy m_rateRange; + ControlProxy m_rateSlider; BaseTrackPlayer* m_pPlayer; }; @@ -138,8 +149,8 @@ class AutoDJProcessor : public QObject { public: enum AutoDJState { ADJ_IDLE = 0, - ADJ_P1FADING, - ADJ_P2FADING, + ADJ_LEFT_FADING, + ADJ_RIGHT_FADING, ADJ_ENABLE_P1LOADED, ADJ_ENABLE_P1PLAYING, ADJ_DISABLED @@ -154,11 +165,18 @@ class AutoDJProcessor : public QObject { ADJ_NOT_TWO_DECKS }; + enum class TransitionMode { + FullIntroOutro, + FadeAtOutroStart, + FixedFullTrack, + FixedSkipSilence + }; + AutoDJProcessor(QObject* pParent, UserSettingsPointer pConfig, PlayerManagerInterface* pPlayerManager, - int iAutoDJPlaylistId, - TrackCollection* pCollection); + TrackCollectionManager* pTrackCollectionManager, + int iAutoDJPlaylistId); virtual ~AutoDJProcessor(); AutoDJState getState() const { @@ -169,6 +187,10 @@ class AutoDJProcessor : public QObject { return m_transitionTime; } + TransitionMode getTransitionMode() const { + return m_transitionMode; + } + PlaylistTableModel* getTableModel() const { return m_pAutoDJTableModel; } @@ -178,20 +200,13 @@ class AutoDJProcessor : public QObject { public slots: void setTransitionTime(int seconds); + void setTransitionMode(TransitionMode newMode); + AutoDJError shufflePlaylist(const QModelIndexList& selectedIndices); AutoDJError skipNext(); void fadeNow(); AutoDJError toggleAutoDJ(bool enable); - // The following virtual signal wrappers are used for testing - virtual void emitLoadTrackToPlayer(TrackPointer pTrack, QString group, - bool play) { - emit(loadTrackToPlayer(pTrack, group, play)); - } - virtual void emitAutoDJStateChanged(AutoDJProcessor::AutoDJState state) { - emit(autoDJStateChanged(state)); - } - signals: void loadTrackToPlayer(TrackPointer pTrack, QString group, bool play); @@ -200,40 +215,62 @@ class AutoDJProcessor : public QObject { void randomTrackRequested(int tracksToAdd); private slots: + void crossfaderChanged(double value); void playerPositionChanged(DeckAttributes* pDeck, double position); void playerPlayChanged(DeckAttributes* pDeck, bool playing); void playerIntroStartChanged(DeckAttributes* pDeck, double position); + void playerIntroEndChanged(DeckAttributes* pDeck, double position); void playerOutroStartChanged(DeckAttributes* pDeck, double position); void playerOutroEndChanged(DeckAttributes* pDeck, double position); void playerTrackLoaded(DeckAttributes* pDeck, TrackPointer pTrack); void playerLoadingTrack(DeckAttributes* pDeck, TrackPointer pNewTrack, TrackPointer pOldTrack); void playerEmpty(DeckAttributes* pDeck); + void playerRateChanged(DeckAttributes* pDeck); void controlEnable(double value); void controlFadeNow(double value); void controlShuffle(double value); void controlSkipNext(double value); + protected: + // The following virtual signal wrappers are used for testing + virtual void emitLoadTrackToPlayer(TrackPointer pTrack, QString group, bool play) { + emit(loadTrackToPlayer(pTrack, group, play)); + } + virtual void emitAutoDJStateChanged(AutoDJProcessor::AutoDJState state) { + emit(autoDJStateChanged(state)); + } + private: // Gets or sets the crossfader position while normalizing it so that -1 is // all the way mixed to the left side and 1 is all the way mixed to the // right side. (prevents AutoDJ logic from having to check for hamster mode // every time) double getCrossfader() const; - void setCrossfader(double value, bool right); + void setCrossfader(double value); // Following functions return seconds computed from samples or -1 if // track in deck has invalid sample rate (<= 0) double getIntroStartPosition(DeckAttributes* pDeck); + double getIntroEndPosition(DeckAttributes* pDeck); double getOutroStartPosition(DeckAttributes* pDeck); double getOutroEndPosition(DeckAttributes* pDeck); + double getFirstSoundPosition(DeckAttributes* pDeck); + double getLastSoundPosition(DeckAttributes* pDeck); + double samplePositionToSeconds(double samplePosition, DeckAttributes* pDeck); TrackPointer getNextTrackFromQueue(); bool loadNextTrackFromQueue(const DeckAttributes& pDeck, bool play = false); void calculateTransition(DeckAttributes* pFromDeck, - DeckAttributes* pToDeck); - DeckAttributes* getOtherDeck(DeckAttributes* pFromDeck, - bool playing = false); + DeckAttributes* pToDeck, + bool seekToStartPoint); + void useFixedFadeTime(DeckAttributes* pFromDeck, + DeckAttributes* pToDeck, + double fromDeckPosition, + double endPoint, + double startPoint); + DeckAttributes* getOtherDeck(const DeckAttributes* pThisDeck); + DeckAttributes* getFromDeck(); // Removes the track loaded to the player group from the top of the AutoDJ // queue if it is present. @@ -248,7 +285,9 @@ class AutoDJProcessor : public QObject { PlaylistTableModel* m_pAutoDJTableModel; AutoDJState m_eState; + double m_transitionProgress; double m_transitionTime; // the desired value set by the user + TransitionMode m_transitionMode; QList<DeckAttributes*> m_decks; |