From 71b126a434fd8cb4016d36e8cbe98165e314ed55 Mon Sep 17 00:00:00 2001 From: dev Date: Sun, 6 Jun 2021 15:38:59 +0530 Subject: [PATCH 1/6] Complete rename in include/ --- include/AutomationPattern.h | 6 +- include/AutomationPatternView.h | 4 +- include/AutomationTrack.h | 2 +- include/{BBTCO.h => BBClip.h} | 18 +++--- include/{BBTCOView.h => BBClipView.h} | 16 +++--- include/BBEditor.h | 2 +- include/BBTrack.h | 4 +- include/BBTrackContainer.h | 4 +- include/{TrackContentObject.h => Clip.h} | 22 ++++---- .../{TrackContentObjectView.h => ClipView.h} | 56 +++++++++---------- include/InstrumentTrack.h | 2 +- include/Pattern.h | 6 +- include/PatternView.h | 4 +- include/{SampleTCO.h => SampleClip.h} | 22 ++++---- include/{SampleTCOView.h => SampleClipView.h} | 22 ++++---- include/SamplePlayHandle.h | 4 +- include/SampleRecordHandle.h | 6 +- include/SampleTrack.h | 4 +- include/Song.h | 2 +- include/TimeLineWidget.h | 2 +- include/Track.h | 30 +++++----- include/TrackContainerView.h | 2 +- include/TrackContentWidget.h | 12 ++-- include/TrackView.h | 6 +- 24 files changed, 129 insertions(+), 129 deletions(-) rename include/{BBTCO.h => BBClip.h} (81%) rename include/{BBTCOView.h => BBClipView.h} (84%) rename include/{TrackContentObject.h => Clip.h} (83%) rename include/{TrackContentObjectView.h => ClipView.h} (77%) rename include/{SampleTCO.h => SampleClip.h} (83%) rename include/{SampleTCOView.h => SampleClipView.h} (79%) diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index 1a98f49568f..57c9b657ec7 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -31,7 +31,7 @@ #include #include "AutomationNode.h" -#include "TrackContentObject.h" +#include "Clip.h" class AutomationTrack; @@ -39,7 +39,7 @@ class TimePos; -class LMMS_EXPORT AutomationPattern : public TrackContentObject +class LMMS_EXPORT AutomationPattern : public Clip { Q_OBJECT public: @@ -150,7 +150,7 @@ class LMMS_EXPORT AutomationPattern : public TrackContentObject static const QString classNodeName() { return "automationpattern"; } QString nodeName() const override { return classNodeName(); } - TrackContentObjectView * createView( TrackView * _tv ) override; + ClipView * createView( TrackView * _tv ) override; static bool isAutomated( const AutomatableModel * _m ); diff --git a/include/AutomationPatternView.h b/include/AutomationPatternView.h index 5e7b12977af..8c1af5a1ba1 100644 --- a/include/AutomationPatternView.h +++ b/include/AutomationPatternView.h @@ -30,10 +30,10 @@ #include "AutomationPattern.h" #include "Song.h" #include "SongEditor.h" -#include "TrackContentObjectView.h" +#include "ClipView.h" -class AutomationPatternView : public TrackContentObjectView +class AutomationPatternView : public ClipView { Q_OBJECT diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index ee55c31acd8..e0d6e9b90d6 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -46,7 +46,7 @@ class AutomationTrack : public Track } TrackView * createView( TrackContainerView* ) override; - TrackContentObject* createTCO(const TimePos & pos) override; + Clip* createClip(const TimePos & pos) override; virtual void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; diff --git a/include/BBTCO.h b/include/BBClip.h similarity index 81% rename from include/BBTCO.h rename to include/BBClip.h index 8a0ba49bd3e..f073fca496c 100644 --- a/include/BBTCO.h +++ b/include/BBClip.h @@ -1,5 +1,5 @@ /* - * BBTCO.h + * BBClip.h * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -23,17 +23,17 @@ */ -#ifndef BB_TCO_H -#define BB_TCO_H +#ifndef BB_CLIP_H +#define BB_CLIP_H -#include "TrackContentObjectView.h" +#include "ClipView.h" -class BBTCO : public TrackContentObject +class BBClip : public Clip { public: - BBTCO( Track * _track ); - virtual ~BBTCO() = default; + BBClip( Track * _track ); + virtual ~BBClip() = default; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; @@ -44,10 +44,10 @@ class BBTCO : public TrackContentObject int bbTrackIndex(); - TrackContentObjectView * createView( TrackView * _tv ) override; + ClipView * createView( TrackView * _tv ) override; private: - friend class BBTCOView; + friend class BBClipView; } ; diff --git a/include/BBTCOView.h b/include/BBClipView.h similarity index 84% rename from include/BBTCOView.h rename to include/BBClipView.h index 13c65ba5873..395904a605d 100644 --- a/include/BBTCOView.h +++ b/include/BBClipView.h @@ -1,5 +1,5 @@ /* - * BBTCOView.h + * BBClipView.h * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -23,20 +23,20 @@ */ -#ifndef BB_TCO_VIEW_H -#define BB_TCO_VIEW_H +#ifndef BB_CLIP_VIEW_H +#define BB_CLIP_VIEW_H -#include "BBTCO.h" +#include "BBClip.h" #include -class BBTCOView : public TrackContentObjectView +class BBClipView : public ClipView { Q_OBJECT public: - BBTCOView( TrackContentObject * _tco, TrackView * _tv ); - virtual ~BBTCOView() = default; + BBClipView( Clip * _tco, TrackView * _tv ); + virtual ~BBClipView() = default; public slots: @@ -55,7 +55,7 @@ protected slots: private: - BBTCO * m_bbTCO; + BBClip * m_bbClip; QPixmap m_paintPixmap; QStaticText m_staticTextName; diff --git a/include/BBEditor.h b/include/BBEditor.h index d02dc198b64..96541ee7786 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -71,7 +71,7 @@ class BBTrackContainerView : public TrackContainerView public: BBTrackContainerView(BBTrackContainer* tc); - bool fixedTCOs() const override + bool fixedClips() const override { return true; } diff --git a/include/BBTrack.h b/include/BBTrack.h index da578ffc8d1..103bed41fc4 100644 --- a/include/BBTrack.h +++ b/include/BBTrack.h @@ -30,7 +30,7 @@ #include -#include "BBTCOView.h" +#include "BBClipView.h" #include "Track.h" class TrackLabelButton; @@ -47,7 +47,7 @@ class LMMS_EXPORT BBTrack : public Track virtual bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num = -1 ) override; TrackView * createView( TrackContainerView* tcv ) override; - TrackContentObject* createTCO(const TimePos & pos) override; + Clip* createClip(const TimePos & pos) override; virtual void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; diff --git a/include/BBTrackContainer.h b/include/BBTrackContainer.h index 79bf2e31565..4337b146796 100644 --- a/include/BBTrackContainer.h +++ b/include/BBTrackContainer.h @@ -57,9 +57,9 @@ class LMMS_EXPORT BBTrackContainer : public TrackContainer void swapBB(int bb1, int bb2); - void updateBBTrack(TrackContentObject * tco); + void updateBBTrack(Clip * tco); void fixIncorrectPositions(); - void createTCOsForBB(int bb); + void createClipsForBB(int bb); AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum) const override; diff --git a/include/TrackContentObject.h b/include/Clip.h similarity index 83% rename from include/TrackContentObject.h rename to include/Clip.h index dddd2b75c39..f0afb16d0b7 100644 --- a/include/TrackContentObject.h +++ b/include/Clip.h @@ -1,5 +1,5 @@ /* - * TrackConteintObject.h - declaration of TrackContentObject class + * TrackConteintObject.h - declaration of Clip class * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -32,20 +32,20 @@ class Track; -class TrackContentObjectView; +class ClipView; class TrackContainer; class TrackView; -class LMMS_EXPORT TrackContentObject : public Model, public JournallingObject +class LMMS_EXPORT Clip : public Model, public JournallingObject { Q_OBJECT MM_OPERATORS mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: - TrackContentObject( Track * track ); - virtual ~TrackContentObject(); + Clip( Track * track ); + virtual ~Clip(); inline Track * getTrack() const { @@ -117,7 +117,7 @@ class LMMS_EXPORT TrackContentObject : public Model, public JournallingObject virtual void movePosition( const TimePos & pos ); virtual void changeLength( const TimePos & length ); - virtual TrackContentObjectView * createView( TrackView * tv ) = 0; + virtual ClipView * createView( TrackView * tv ) = 0; inline void selectViewOnCreate( bool select ) { @@ -130,15 +130,15 @@ class LMMS_EXPORT TrackContentObject : public Model, public JournallingObject } /// Returns true if and only if a->startPosition() < b->startPosition() - static bool comparePosition(const TrackContentObject* a, const TrackContentObject* b); + static bool comparePosition(const Clip* a, const Clip* b); TimePos startTimeOffset() const; void setStartTimeOffset( const TimePos &startTimeOffset ); void updateColor(); - // Will copy the state of a TCO to another TCO - static void copyStateTo( TrackContentObject *src, TrackContentObject *dst ); + // Will copy the state of a Clip to another Clip + static void copyStateTo( Clip *src, Clip *dst ); public slots: void toggleMute(); @@ -147,7 +147,7 @@ public slots: signals: void lengthChanged(); void positionChanged(); - void destroyedTCO(); + void destroyedClip(); void trackColorChanged(); @@ -175,7 +175,7 @@ public slots: QColor m_color; bool m_useCustomClipColor; - friend class TrackContentObjectView; + friend class ClipView; } ; diff --git a/include/TrackContentObjectView.h b/include/ClipView.h similarity index 77% rename from include/TrackContentObjectView.h rename to include/ClipView.h index d7a72c204b3..00b879d5713 100644 --- a/include/TrackContentObjectView.h +++ b/include/ClipView.h @@ -1,5 +1,5 @@ /* - * TrackContentObjectView.h - declaration of TrackContentObjectView class + * ClipView.h - declaration of ClipView class * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -30,7 +30,7 @@ #include "ModelView.h" #include "Rubberband.h" -#include "TrackContentObject.h" +#include "Clip.h" class QMenu; @@ -38,11 +38,11 @@ class QContextMenuEvent; class DataFile; class TextFloat; -class TrackContentObject; +class Clip; class TrackView; -class TrackContentObjectView : public selectableObject, public ModelView +class ClipView : public selectableObject, public ModelView { Q_OBJECT @@ -61,12 +61,12 @@ class TrackContentObjectView : public selectableObject, public ModelView Q_PROPERTY( QSize mouseHotspotKnife MEMBER m_mouseHotspotKnife ) public: - TrackContentObjectView( TrackContentObject * tco, TrackView * tv ); - virtual ~TrackContentObjectView(); + ClipView( Clip * tco, TrackView * tv ); + virtual ~ClipView(); - bool fixedTCOs(); + bool fixedClips(); - inline TrackContentObject * getTrackContentObject() + inline Clip * getClip() { return m_tco; } @@ -98,23 +98,23 @@ class TrackContentObjectView : public selectableObject, public ModelView bool needsUpdate(); void setNeedsUpdate( bool b ); - // Method to get a QVector of TCOs to be affected by a context menu action - QVector getClickedTCOs(); + // Method to get a QVector of Clips to be affected by a context menu action + QVector getClickedClips(); - // Methods to remove, copy, cut, paste and mute a QVector of TCO views - void copy( QVector tcovs ); - void cut( QVector tcovs ); + // Methods to remove, copy, cut, paste and mute a QVector of Clip views + void copy( QVector tcovs ); + void cut( QVector tcovs ); void paste(); // remove and toggleMute are static because they don't depend - // being called from a particular TCO view, but can be called anywhere as long - // as a valid TCO view list is given, while copy/cut require an instance for + // being called from a particular Clip view, but can be called anywhere as long + // as a valid Clip view list is given, while copy/cut require an instance for // some metadata to be written to the clipboard. - static void remove( QVector tcovs ); - static void toggleMute( QVector tcovs ); - static void mergeTCOs(QVector tcovs); + static void remove( QVector tcovs ); + static void toggleMute( QVector tcovs ); + static void mergeClips(QVector tcovs); // Returns true if selection can be merged and false if not - static bool canMergeSelection(QVector tcovs); + static bool canMergeSelection(QVector tcovs); QColor getColorForDisplay( QColor ); @@ -141,8 +141,8 @@ public slots: }; TrackView * m_trackView; - TimePos m_initialTCOPos; - TimePos m_initialTCOEnd; + TimePos m_initialClipPos; + TimePos m_initialClipEnd; bool m_marker = false; int m_markerPos = 0; @@ -170,7 +170,7 @@ public slots: float pixelsPerBar(); - DataFile createTCODataFiles(const QVector & tcos) const; + DataFile createClipDataFiles(const QVector & tcos) const; virtual void paintTextLabel(QString const & text, QPainter & painter); @@ -195,7 +195,7 @@ protected slots: static TextFloat * s_textFloat; - TrackContentObject * m_tco; + Clip * m_tco; Actions m_action; QPoint m_initialMousePos; QPoint m_initialMouseGlobalPos; @@ -223,16 +223,16 @@ protected slots: { m_initialMousePos = pos; m_initialMouseGlobalPos = mapToGlobal( pos ); - m_initialTCOPos = m_tco->startPosition(); - m_initialTCOEnd = m_initialTCOPos + m_tco->length(); + m_initialClipPos = m_tco->startPosition(); + m_initialClipEnd = m_initialClipPos + m_tco->length(); } void setInitialOffsets(); bool mouseMovedDistance( QMouseEvent * me, int distance ); - TimePos draggedTCOPos( QMouseEvent * me ); + TimePos draggedClipPos( QMouseEvent * me ); int knifeMarkerPos( QMouseEvent * me ); - //! Return true iff TCO could be split. Currently only implemented for samples - virtual bool splitTCO( const TimePos pos ){ return false; }; + //! Return true iff Clip could be split. Currently only implemented for samples + virtual bool splitClip( const TimePos pos ){ return false; }; void updateCursor(QMouseEvent * me); } ; diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index d3c84a4413b..7553a55401d 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -138,7 +138,7 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor TrackView * createView( TrackContainerView* tcv ) override; // create new track-content-object = pattern - TrackContentObject* createTCO(const TimePos & pos) override; + Clip* createClip(const TimePos & pos) override; // called by track diff --git a/include/Pattern.h b/include/Pattern.h index 9d1697a989c..bb07e25817a 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -30,13 +30,13 @@ #include "Note.h" #include "PatternView.h" -#include "TrackContentObjectView.h" +#include "ClipView.h" class InstrumentTrack; -class LMMS_EXPORT Pattern : public TrackContentObject +class LMMS_EXPORT Pattern : public Clip { Q_OBJECT public: @@ -102,7 +102,7 @@ class LMMS_EXPORT Pattern : public TrackContentObject bool empty(); - TrackContentObjectView * createView( TrackView * _tv ) override; + ClipView * createView( TrackView * _tv ) override; using Model::dataChanged; diff --git a/include/PatternView.h b/include/PatternView.h index 6c2243e72e6..252ac3a4d00 100644 --- a/include/PatternView.h +++ b/include/PatternView.h @@ -26,12 +26,12 @@ #define PATTERN_VIEW_H #include "Pattern.h" -#include "TrackContentObjectView.h" +#include "ClipView.h" class Pattern; -class PatternView : public TrackContentObjectView +class PatternView : public ClipView { Q_OBJECT diff --git a/include/SampleTCO.h b/include/SampleClip.h similarity index 83% rename from include/SampleTCO.h rename to include/SampleClip.h index 616dba04432..16b1344a8f7 100644 --- a/include/SampleTCO.h +++ b/include/SampleClip.h @@ -1,5 +1,5 @@ /* - * SampleTCO.h + * SampleClip.h * * Copyright (c) 2005-2014 Tobias Doerffel * @@ -22,24 +22,24 @@ * */ -#ifndef SAMPLE_TCO_H -#define SAMPLE_TCO_H +#ifndef SAMPLE_CLIP_H +#define SAMPLE_CLIP_H #include "SampleBuffer.h" #include "SampleTrack.h" -#include "TrackContentObject.h" +#include "Clip.h" -class SampleTCO : public TrackContentObject +class SampleClip : public Clip { Q_OBJECT mapPropertyFromModel(bool,isRecord,setRecord,m_recordModel); public: - SampleTCO( Track * _track ); - SampleTCO( const SampleTCO& orig ); - virtual ~SampleTCO(); + SampleClip( Track * _track ); + SampleClip( const SampleClip& orig ); + virtual ~SampleClip(); - SampleTCO& operator=( const SampleTCO& that ) = delete; + SampleClip& operator=( const SampleClip& that ) = delete; void changeLength( const TimePos & _length ) override; const QString & sampleFile() const; @@ -59,7 +59,7 @@ class SampleTCO : public TrackContentObject TimePos sampleLength() const; void setSampleStartFrame( f_cnt_t startFrame ); void setSamplePlayLength( f_cnt_t length ); - TrackContentObjectView * createView( TrackView * _tv ) override; + ClipView * createView( TrackView * _tv ) override; bool isPlaying() const; @@ -79,7 +79,7 @@ public slots: BoolModel m_recordModel; bool m_isPlaying; - friend class SampleTCOView; + friend class SampleClipView; signals: diff --git a/include/SampleTCOView.h b/include/SampleClipView.h similarity index 79% rename from include/SampleTCOView.h rename to include/SampleClipView.h index eab8f2733e1..4652f50fa9d 100644 --- a/include/SampleTCOView.h +++ b/include/SampleClipView.h @@ -1,5 +1,5 @@ /* - * SampleTCOView.h + * SampleClipView.h * * Copyright (c) 2005-2014 Tobias Doerffel * @@ -22,21 +22,21 @@ * */ -#ifndef SAMPLE_TCO_VIEW_H -#define SAMPLE_TCO_VIEW_H +#ifndef SAMPLE_CLIP_VIEW_H +#define SAMPLE_CLIP_VIEW_H -#include "SampleTCOView.h" +#include "SampleClipView.h" -#include "SampleTCO.h" -#include "TrackContentObjectView.h" +#include "SampleClip.h" +#include "ClipView.h" -class SampleTCOView : public TrackContentObjectView +class SampleClipView : public ClipView { Q_OBJECT public: - SampleTCOView( SampleTCO * _tco, TrackView * _tv ); - virtual ~SampleTCOView() = default; + SampleClipView( SampleClip * _tco, TrackView * _tv ); + virtual ~SampleClipView() = default; public slots: void updateSample(); @@ -55,9 +55,9 @@ public slots: private: - SampleTCO * m_tco; + SampleClip * m_tco; QPixmap m_paintPixmap; - bool splitTCO( const TimePos pos ) override; + bool splitClip( const TimePos pos ) override; } ; diff --git a/include/SamplePlayHandle.h b/include/SamplePlayHandle.h index 33f5ebe5294..6b21a6c9368 100644 --- a/include/SamplePlayHandle.h +++ b/include/SamplePlayHandle.h @@ -31,7 +31,7 @@ #include "PlayHandle.h" class BBTrack; -class SampleTCO; +class SampleClip; class Track; class AudioPort; @@ -41,7 +41,7 @@ class SamplePlayHandle : public PlayHandle public: SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort = true ); SamplePlayHandle( const QString& sampleFile ); - SamplePlayHandle( SampleTCO* tco ); + SamplePlayHandle( SampleClip* tco ); virtual ~SamplePlayHandle(); inline bool affinityMatters() const override diff --git a/include/SampleRecordHandle.h b/include/SampleRecordHandle.h index f2a6fd63be4..8e1c40d1041 100644 --- a/include/SampleRecordHandle.h +++ b/include/SampleRecordHandle.h @@ -34,14 +34,14 @@ class BBTrack; class SampleBuffer; -class SampleTCO; +class SampleClip; class Track; class SampleRecordHandle : public PlayHandle { public: - SampleRecordHandle( SampleTCO* tco ); + SampleRecordHandle( SampleClip* tco ); virtual ~SampleRecordHandle(); void play( sampleFrame * _working_buffer ) override; @@ -64,7 +64,7 @@ class SampleRecordHandle : public PlayHandle Track * m_track; BBTrack * m_bbTrack; - SampleTCO * m_tco; + SampleClip * m_tco; } ; diff --git a/include/SampleTrack.h b/include/SampleTrack.h index c2d984434ed..5f0541c7e01 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -30,7 +30,7 @@ #include "AudioPort.h" #include "FadeButton.h" #include "FxMixer.h" -#include "SampleTCO.h" +#include "SampleClip.h" #include "SampleTrackView.h" #include "Track.h" @@ -45,7 +45,7 @@ class SampleTrack : public Track virtual bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num = -1 ) override; TrackView * createView( TrackContainerView* tcv ) override; - TrackContentObject* createTCO(const TimePos & pos) override; + Clip* createClip(const TimePos & pos) override; virtual void saveTrackSpecificSettings( QDomDocument & _doc, diff --git a/include/Song.h b/include/Song.h index f9eff1fe29a..08f31a2bb05 100644 --- a/include/Song.h +++ b/include/Song.h @@ -321,7 +321,7 @@ class LMMS_EXPORT Song : public TrackContainer return "song"; } - virtual bool fixedTCOs() const + virtual bool fixedClips() const { return false; } diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index c7ac0124c9e..915553c4d98 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -235,7 +235,7 @@ public slots: MovePositionMarker, MoveLoopBegin, MoveLoopEnd, - SelectSongTCO, + SelectSongClip, } m_action; int m_moveXOff; diff --git a/include/Track.h b/include/Track.h index 9ddd34f4fc6..f94da5c5048 100644 --- a/include/Track.h +++ b/include/Track.h @@ -37,7 +37,7 @@ class TimePos; class TrackContainer; class TrackContainerView; -class TrackContentObject; +class Clip; class TrackView; @@ -60,7 +60,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: - typedef QVector tcoVector; + typedef QVector tcoVector; enum TrackTypes { @@ -94,7 +94,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject virtual TrackView * createView( TrackContainerView * view ) = 0; - virtual TrackContentObject * createTCO( const TimePos & pos ) = 0; + virtual Clip * createClip( const TimePos & pos ) = 0; virtual void saveTrackSpecificSettings( QDomDocument & doc, QDomElement & parent ) = 0; @@ -109,25 +109,25 @@ class LMMS_EXPORT Track : public Model, public JournallingObject m_simpleSerializingMode = true; } - // -- for usage by TrackContentObject only --------------- - TrackContentObject * addTCO( TrackContentObject * tco ); - void removeTCO( TrackContentObject * tco ); + // -- for usage by Clip only --------------- + Clip * addClip( Clip * tco ); + void removeClip( Clip * tco ); // ------------------------------------------------------- - void deleteTCOs(); + void deleteClips(); - int numOfTCOs(); - TrackContentObject * getTCO( int tcoNum ); - int getTCONum(const TrackContentObject* tco ); + int numOfClips(); + Clip * getClip( int tcoNum ); + int getClipNum(const Clip* tco ); - const tcoVector & getTCOs() const + const tcoVector & getClips() const { return m_trackContentObjects; } - void getTCOsInRange( tcoVector & tcoV, const TimePos & start, + void getClipsInRange( tcoVector & tcoV, const TimePos & start, const TimePos & end ); - void swapPositionOfTCOs( int tcoNum1, int tcoNum2 ); + void swapPositionOfClips( int tcoNum1, int tcoNum2 ); - void createTCOsForBB( int bb ); + void createClipsForBB( int bb ); void insertBar( const TimePos & pos ); @@ -228,7 +228,7 @@ public slots: signals: void destroyedTrack(); void nameChanged(); - void trackContentObjectAdded( TrackContentObject * ); + void trackContentObjectAdded( Clip * ); } ; diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index ebc4e42a6ea..f6ad177b920 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -65,7 +65,7 @@ class TrackContainerView : public QWidget, public ModelView, return m_currentPosition; } - virtual bool fixedTCOs() const + virtual bool fixedClips() const { return false; } diff --git a/include/TrackContentWidget.h b/include/TrackContentWidget.h index 37362319b76..aefbbc4e502 100644 --- a/include/TrackContentWidget.h +++ b/include/TrackContentWidget.h @@ -34,7 +34,7 @@ class QMimeData; class Track; -class TrackContentObjectView; +class ClipView; class TrackView; @@ -55,13 +55,13 @@ class TrackContentWidget : public QWidget, public JournallingObject /*! \brief Updates the background tile pixmap. */ void updateBackground(); - void addTCOView( TrackContentObjectView * tcov ); - void removeTCOView( TrackContentObjectView * tcov ); - void removeTCOView( int tcoNum ) + void addClipView( ClipView * tcov ); + void removeClipView( ClipView * tcov ); + void removeClipView( int tcoNum ) { if( tcoNum >= 0 && tcoNum < m_tcoViews.size() ) { - removeTCOView( m_tcoViews[tcoNum] ); + removeClipView( m_tcoViews[tcoNum] ); } } @@ -126,7 +126,7 @@ public slots: TrackView * m_trackView; - typedef QVector tcoViewVector; + typedef QVector tcoViewVector; tcoViewVector m_tcoViews; QPixmap m_background; diff --git a/include/TrackView.h b/include/TrackView.h index 1029e148c1d..7e114cd6090 100644 --- a/include/TrackView.h +++ b/include/TrackView.h @@ -40,7 +40,7 @@ class QMenu; class FadeButton; class Track; class TrackContainerView; -class TrackContentObject; +class Clip; const int DEFAULT_SETTINGS_WIDGET_WIDTH = 224; @@ -50,7 +50,7 @@ const int TRACK_OP_WIDTH = 78; const int DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT = 96; const int TRACK_OP_WIDTH_COMPACT = 62; -const int TCO_BORDER_WIDTH = 2; +const int CLIP_BORDER_WIDTH = 2; class TrackView : public QWidget, public ModelView, public JournallingObject @@ -163,7 +163,7 @@ public slots: private slots: - void createTCOView( TrackContentObject * tco ); + void createClipView( Clip * tco ); void muteChanged(); } ; From 90ed911ff0ec8ca14a394089d12cca584466d9e5 Mon Sep 17 00:00:00 2001 From: dev Date: Sun, 6 Jun 2021 16:28:43 +0530 Subject: [PATCH 2/6] Rename in src/ and fix errors --- data/themes/classic/style.css | 6 +- data/themes/default/style.css | 6 +- include/AutomationTrack.h | 2 +- include/BBClip.h | 2 +- include/BBClipView.h | 2 +- include/BBTrack.h | 2 +- include/BBTrackContainer.h | 6 +- include/BasicFilters.h | 8 +- include/ClipView.h | 24 +- include/InstrumentTrack.h | 2 +- include/SampleClip.h | 4 +- include/SampleClipView.h | 4 +- include/SamplePlayHandle.h | 2 +- include/SampleRecordHandle.h | 4 +- include/SampleTrack.h | 6 +- include/Song.h | 2 +- include/SongEditor.h | 2 +- include/Track.h | 20 +- include/TrackContainer.h | 4 +- include/TrackContentWidget.h | 22 +- include/TrackView.h | 2 +- plugins/HydrogenImport/HydrogenImport.cpp | 4 +- plugins/MidiExport/MidiExport.cpp | 4 +- plugins/MidiImport/MidiImport.cpp | 8 +- src/core/AutomationPattern.cpp | 28 +- src/core/{BBTCO.cpp => BBClip.cpp} | 18 +- src/core/BBTrackContainer.cpp | 36 +- src/core/CMakeLists.txt | 6 +- src/core/{TrackContentObject.cpp => Clip.cpp} | 50 +- src/core/DataFile.cpp | 6 +- src/core/{SampleTCO.cpp => SampleClip.cpp} | 72 +-- src/core/SamplePlayHandle.cpp | 10 +- src/core/SampleRecordHandle.cpp | 14 +- src/core/Song.cpp | 22 +- src/core/Track.cpp | 154 ++--- src/core/TrackContainer.cpp | 32 +- src/core/midi/MidiPort.cpp | 8 +- src/gui/AutomationPatternView.cpp | 38 +- src/gui/AutomationTrackView.cpp | 4 +- src/gui/{BBTCOView.cpp => BBClipView.cpp} | 56 +- src/gui/CMakeLists.txt | 6 +- ...rackContentObjectView.cpp => ClipView.cpp} | 594 +++++++++--------- src/gui/FileBrowser.cpp | 2 +- src/gui/PatternView.cpp | 56 +- .../{SampleTCOView.cpp => SampleClipView.cpp} | 162 ++--- src/gui/SampleTrackView.cpp | 6 +- src/gui/TimeLineWidget.cpp | 6 +- src/gui/TrackView.cpp | 26 +- src/gui/editors/BBEditor.cpp | 36 +- src/gui/editors/SongEditor.cpp | 28 +- src/gui/widgets/EnvelopeAndLfoView.cpp | 4 +- src/gui/widgets/TrackContentWidget.cpp | 200 +++--- src/gui/widgets/TrackOperationsWidget.cpp | 12 +- src/tracks/AutomationTrack.cpp | 4 +- src/tracks/BBTrack.cpp | 32 +- src/tracks/InstrumentTrack.cpp | 24 +- src/tracks/Pattern.cpp | 18 +- src/tracks/SampleTrack.cpp | 72 +-- 58 files changed, 995 insertions(+), 995 deletions(-) rename src/core/{BBTCO.cpp => BBClip.cpp} (86%) rename src/core/{TrackContentObject.cpp => Clip.cpp} (72%) rename src/core/{SampleTCO.cpp => SampleClip.cpp} (79%) rename src/gui/{BBTCOView.cpp => BBClipView.cpp} (72%) rename src/gui/{TrackContentObjectView.cpp => ClipView.cpp} (65%) rename src/gui/{SampleTCOView.cpp => SampleClipView.cpp} (63%) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index f6450c31ae2..949a6d7d029 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -666,7 +666,7 @@ TrackContainerView QLabel /* Patterns */ /* common pattern colors */ -TrackContentObjectView { +ClipView { qproperty-mutedColor: rgb( 128, 128, 128 ); qproperty-mutedBackgroundColor: rgb( 80, 80, 80 ); qproperty-selectedColor: rgb( 0, 125, 255 ); @@ -694,7 +694,7 @@ PatternView { } /* sample track pattern */ -SampleTCOView { +SampleClipView { background-color: rgba(42,51,59,255); color: #FF8F05; } @@ -706,7 +706,7 @@ AutomationPatternView { } /* bb-pattern */ -BBTCOView { +BBClipView { background-color: rgb( 128, 182, 175 ); /* default colour for bb-tracks */ } diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 7171003f728..1b7a2c2ea67 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -712,7 +712,7 @@ TrackContainerView QLabel /* Patterns */ /* common pattern colors */ -TrackContentObjectView { +ClipView { qproperty-mutedColor: rgba(255,255,255,100); qproperty-mutedBackgroundColor: #373d48; qproperty-selectedColor: #006B65; @@ -740,7 +740,7 @@ PatternView { } /* sample track pattern */ -SampleTCOView { +SampleClipView { background-color: rgba(42,51,59,255); color: #FF8F05; } @@ -752,7 +752,7 @@ AutomationPatternView { } /* bb-pattern */ -BBTCOView { +BBClipView { background-color: #20BDB2; /* default colour for bb-tracks */ } diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index e0d6e9b90d6..dc33f76c3c9 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -38,7 +38,7 @@ class AutomationTrack : public Track virtual ~AutomationTrack() = default; virtual bool play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _frame_base, int _tco_num = -1 ) override; + const f_cnt_t _frame_base, int _clip_num = -1 ) override; QString nodeName() const override { diff --git a/include/BBClip.h b/include/BBClip.h index f073fca496c..5c62e66ae2f 100644 --- a/include/BBClip.h +++ b/include/BBClip.h @@ -39,7 +39,7 @@ class BBClip : public Clip void loadSettings( const QDomElement & _this ) override; inline QString nodeName() const override { - return( "bbtco" ); + return( "bbclip" ); } int bbTrackIndex(); diff --git a/include/BBClipView.h b/include/BBClipView.h index 395904a605d..a779ca68066 100644 --- a/include/BBClipView.h +++ b/include/BBClipView.h @@ -35,7 +35,7 @@ class BBClipView : public ClipView { Q_OBJECT public: - BBClipView( Clip * _tco, TrackView * _tv ); + BBClipView( Clip * _clip, TrackView * _tv ); virtual ~BBClipView() = default; diff --git a/include/BBTrack.h b/include/BBTrack.h index 103bed41fc4..c07c8a90e22 100644 --- a/include/BBTrack.h +++ b/include/BBTrack.h @@ -45,7 +45,7 @@ class LMMS_EXPORT BBTrack : public Track virtual ~BBTrack(); virtual bool play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _frame_base, int _tco_num = -1 ) override; + const f_cnt_t _frame_base, int _clip_num = -1 ) override; TrackView * createView( TrackContainerView* tcv ) override; Clip* createClip(const TimePos & pos) override; diff --git a/include/BBTrackContainer.h b/include/BBTrackContainer.h index 4337b146796..dac67a39d23 100644 --- a/include/BBTrackContainer.h +++ b/include/BBTrackContainer.h @@ -38,7 +38,7 @@ class LMMS_EXPORT BBTrackContainer : public TrackContainer BBTrackContainer(); virtual ~BBTrackContainer(); - virtual bool play(TimePos start, const fpp_t frames, const f_cnt_t frameBase, int tcoNum = -1); + virtual bool play(TimePos start, const fpp_t frames, const f_cnt_t frameBase, int clipNum = -1); void updateAfterTrackAdd() override; @@ -57,11 +57,11 @@ class LMMS_EXPORT BBTrackContainer : public TrackContainer void swapBB(int bb1, int bb2); - void updateBBTrack(Clip * tco); + void updateBBTrack(Clip * clip); void fixIncorrectPositions(); void createClipsForBB(int bb); - AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum) const override; + AutomatedValueMap automatedValuesAt(TimePos time, int clipNum) const override; public slots: void play(); diff --git a/include/BasicFilters.h b/include/BasicFilters.h index c3a76d36e0d..3a77a1cc073 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -812,27 +812,27 @@ class BasicFilters _freq = qBound( minFreq(), _freq, 20000.0f ); const float omega = F_2PI * _freq * m_sampleRatio; const float tsin = sinf( omega ) * 0.5f; - const float tcos = cosf( omega ); + const float clips = cosf( omega ); const float alpha = tsin / _q; const float a0 = 1.0f / ( 1.0f + alpha ); - const float a1 = -2.0f * tcos * a0; + const float a1 = -2.0f * clips * a0; const float a2 = ( 1.0f - alpha ) * a0; switch( m_type ) { case LowPass: { - const float b1 = ( 1.0f - tcos ) * a0; + const float b1 = ( 1.0f - clips ) * a0; const float b0 = b1 * 0.5f; m_biQuad.setCoeffs( a1, a2, b0, b1, b0 ); break; } case HiPass: { - const float b1 = ( -1.0f - tcos ) * a0; + const float b1 = ( -1.0f - clips ) * a0; const float b0 = b1 * -0.5f; m_biQuad.setCoeffs( a1, a2, b0, b1, b0 ); break; diff --git a/include/ClipView.h b/include/ClipView.h index 00b879d5713..14ad930f42b 100644 --- a/include/ClipView.h +++ b/include/ClipView.h @@ -61,14 +61,14 @@ class ClipView : public selectableObject, public ModelView Q_PROPERTY( QSize mouseHotspotKnife MEMBER m_mouseHotspotKnife ) public: - ClipView( Clip * tco, TrackView * tv ); + ClipView( Clip * clip, TrackView * tv ); virtual ~ClipView(); bool fixedClips(); inline Clip * getClip() { - return m_tco; + return m_clip; } inline TrackView * getTrackView() @@ -102,19 +102,19 @@ class ClipView : public selectableObject, public ModelView QVector getClickedClips(); // Methods to remove, copy, cut, paste and mute a QVector of Clip views - void copy( QVector tcovs ); - void cut( QVector tcovs ); + void copy( QVector clipvs ); + void cut( QVector clipvs ); void paste(); // remove and toggleMute are static because they don't depend // being called from a particular Clip view, but can be called anywhere as long // as a valid Clip view list is given, while copy/cut require an instance for // some metadata to be written to the clipboard. - static void remove( QVector tcovs ); - static void toggleMute( QVector tcovs ); - static void mergeClips(QVector tcovs); + static void remove( QVector clipvs ); + static void toggleMute( QVector clipvs ); + static void mergeClips(QVector clipvs); // Returns true if selection can be merged and false if not - static bool canMergeSelection(QVector tcovs); + static bool canMergeSelection(QVector clipvs); QColor getColorForDisplay( QColor ); @@ -170,7 +170,7 @@ public slots: float pixelsPerBar(); - DataFile createClipDataFiles(const QVector & tcos) const; + DataFile createClipDataFiles(const QVector & clips) const; virtual void paintTextLabel(QString const & text, QPainter & painter); @@ -195,7 +195,7 @@ protected slots: static TextFloat * s_textFloat; - Clip * m_tco; + Clip * m_clip; Actions m_action; QPoint m_initialMousePos; QPoint m_initialMouseGlobalPos; @@ -223,8 +223,8 @@ protected slots: { m_initialMousePos = pos; m_initialMouseGlobalPos = mapToGlobal( pos ); - m_initialClipPos = m_tco->startPosition(); - m_initialClipEnd = m_initialClipPos + m_tco->length(); + m_initialClipPos = m_clip->startPosition(); + m_initialClipEnd = m_initialClipPos + m_clip->length(); } void setInitialOffsets(); diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 7553a55401d..7510ff8641f 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -133,7 +133,7 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor // play everything in given frame-range - creates note-play-handles virtual bool play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _frame_base, int _tco_num = -1 ) override; + const f_cnt_t _frame_base, int _clip_num = -1 ) override; // create new view for me TrackView * createView( TrackContainerView* tcv ) override; diff --git a/include/SampleClip.h b/include/SampleClip.h index 16b1344a8f7..e1e2a52a055 100644 --- a/include/SampleClip.h +++ b/include/SampleClip.h @@ -48,7 +48,7 @@ class SampleClip : public Clip void loadSettings( const QDomElement & _this ) override; inline QString nodeName() const override { - return "sampletco"; + return "sampleclip"; } SampleBuffer* sampleBuffer() @@ -71,7 +71,7 @@ public slots: void updateLength(); void toggleRecord(); void playbackPositionChanged(); - void updateTrackTcos(); + void updateTrackClips(); private: diff --git a/include/SampleClipView.h b/include/SampleClipView.h index 4652f50fa9d..c10c6c48040 100644 --- a/include/SampleClipView.h +++ b/include/SampleClipView.h @@ -35,7 +35,7 @@ class SampleClipView : public ClipView Q_OBJECT public: - SampleClipView( SampleClip * _tco, TrackView * _tv ); + SampleClipView( SampleClip * _clip, TrackView * _tv ); virtual ~SampleClipView() = default; public slots: @@ -55,7 +55,7 @@ public slots: private: - SampleClip * m_tco; + SampleClip * m_clip; QPixmap m_paintPixmap; bool splitClip( const TimePos pos ) override; } ; diff --git a/include/SamplePlayHandle.h b/include/SamplePlayHandle.h index 6b21a6c9368..367a9a25a27 100644 --- a/include/SamplePlayHandle.h +++ b/include/SamplePlayHandle.h @@ -41,7 +41,7 @@ class SamplePlayHandle : public PlayHandle public: SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort = true ); SamplePlayHandle( const QString& sampleFile ); - SamplePlayHandle( SampleClip* tco ); + SamplePlayHandle( SampleClip* clip ); virtual ~SamplePlayHandle(); inline bool affinityMatters() const override diff --git a/include/SampleRecordHandle.h b/include/SampleRecordHandle.h index 8e1c40d1041..3921b19765a 100644 --- a/include/SampleRecordHandle.h +++ b/include/SampleRecordHandle.h @@ -41,7 +41,7 @@ class Track; class SampleRecordHandle : public PlayHandle { public: - SampleRecordHandle( SampleClip* tco ); + SampleRecordHandle( SampleClip* clip ); virtual ~SampleRecordHandle(); void play( sampleFrame * _working_buffer ) override; @@ -64,7 +64,7 @@ class SampleRecordHandle : public PlayHandle Track * m_track; BBTrack * m_bbTrack; - SampleClip * m_tco; + SampleClip * m_clip; } ; diff --git a/include/SampleTrack.h b/include/SampleTrack.h index 5f0541c7e01..19440081f83 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -43,7 +43,7 @@ class SampleTrack : public Track virtual ~SampleTrack(); virtual bool play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _frame_base, int _tco_num = -1 ) override; + const f_cnt_t _frame_base, int _clip_num = -1 ) override; TrackView * createView( TrackContainerView* tcv ) override; Clip* createClip(const TimePos & pos) override; @@ -82,8 +82,8 @@ class SampleTrack : public Track void playingChanged(); public slots: - void updateTcos(); - void setPlayingTcos( bool isPlaying ); + void updateClips(); + void setPlayingClips( bool isPlaying ); void updateEffectChannel(); private: diff --git a/include/Song.h b/include/Song.h index 08f31a2bb05..d05c4391001 100644 --- a/include/Song.h +++ b/include/Song.h @@ -280,7 +280,7 @@ class LMMS_EXPORT Song : public TrackContainer } //TODO: Add Q_DECL_OVERRIDE when Qt4 is dropped - AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum = -1) const override; + AutomatedValueMap automatedValuesAt(TimePos time, int clipNum = -1) const override; // file management void createNewProject(); diff --git a/include/SongEditor.h b/include/SongEditor.h index 6c5f9eb6e6d..41b732dddc8 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -84,7 +84,7 @@ public slots: void updatePosition( const TimePos & t ); void updatePositionLine(); - void selectAllTcos( bool select ); + void selectAllClips( bool select ); protected: void closeEvent( QCloseEvent * ce ) override; diff --git a/include/Track.h b/include/Track.h index f94da5c5048..70a6a82bc3c 100644 --- a/include/Track.h +++ b/include/Track.h @@ -60,7 +60,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: - typedef QVector tcoVector; + typedef QVector clipVector; enum TrackTypes { @@ -90,7 +90,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject } virtual bool play( const TimePos & start, const fpp_t frames, - const f_cnt_t frameBase, int tcoNum = -1 ) = 0; + const f_cnt_t frameBase, int clipNum = -1 ) = 0; virtual TrackView * createView( TrackContainerView * view ) = 0; @@ -110,22 +110,22 @@ class LMMS_EXPORT Track : public Model, public JournallingObject } // -- for usage by Clip only --------------- - Clip * addClip( Clip * tco ); - void removeClip( Clip * tco ); + Clip * addClip( Clip * clip ); + void removeClip( Clip * clip ); // ------------------------------------------------------- void deleteClips(); int numOfClips(); - Clip * getClip( int tcoNum ); - int getClipNum(const Clip* tco ); + Clip * getClip( int clipNum ); + int getClipNum(const Clip* clip ); - const tcoVector & getClips() const + const clipVector & getClips() const { return m_trackContentObjects; } - void getClipsInRange( tcoVector & tcoV, const TimePos & start, + void getClipsInRange( clipVector & clipV, const TimePos & start, const TimePos & end ); - void swapPositionOfClips( int tcoNum1, int tcoNum2 ); + void swapPositionOfClips( int clipNum1, int clipNum2 ); void createClipsForBB( int bb ); @@ -215,7 +215,7 @@ public slots: bool m_simpleSerializingMode; - tcoVector m_trackContentObjects; + clipVector m_trackContentObjects; QMutex m_processingLock; diff --git a/include/TrackContainer.h b/include/TrackContainer.h index 00b391e102d..06d2d0a056e 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -93,13 +93,13 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject return m_TrackContainerType; } - virtual AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum = -1) const; + virtual AutomatedValueMap automatedValuesAt(TimePos time, int clipNum = -1) const; signals: void trackAdded( Track * _track ); protected: - static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int tcoNum = -1); + static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int clipNum = -1); mutable QReadWriteLock m_tracksMutex; diff --git a/include/TrackContentWidget.h b/include/TrackContentWidget.h index aefbbc4e502..d3bf60488f0 100644 --- a/include/TrackContentWidget.h +++ b/include/TrackContentWidget.h @@ -55,20 +55,20 @@ class TrackContentWidget : public QWidget, public JournallingObject /*! \brief Updates the background tile pixmap. */ void updateBackground(); - void addClipView( ClipView * tcov ); - void removeClipView( ClipView * tcov ); - void removeClipView( int tcoNum ) + void addClipView( ClipView * clipv ); + void removeClipView( ClipView * clipv ); + void removeClipView( int clipNum ) { - if( tcoNum >= 0 && tcoNum < m_tcoViews.size() ) + if( clipNum >= 0 && clipNum < m_clipViews.size() ) { - removeClipView( m_tcoViews[tcoNum] ); + removeClipView( m_clipViews[clipNum] ); } } - bool canPasteSelection( TimePos tcoPos, const QDropEvent *de ); - bool canPasteSelection( TimePos tcoPos, const QMimeData *md, bool allowSameBar = false ); - bool pasteSelection( TimePos tcoPos, QDropEvent * de ); - bool pasteSelection( TimePos tcoPos, const QMimeData * md, bool skipSafetyCheck = false ); + bool canPasteSelection( TimePos clipPos, const QDropEvent *de ); + bool canPasteSelection( TimePos clipPos, const QMimeData *md, bool allowSameBar = false ); + bool pasteSelection( TimePos clipPos, QDropEvent * de ); + bool pasteSelection( TimePos clipPos, const QMimeData * md, bool skipSafetyCheck = false ); TimePos endPosition( const TimePos & posStart ); @@ -126,8 +126,8 @@ public slots: TrackView * m_trackView; - typedef QVector tcoViewVector; - tcoViewVector m_tcoViews; + typedef QVector clipViewVector; + clipViewVector m_clipViews; QPixmap m_background; diff --git a/include/TrackView.h b/include/TrackView.h index 7e114cd6090..9c8973b71eb 100644 --- a/include/TrackView.h +++ b/include/TrackView.h @@ -163,7 +163,7 @@ public slots: private slots: - void createClipView( Clip * tco ); + void createClipView( Clip * clip ); void muteChanged(); } ; diff --git a/plugins/HydrogenImport/HydrogenImport.cpp b/plugins/HydrogenImport/HydrogenImport.cpp index 72b5dd7aa94..0bb07289f8f 100644 --- a/plugins/HydrogenImport/HydrogenImport.cpp +++ b/plugins/HydrogenImport/HydrogenImport.cpp @@ -280,7 +280,7 @@ bool HydrogenImport::readSong() QString instrId = LocalFileMng::readXmlString( noteNode, "instrument", 0,false, false ); int i = pattern_count - 1 + nbb; pattern_id[sName] = pattern_count - 1; - Pattern*p = dynamic_cast( drum_track[instrId]->getTCO( i ) ); + Pattern*p = dynamic_cast( drum_track[instrId]->getClip( i ) ); Note n; n.setPos( nPosition ); if ( (nPosition + 48) <= nSize ) @@ -316,7 +316,7 @@ bool HydrogenImport::readSong() int i = pattern_id[patId]+song_num_tracks; Track *t = ( BBTrack * ) s->tracks().at( i ); - t->createTCO(pos); + t->createClip(pos); if ( pattern_length[patId] > best_length ) { diff --git a/plugins/MidiExport/MidiExport.cpp b/plugins/MidiExport/MidiExport.cpp index b29755a1463..df95b5ff881 100644 --- a/plugins/MidiExport/MidiExport.cpp +++ b/plugins/MidiExport/MidiExport.cpp @@ -160,7 +160,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { - if (n.nodeName() == "bbtco") + if (n.nodeName() == "bbclip") { QDomElement it = n.toElement(); int pos = it.attribute("pos", "0").toInt(); @@ -215,7 +215,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, MidiNoteVector nv, pat; writePattern(pat, n, base_pitch, base_volume, 0); - // workaround for nested BBTCOs + // workaround for nested BBClips int pos = 0; int len = n.toElement().attribute("steps", "1").toInt() * 12; for (auto it = plist.begin(); it != plist.end(); ++it) diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index a2b877394a2..93bea56e75b 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -193,7 +193,7 @@ class smfMidiCC { TimePos pPos = TimePos( time.getBar(), 0 ); ap = dynamic_cast( - at->createTCO(pPos)); + at->createClip(pPos)); ap->addObject( objModel ); } @@ -259,7 +259,7 @@ class smfMidiChannel it->pitchRangeModel()->setInitValue( 2 ); // Create a default pattern - p = dynamic_cast(it->createTCO(0)); + p = dynamic_cast(it->createClip(0)); } return this; } @@ -269,7 +269,7 @@ class smfMidiChannel { if (!p) { - p = dynamic_cast(it->createTCO(0)); + p = dynamic_cast(it->createClip(0)); } p->addNote(n, false); hasNotes = true; @@ -286,7 +286,7 @@ class smfMidiChannel if (!newPattern || n->pos() > lastEnd + DefaultTicksPerBar) { TimePos pPos = TimePos(n->pos().getBar(), 0); - newPattern = dynamic_cast(it->createTCO(pPos)); + newPattern = dynamic_cast(it->createClip(pPos)); } lastEnd = n->pos() + n->length(); diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index a2b831d0793..f010e3e26ed 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -42,7 +42,7 @@ const float AutomationPattern::DEFAULT_MAX_VALUE = 1; AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : - TrackContentObject( _auto_track ), + Clip( _auto_track ), m_patternMutex(QMutex::Recursive), m_autoTrack( _auto_track ), m_objects(), @@ -74,7 +74,7 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : - TrackContentObject( _pat_to_copy.m_autoTrack ), + Clip( _pat_to_copy.m_autoTrack ), m_patternMutex(QMutex::Recursive), m_autoTrack( _pat_to_copy.m_autoTrack ), m_objects( _pat_to_copy.m_objects ), @@ -205,7 +205,7 @@ TimePos AutomationPattern::timeMapLength() const timeMap::const_iterator it = m_timeMap.end(); tick_t last_tick = static_cast(POS(it - 1)); // if last_tick is 0 (single item at tick 0) - // return length as a whole bar to prevent disappearing TCO + // return length as a whole bar to prevent disappearing Clip if (last_tick == 0) { return one_bar; } return TimePos(last_tick); @@ -855,9 +855,9 @@ const QString AutomationPattern::name() const { QMutexLocker m(&m_patternMutex); - if( !TrackContentObject::name().isEmpty() ) + if( !Clip::name().isEmpty() ) { - return TrackContentObject::name(); + return Clip::name(); } if( !m_objects.isEmpty() && m_objects.first() != NULL ) { @@ -869,7 +869,7 @@ const QString AutomationPattern::name() const -TrackContentObjectView * AutomationPattern::createView( TrackView * _tv ) +ClipView * AutomationPattern::createView( TrackView * _tv ) { QMutexLocker m(&m_patternMutex); @@ -892,8 +892,8 @@ bool AutomationPattern::isAutomated( const AutomatableModel * _m ) if( ( *it )->type() == Track::AutomationTrack || ( *it )->type() == Track::HiddenAutomationTrack ) { - const Track::tcoVector & v = ( *it )->getTCOs(); - for( Track::tcoVector::ConstIterator j = v.begin(); j != v.end(); ++j ) + const Track::clipVector & v = ( *it )->getClips(); + for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) { const AutomationPattern * a = dynamic_cast( *j ); if( a && a->hasAutomation() ) @@ -933,9 +933,9 @@ QVector AutomationPattern::patternsForModel( const Automata ( *it )->type() == Track::HiddenAutomationTrack ) { // get patterns in those tracks.... - const Track::tcoVector & v = ( *it )->getTCOs(); + const Track::clipVector & v = ( *it )->getClips(); // go through all the patterns... - for( Track::tcoVector::ConstIterator j = v.begin(); j != v.end(); ++j ) + for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) { AutomationPattern * a = dynamic_cast( *j ); // check that the pattern has automation @@ -966,8 +966,8 @@ AutomationPattern * AutomationPattern::globalAutomationPattern( AutomatableModel * _m ) { AutomationTrack * t = Engine::getSong()->globalAutomationTrack(); - Track::tcoVector v = t->getTCOs(); - for( Track::tcoVector::const_iterator j = v.begin(); j != v.end(); ++j ) + Track::clipVector v = t->getClips(); + for( Track::clipVector::const_iterator j = v.begin(); j != v.end(); ++j ) { AutomationPattern * a = dynamic_cast( *j ); if( a ) @@ -1002,8 +1002,8 @@ void AutomationPattern::resolveAllIDs() if( ( *it )->type() == Track::AutomationTrack || ( *it )->type() == Track::HiddenAutomationTrack ) { - Track::tcoVector v = ( *it )->getTCOs(); - for( Track::tcoVector::iterator j = v.begin(); + Track::clipVector v = ( *it )->getClips(); + for( Track::clipVector::iterator j = v.begin(); j != v.end(); ++j ) { AutomationPattern * a = dynamic_cast( *j ); diff --git a/src/core/BBTCO.cpp b/src/core/BBClip.cpp similarity index 86% rename from src/core/BBTCO.cpp rename to src/core/BBClip.cpp index f6e760ca05c..0dcf60349e4 100644 --- a/src/core/BBTCO.cpp +++ b/src/core/BBClip.cpp @@ -1,5 +1,5 @@ /* - * BBTCO.cpp - implementation of class bbTCO + * BBClip.cpp - implementation of class bbClip * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -22,7 +22,7 @@ * */ - #include "BBTCO.h" + #include "BBClip.h" #include @@ -31,8 +31,8 @@ #include "Engine.h" -BBTCO::BBTCO( Track * _track ) : - TrackContentObject( _track ) +BBClip::BBClip( Track * _track ) : + Clip( _track ) { bar_t t = Engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() ); if( t > 0 ) @@ -44,7 +44,7 @@ BBTCO::BBTCO( Track * _track ) : setAutoResize( false ); } -void BBTCO::saveSettings( QDomDocument & doc, QDomElement & element ) +void BBClip::saveSettings( QDomDocument & doc, QDomElement & element ) { element.setAttribute( "name", name() ); if( element.parentNode().nodeName() == "clipboard" ) @@ -66,7 +66,7 @@ void BBTCO::saveSettings( QDomDocument & doc, QDomElement & element ) -void BBTCO::loadSettings( const QDomElement & element ) +void BBClip::loadSettings( const QDomElement & element ) { setName( element.attribute( "name" ) ); if( element.attribute( "pos" ).toInt() >= 0 ) @@ -98,14 +98,14 @@ void BBTCO::loadSettings( const QDomElement & element ) -int BBTCO::bbTrackIndex() +int BBClip::bbTrackIndex() { return dynamic_cast( getTrack() )->index(); } -TrackContentObjectView * BBTCO::createView( TrackView * _tv ) +ClipView * BBClip::createView( TrackView * _tv ) { - return new BBTCOView( this, _tv ); + return new BBClipView( this, _tv ); } \ No newline at end of file diff --git a/src/core/BBTrackContainer.cpp b/src/core/BBTrackContainer.cpp index f818684ec4e..32ff54f2c9e 100644 --- a/src/core/BBTrackContainer.cpp +++ b/src/core/BBTrackContainer.cpp @@ -53,21 +53,21 @@ BBTrackContainer::~BBTrackContainer() -bool BBTrackContainer::play(TimePos start, fpp_t frames, f_cnt_t offset, int tcoNum) +bool BBTrackContainer::play(TimePos start, fpp_t frames, f_cnt_t offset, int clipNum) { bool notePlayed = false; - if (lengthOfBB(tcoNum) <= 0) + if (lengthOfBB(clipNum) <= 0) { return false; } - start = start % (lengthOfBB(tcoNum) * TimePos::ticksPerBar()); + start = start % (lengthOfBB(clipNum) * TimePos::ticksPerBar()); TrackList tl = tracks(); for (Track * t : tl) { - if (t->play(start, frames, offset, tcoNum)) + if (t->play(start, frames, offset, clipNum)) { notePlayed = true; } @@ -97,10 +97,10 @@ bar_t BBTrackContainer::lengthOfBB(int bb) const const TrackList & tl = tracks(); for (Track * t : tl) { - // Don't create TCOs here if they don't exist - if (bb < t->numOfTCOs()) + // Don't create Clips here if they don't exist + if (bb < t->numOfClips()) { - maxLength = qMax(maxLength, t->getTCO(bb)->length()); + maxLength = qMax(maxLength, t->getClip(bb)->length()); } } @@ -123,7 +123,7 @@ void BBTrackContainer::removeBB(int bb) TrackList tl = tracks(); for (Track * t : tl) { - delete t->getTCO(bb); + delete t->getClip(bb); t->removeBar(bb * DefaultTicksPerBar); } if (bb <= currentBB()) @@ -140,7 +140,7 @@ void BBTrackContainer::swapBB(int bb1, int bb2) TrackList tl = tracks(); for (Track * t : tl) { - t->swapPositionOfTCOs(bb1, bb2); + t->swapPositionOfClips(bb1, bb2); } updateComboBox(); } @@ -148,9 +148,9 @@ void BBTrackContainer::swapBB(int bb1, int bb2) -void BBTrackContainer::updateBBTrack(TrackContentObject * tco) +void BBTrackContainer::updateBBTrack(Clip * clip) { - BBTrack * t = BBTrack::findBBTrack(tco->startPosition() / DefaultTicksPerBar); + BBTrack * t = BBTrack::findBBTrack(clip->startPosition() / DefaultTicksPerBar); if (t != NULL) { t->dataChanged(); @@ -167,7 +167,7 @@ void BBTrackContainer::fixIncorrectPositions() { for (int i = 0; i < numOfBBs(); ++i) { - t->getTCO(i)->movePosition(TimePos(i, 0)); + t->getClip(i)->movePosition(TimePos(i, 0)); } } } @@ -231,27 +231,27 @@ void BBTrackContainer::currentBBChanged() -void BBTrackContainer::createTCOsForBB(int bb) +void BBTrackContainer::createClipsForBB(int bb) { TrackList tl = tracks(); for (Track * t : tl) { - t->createTCOsForBB(bb); + t->createClipsForBB(bb); } } -AutomatedValueMap BBTrackContainer::automatedValuesAt(TimePos time, int tcoNum) const +AutomatedValueMap BBTrackContainer::automatedValuesAt(TimePos time, int clipNum) const { - Q_ASSERT(tcoNum >= 0); + Q_ASSERT(clipNum >= 0); Q_ASSERT(time.getTicks() >= 0); - auto lengthBars = lengthOfBB(tcoNum); + auto lengthBars = lengthOfBB(clipNum); auto lengthTicks = lengthBars * TimePos::ticksPerBar(); if (time > lengthTicks) { time = lengthTicks; } - return TrackContainer::automatedValuesAt(time + (TimePos::ticksPerBar() * tcoNum), tcoNum); + return TrackContainer::automatedValuesAt(time + (TimePos::ticksPerBar() * clipNum), clipNum); } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c211d48a7c2..e41cd830369 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -6,7 +6,7 @@ set(LMMS_SRCS core/AutomationNode.cpp core/BandLimitedWave.cpp core/base64.cpp - core/BBTCO.cpp + core/BBClip.cpp core/BBTrackContainer.cpp core/BufferManager.cpp core/Clipboard.cpp @@ -66,7 +66,7 @@ set(LMMS_SRCS core/SampleBuffer.cpp core/SamplePlayHandle.cpp core/SampleRecordHandle.cpp - core/SampleTCO.cpp + core/SampleClip.cpp core/SerializingObject.cpp core/Song.cpp core/TempoSyncKnobModel.cpp @@ -74,7 +74,7 @@ set(LMMS_SRCS core/ToolPlugin.cpp core/Track.cpp core/TrackContainer.cpp - core/TrackContentObject.cpp + core/Clip.cpp core/ValueBuffer.cpp core/VstSyncController.cpp core/StepRecorder.cpp diff --git a/src/core/TrackContentObject.cpp b/src/core/Clip.cpp similarity index 72% rename from src/core/TrackContentObject.cpp rename to src/core/Clip.cpp index ad41fd11099..ec7a8bfc891 100644 --- a/src/core/TrackContentObject.cpp +++ b/src/core/Clip.cpp @@ -1,5 +1,5 @@ /* - * TrackContentObject.cpp - implementation of TrackContentObject class + * Clip.cpp - implementation of Clip class * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -22,7 +22,7 @@ * */ -#include "TrackContentObject.h" +#include "Clip.h" #include @@ -33,13 +33,13 @@ #include "Song.h" -/*! \brief Create a new TrackContentObject +/*! \brief Create a new Clip * * Creates a new track content object for the given track. * * \param _track The track that will contain the new object */ -TrackContentObject::TrackContentObject( Track * track ) : +Clip::Clip( Track * track ) : Model( track ), m_track( track ), m_startPosition(), @@ -51,7 +51,7 @@ TrackContentObject::TrackContentObject( Track * track ) : { if( getTrack() ) { - getTrack()->addTCO( this ); + getTrack()->addClip( this ); } setJournalling( false ); movePosition( 0 ); @@ -62,32 +62,32 @@ TrackContentObject::TrackContentObject( Track * track ) : -/*! \brief Destroy a TrackContentObject +/*! \brief Destroy a Clip * * Destroys the given track content object. * */ -TrackContentObject::~TrackContentObject() +Clip::~Clip() { - emit destroyedTCO(); + emit destroyedClip(); if( getTrack() ) { - getTrack()->removeTCO( this ); + getTrack()->removeClip( this ); } } -/*! \brief Move this TrackContentObject's position in time +/*! \brief Move this Clip's position in time * * If the track content object has moved, update its position. We * also add a journal entry for undo and update the display. * * \param _pos The new position of the track content object. */ -void TrackContentObject::movePosition( const TimePos & pos ) +void Clip::movePosition( const TimePos & pos ) { TimePos newPos = qMax(0, pos.getTicks()); if (m_startPosition != newPos) @@ -103,14 +103,14 @@ void TrackContentObject::movePosition( const TimePos & pos ) -/*! \brief Change the length of this TrackContentObject +/*! \brief Change the length of this Clip * * If the track content object's length has changed, update it. We * also add a journal entry for undo and update the display. * * \param _length The new length of the track content object. */ -void TrackContentObject::changeLength( const TimePos & length ) +void Clip::changeLength( const TimePos & length ) { m_length = length; Engine::getSong()->updateLength(); @@ -120,7 +120,7 @@ void TrackContentObject::changeLength( const TimePos & length ) -bool TrackContentObject::comparePosition(const TrackContentObject *a, const TrackContentObject *b) +bool Clip::comparePosition(const Clip *a, const Clip *b) { return a->startPosition() < b->startPosition(); } @@ -128,11 +128,11 @@ bool TrackContentObject::comparePosition(const TrackContentObject *a, const Trac -/*! \brief Copies the state of a TrackContentObject to another TrackContentObject +/*! \brief Copies the state of a Clip to another Clip * - * This method copies the state of a TCO to another TCO + * This method copies the state of a Clip to another Clip */ -void TrackContentObject::copyStateTo( TrackContentObject *src, TrackContentObject *dst ) +void Clip::copyStateTo( Clip *src, Clip *dst ) { // If the node names match we copy the state if( src->nodeName() == dst->nodeName() ){ @@ -152,7 +152,7 @@ void TrackContentObject::copyStateTo( TrackContentObject *src, TrackContentObjec -/*! \brief Mutes this TrackContentObject +/*! \brief Mutes this Clip * * Restore the previous state of this track content object. This will * restore the position or the length of the track content object @@ -160,7 +160,7 @@ void TrackContentObject::copyStateTo( TrackContentObject *src, TrackContentObjec * * \param _je The journal entry to undo */ -void TrackContentObject::toggleMute() +void Clip::toggleMute() { m_mutedModel.setValue( !m_mutedModel.value() ); emit dataChanged(); @@ -169,7 +169,7 @@ void TrackContentObject::toggleMute() -TimePos TrackContentObject::startTimeOffset() const +TimePos Clip::startTimeOffset() const { return m_startTimeOffset; } @@ -177,13 +177,13 @@ TimePos TrackContentObject::startTimeOffset() const -void TrackContentObject::setStartTimeOffset( const TimePos &startTimeOffset ) +void Clip::setStartTimeOffset( const TimePos &startTimeOffset ) { m_startTimeOffset = startTimeOffset; } -// Update TCO color if it follows the track color -void TrackContentObject::updateColor() +// Update Clip color if it follows the track color +void Clip::updateColor() { if( ! m_useCustomClipColor ) { @@ -192,14 +192,14 @@ void TrackContentObject::updateColor() } -void TrackContentObject::useCustomClipColor( bool b ) +void Clip::useCustomClipColor( bool b ) { m_useCustomClipColor = b; updateColor(); } -bool TrackContentObject::hasColor() +bool Clip::hasColor() { return usesCustomClipColor() || getTrack()->useColor(); } diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 1ca63eb92a5..898903ebe09 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -54,7 +54,7 @@ static void findIds(const QDomElement& elem, QList& idList); // QMap with the DOM elements that access file resources const DataFile::ResourcesMap DataFile::ELEMENTS_WITH_RESOURCES = { -{ "sampletco", {"src"} }, +{ "sampleclip", {"src"} }, { "audiofileprocessor", {"src"} }, }; @@ -911,7 +911,7 @@ void DataFile::upgrade_0_4_0_20080409() { // Upgrade to version 0.4.0-20080409 from some version greater than or equal to 0.4.0-20080129 QStringList s; - s << "note" << "pattern" << "bbtco" << "sampletco" << "time"; + s << "note" << "pattern" << "bbclip" << "sampleclip" << "time"; for( QStringList::iterator it = s.begin(); it < s.end(); ++it ) { QDomNodeList list = elementsByTagName( *it ); @@ -1621,7 +1621,7 @@ void DataFile::upgrade_noHiddenClipNames() QDomNodeList instClips = track.elementsByTagName("pattern"); QDomNodeList autoClips = track.elementsByTagName("automationpattern"); - QDomNodeList bbClips = track.elementsByTagName("bbtco"); + QDomNodeList bbClips = track.elementsByTagName("bbclip"); clearDefaultNames(instClips, trackName); clearDefaultNames(autoClips, trackName); diff --git a/src/core/SampleTCO.cpp b/src/core/SampleClip.cpp similarity index 79% rename from src/core/SampleTCO.cpp rename to src/core/SampleClip.cpp index 888fb3cb9b9..4922cafbb4d 100644 --- a/src/core/SampleTCO.cpp +++ b/src/core/SampleClip.cpp @@ -1,5 +1,5 @@ /* - * SampleTCO.cpp + * SampleClip.cpp * * Copyright (c) 2005-2014 Tobias Doerffel * @@ -22,15 +22,15 @@ * */ -#include "SampleTCO.h" +#include "SampleClip.h" #include -#include "SampleTCOView.h" +#include "SampleClipView.h" #include "TimeLineWidget.h" -SampleTCO::SampleTCO( Track * _track ) : - TrackContentObject( _track ), +SampleClip::SampleClip( Track * _track ) : + Clip( _track ), m_sampleBuffer( new SampleBuffer ), m_isPlaying( false ) { @@ -39,7 +39,7 @@ SampleTCO::SampleTCO( Track * _track ) : restoreJournallingState(); // we need to receive bpm-change-events, because then we have to - // change length of this TCO + // change length of this Clip connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), this, SLOT( updateLength() ), Qt::DirectConnection ); connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int,int ) ), @@ -57,13 +57,13 @@ SampleTCO::SampleTCO( Track * _track ) : //care about loops connect( Engine::getSong(), SIGNAL( updateSampleTracks() ), this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); - //care about mute TCOs + //care about mute Clips connect( this, SIGNAL( dataChanged() ), this, SLOT( playbackPositionChanged() ) ); //care about mute track connect( getTrack()->getMutedModel(), SIGNAL( dataChanged() ), this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); - //care about TCO position - connect( this, SIGNAL( positionChanged() ), this, SLOT( updateTrackTcos() ) ); + //care about Clip position + connect( this, SIGNAL( positionChanged() ), this, SLOT( updateTrackClips() ) ); switch( getTrack()->trackContainer()->type() ) { @@ -77,13 +77,13 @@ SampleTCO::SampleTCO( Track * _track ) : setAutoResize( false ); break; } - updateTrackTcos(); + updateTrackClips(); } -SampleTCO::SampleTCO(const SampleTCO& orig) : - SampleTCO(orig.getTrack()) +SampleClip::SampleClip(const SampleClip& orig) : + SampleClip(orig.getTrack()) { - // TODO: This creates a new SampleBuffer for the new TCO, eating up memory + // TODO: This creates a new SampleBuffer for the new Clip, eating up memory // & eventually causing performance issues. Letting tracks share buffers // when they're identical would fix this, but isn't possible right now. *m_sampleBuffer = *orig.m_sampleBuffer; @@ -93,12 +93,12 @@ SampleTCO::SampleTCO(const SampleTCO& orig) : -SampleTCO::~SampleTCO() +SampleClip::~SampleClip() { SampleTrack * sampletrack = dynamic_cast( getTrack() ); if ( sampletrack ) { - sampletrack->updateTcos(); + sampletrack->updateClips(); } Engine::mixer()->requestChangeInModel(); sharedObject::unref( m_sampleBuffer ); @@ -108,22 +108,22 @@ SampleTCO::~SampleTCO() -void SampleTCO::changeLength( const TimePos & _length ) +void SampleClip::changeLength( const TimePos & _length ) { - TrackContentObject::changeLength( qMax( static_cast( _length ), 1 ) ); + Clip::changeLength( qMax( static_cast( _length ), 1 ) ); } -const QString & SampleTCO::sampleFile() const +const QString & SampleClip::sampleFile() const { return m_sampleBuffer->audioFile(); } -void SampleTCO::setSampleBuffer( SampleBuffer* sb ) +void SampleClip::setSampleBuffer( SampleBuffer* sb ) { Engine::mixer()->requestChangeInModel(); sharedObject::unref( m_sampleBuffer ); @@ -136,7 +136,7 @@ void SampleTCO::setSampleBuffer( SampleBuffer* sb ) -void SampleTCO::setSampleFile( const QString & _sf ) +void SampleClip::setSampleFile( const QString & _sf ) { int length; if ( _sf.isEmpty() ) @@ -161,7 +161,7 @@ void SampleTCO::setSampleFile( const QString & _sf ) -void SampleTCO::toggleRecord() +void SampleClip::toggleRecord() { m_recordModel.setValue( !m_recordModel.value() ); emit dataChanged(); @@ -170,29 +170,29 @@ void SampleTCO::toggleRecord() -void SampleTCO::playbackPositionChanged() +void SampleClip::playbackPositionChanged() { Engine::mixer()->removePlayHandlesOfTypes( getTrack(), PlayHandle::TypeSamplePlayHandle ); SampleTrack * st = dynamic_cast( getTrack() ); - st->setPlayingTcos( false ); + st->setPlayingClips( false ); } -void SampleTCO::updateTrackTcos() +void SampleClip::updateTrackClips() { SampleTrack * sampletrack = dynamic_cast( getTrack() ); if( sampletrack) { - sampletrack->updateTcos(); + sampletrack->updateClips(); } } -bool SampleTCO::isPlaying() const +bool SampleClip::isPlaying() const { return m_isPlaying; } @@ -200,7 +200,7 @@ bool SampleTCO::isPlaying() const -void SampleTCO::setIsPlaying(bool isPlaying) +void SampleClip::setIsPlaying(bool isPlaying) { m_isPlaying = isPlaying; } @@ -208,7 +208,7 @@ void SampleTCO::setIsPlaying(bool isPlaying) -void SampleTCO::updateLength() +void SampleClip::updateLength() { emit sampleChanged(); } @@ -216,7 +216,7 @@ void SampleTCO::updateLength() -TimePos SampleTCO::sampleLength() const +TimePos SampleClip::sampleLength() const { return (int)( m_sampleBuffer->frames() / Engine::framesPerTick() ); } @@ -224,7 +224,7 @@ TimePos SampleTCO::sampleLength() const -void SampleTCO::setSampleStartFrame(f_cnt_t startFrame) +void SampleClip::setSampleStartFrame(f_cnt_t startFrame) { m_sampleBuffer->setStartFrame( startFrame ); } @@ -232,7 +232,7 @@ void SampleTCO::setSampleStartFrame(f_cnt_t startFrame) -void SampleTCO::setSamplePlayLength(f_cnt_t length) +void SampleClip::setSamplePlayLength(f_cnt_t length) { m_sampleBuffer->setEndFrame( length ); } @@ -240,7 +240,7 @@ void SampleTCO::setSamplePlayLength(f_cnt_t length) -void SampleTCO::saveSettings( QDomDocument & _doc, QDomElement & _this ) +void SampleClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) { if( _this.parentNode().nodeName() == "clipboard" ) { @@ -275,7 +275,7 @@ void SampleTCO::saveSettings( QDomDocument & _doc, QDomElement & _this ) -void SampleTCO::loadSettings( const QDomElement & _this ) +void SampleClip::loadSettings( const QDomElement & _this ) { if( _this.attribute( "pos" ).toInt() >= 0 ) { @@ -303,14 +303,14 @@ void SampleTCO::loadSettings( const QDomElement & _this ) if(_this.hasAttribute("reversed")) { m_sampleBuffer->setReversed(true); - emit wasReversed(); // tell SampleTCOView to update the view + emit wasReversed(); // tell SampleClipView to update the view } } -TrackContentObjectView * SampleTCO::createView( TrackView * _tv ) +ClipView * SampleClip::createView( TrackView * _tv ) { - return new SampleTCOView( this, _tv ); + return new SampleClipView( this, _tv ); } \ No newline at end of file diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index 018629357d4..d4108ee058a 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -28,7 +28,7 @@ #include "Engine.h" #include "InstrumentTrack.h" #include "Mixer.h" -#include "SampleTCO.h" +#include "SampleClip.h" @@ -61,11 +61,11 @@ SamplePlayHandle::SamplePlayHandle( const QString& sampleFile ) : -SamplePlayHandle::SamplePlayHandle( SampleTCO* tco ) : - SamplePlayHandle( tco->sampleBuffer() , false) +SamplePlayHandle::SamplePlayHandle( SampleClip* clip ) : + SamplePlayHandle( clip->sampleBuffer() , false) { - m_track = tco->getTrack(); - setAudioPort( ( (SampleTrack *)tco->getTrack() )->audioPort() ); + m_track = clip->getTrack(); + setAudioPort( ( (SampleTrack *)clip->getTrack() )->audioPort() ); } diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index c8f688a969a..c843f7bfbda 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -33,13 +33,13 @@ #include "debug.h" -SampleRecordHandle::SampleRecordHandle( SampleTCO* tco ) : +SampleRecordHandle::SampleRecordHandle( SampleClip* clip ) : PlayHandle( TypeSamplePlayHandle ), m_framesRecorded( 0 ), - m_minLength( tco->length() ), - m_track( tco->getTrack() ), + m_minLength( clip->length() ), + m_track( clip->getTrack() ), m_bbTrack( NULL ), - m_tco( tco ) + m_clip( clip ) { } @@ -52,7 +52,7 @@ SampleRecordHandle::~SampleRecordHandle() { SampleBuffer* sb; createSampleBuffer( &sb ); - m_tco->setSampleBuffer( sb ); + m_clip->setSampleBuffer( sb ); } while( !m_buffers.empty() ) @@ -60,7 +60,7 @@ SampleRecordHandle::~SampleRecordHandle() delete[] m_buffers.front().first; m_buffers.erase( m_buffers.begin() ); } - m_tco->setRecord( false ); + m_clip->setRecord( false ); } @@ -76,7 +76,7 @@ void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ ) TimePos len = (tick_t)( m_framesRecorded / Engine::framesPerTick() ); if( len > m_minLength ) { -// m_tco->changeLength( len ); +// m_clip->changeLength( len ); m_minLength = len; } } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 2800f829b17..0b8f17cd43c 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -228,7 +228,7 @@ void Song::processNextBuffer() case Mode_PlayPattern: if (m_patternToPlay) { - clipNum = m_patternToPlay->getTrack()->getTCONum(m_patternToPlay); + clipNum = m_patternToPlay->getTrack()->getClipNum(m_patternToPlay); trackList.push_back(m_patternToPlay->getTrack()); } break; @@ -360,7 +360,7 @@ void Song::processAutomations(const TrackList &tracklist, TimePos timeStart, fpp QSet recordedModels; TrackContainer* container = this; - int tcoNum = -1; + int clipNum = -1; switch (m_playMode) { @@ -373,28 +373,28 @@ void Song::processAutomations(const TrackList &tracklist, TimePos timeStart, fpp auto bbTrack = dynamic_cast(tracklist.at(0)); auto bbContainer = Engine::getBBTrackContainer(); container = bbContainer; - tcoNum = bbTrack->index(); + clipNum = bbTrack->index(); } break; default: return; } - values = container->automatedValuesAt(timeStart, tcoNum); + values = container->automatedValuesAt(timeStart, clipNum); TrackList tracks = container->tracks(); - Track::tcoVector tcos; + Track::clipVector clips; for (Track* track : tracks) { if (track->type() == Track::AutomationTrack) { - track->getTCOsInRange(tcos, 0, timeStart); + track->getClipsInRange(clips, 0, timeStart); } } // Process recording - for (TrackContentObject* tco : tcos) + for (Clip* clip : clips) { - auto p = dynamic_cast(tco); + auto p = dynamic_cast(clip); TimePos relTime = timeStart - p->startPosition(); if (p->isRecording() && relTime >= 0 && relTime < p->length()) { @@ -839,9 +839,9 @@ AutomationPattern * Song::tempoAutomationPattern() } -AutomatedValueMap Song::automatedValuesAt(TimePos time, int tcoNum) const +AutomatedValueMap Song::automatedValuesAt(TimePos time, int clipNum) const { - return TrackContainer::automatedValuesFromTracks(TrackList{m_globalAutomationTrack} << tracks(), time, tcoNum); + return TrackContainer::automatedValuesFromTracks(TrackList{m_globalAutomationTrack} << tracks(), time, clipNum); } @@ -1159,7 +1159,7 @@ void Song::loadProject( const QString & fileName ) node = node.nextSibling(); } - // quirk for fixing projects with broken positions of TCOs inside + // quirk for fixing projects with broken positions of Clips inside // BB-tracks Engine::getBBTrackContainer()->fixIncorrectPositions(); diff --git a/src/core/Track.cpp b/src/core/Track.cpp index a6111c06e82..7b621f727bb 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -76,7 +76,7 @@ Track::Track( TrackTypes type, TrackContainer * tc ) : * If the track container is a Beat+Bassline container, step through * its list of tracks and remove us. * - * Then delete the TrackContentObject's contents, remove this track from + * Then delete the Clip's contents, remove this track from * the track container. * * Finally step through this track's automation and forget all of them. @@ -124,7 +124,7 @@ Track * Track::create( TrackTypes tt, TrackContainer * tc ) if( tc == Engine::getBBTrackContainer() && t ) { - t->createTCOsForBB( Engine::getBBTrackContainer()->numOfBBs() + t->createClipsForBB( Engine::getBBTrackContainer()->numOfBBs() - 1 ); } @@ -228,8 +228,8 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element ) return; } - // now save settings of all TCO's - for( tcoVector::const_iterator it = m_trackContentObjects.begin(); + // now save settings of all Clip's + for( clipVector::const_iterator it = m_trackContentObjects.begin(); it != m_trackContentObjects.end(); ++it ) { ( *it )->saveState( doc, element ); @@ -242,7 +242,7 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element ) /*! \brief Load the settings from a file * * We load the track's type and muted state and solo state, then clear out our - * current TrackContentObject. + * current Clip. * * Then we step through the QDomElement's children and load the * track-specific settings and trackContentObjects states from it @@ -309,9 +309,9 @@ void Track::loadSettings( const QDomElement & element ) && node.nodeName() != "solo" && !node.toElement().attribute( "metadata" ).toInt() ) { - TrackContentObject * tco = createTCO( + Clip * clip = createClip( TimePos( 0 ) ); - tco->restoreState( node.toElement() ); + clip->restoreState( node.toElement() ); } } node = node.nextSibling(); @@ -327,31 +327,31 @@ void Track::loadSettings( const QDomElement & element ) -/*! \brief Add another TrackContentObject into this track +/*! \brief Add another Clip into this track * - * \param tco The TrackContentObject to attach to this track. + * \param clip The Clip to attach to this track. */ -TrackContentObject * Track::addTCO( TrackContentObject * tco ) +Clip * Track::addClip( Clip * clip ) { - m_trackContentObjects.push_back( tco ); + m_trackContentObjects.push_back( clip ); - emit trackContentObjectAdded( tco ); + emit trackContentObjectAdded( clip ); - return tco; // just for convenience + return clip; // just for convenience } -/*! \brief Remove a given TrackContentObject from this track +/*! \brief Remove a given Clip from this track * - * \param tco The TrackContentObject to remove from this track. + * \param clip The Clip to remove from this track. */ -void Track::removeTCO( TrackContentObject * tco ) +void Track::removeClip( Clip * clip ) { - tcoVector::iterator it = std::find( m_trackContentObjects.begin(), + clipVector::iterator it = std::find( m_trackContentObjects.begin(), m_trackContentObjects.end(), - tco ); + clip ); if( it != m_trackContentObjects.end() ) { m_trackContentObjects.erase( it ); @@ -364,8 +364,8 @@ void Track::removeTCO( TrackContentObject * tco ) } -/*! \brief Remove all TCOs from this track */ -void Track::deleteTCOs() +/*! \brief Remove all Clips from this track */ +void Track::deleteClips() { while( ! m_trackContentObjects.isEmpty() ) { @@ -378,7 +378,7 @@ void Track::deleteTCOs() * * \return the number of trackContentObjects we currently contain. */ -int Track::numOfTCOs() +int Track::numOfClips() { return m_trackContentObjects.size(); } @@ -386,53 +386,53 @@ int Track::numOfTCOs() -/*! \brief Get a TrackContentObject by number +/*! \brief Get a Clip by number * - * If the TCO number is less than our TCO array size then fetch that + * If the Clip number is less than our Clip array size then fetch that * numbered object from the array. Otherwise we warn the user that - * we've somehow requested a TCO that is too large, and create a new - * TCO for them. - * \param tcoNum The number of the TrackContentObject to fetch. - * \return the given TrackContentObject or a new one if out of range. - * \todo reject TCO numbers less than zero. - * \todo if we create a TCO here, should we somehow attach it to the + * we've somehow requested a Clip that is too large, and create a new + * Clip for them. + * \param clipNum The number of the Clip to fetch. + * \return the given Clip or a new one if out of range. + * \todo reject Clip numbers less than zero. + * \todo if we create a Clip here, should we somehow attach it to the * track? */ -TrackContentObject * Track::getTCO( int tcoNum ) +Clip * Track::getClip( int clipNum ) { - if( tcoNum < m_trackContentObjects.size() ) + if( clipNum < m_trackContentObjects.size() ) { - return m_trackContentObjects[tcoNum]; + return m_trackContentObjects[clipNum]; } - printf( "called Track::getTCO( %d ), " - "but TCO %d doesn't exist\n", tcoNum, tcoNum ); - return createTCO( tcoNum * TimePos::ticksPerBar() ); + printf( "called Track::getClip( %d ), " + "but Clip %d doesn't exist\n", clipNum, clipNum ); + return createClip( clipNum * TimePos::ticksPerBar() ); } -/*! \brief Determine the given TrackContentObject's number in our array. +/*! \brief Determine the given Clip's number in our array. * - * \param tco The TrackContentObject to search for. + * \param clip The Clip to search for. * \return its number in our array. */ -int Track::getTCONum( const TrackContentObject * tco ) +int Track::getClipNum( const Clip * clip ) { -// for( int i = 0; i < getTrackContentWidget()->numOfTCOs(); ++i ) - tcoVector::iterator it = std::find( m_trackContentObjects.begin(), +// for( int i = 0; i < getTrackContentWidget()->numOfClips(); ++i ) + clipVector::iterator it = std::find( m_trackContentObjects.begin(), m_trackContentObjects.end(), - tco ); + clip ); if( it != m_trackContentObjects.end() ) { -/* if( getTCO( i ) == _tco ) +/* if( getClip( i ) == _clip ) { return i; }*/ return it - m_trackContentObjects.begin(); } - qWarning( "Track::getTCONum(...) -> _tco not found!\n" ); + qWarning( "Track::getClipNum(...) -> _clip not found!\n" ); return 0; } @@ -444,25 +444,25 @@ int Track::getTCONum( const TrackContentObject * tco ) * Here we're interested in a range of trackContentObjects that intersect * the given time period. * - * We return the TCOs we find in order by time, earliest TCOs first. + * We return the Clips we find in order by time, earliest Clips first. * - * \param tcoV The list to contain the found trackContentObjects. + * \param clipV The list to contain the found trackContentObjects. * \param start The MIDI start time of the range. * \param end The MIDI endi time of the range. */ -void Track::getTCOsInRange( tcoVector & tcoV, const TimePos & start, +void Track::getClipsInRange( clipVector & clipV, const TimePos & start, const TimePos & end ) { - for( TrackContentObject* tco : m_trackContentObjects ) + for( Clip* clip : m_trackContentObjects ) { - int s = tco->startPosition(); - int e = tco->endPosition(); + int s = clip->startPosition(); + int e = clip->endPosition(); if( ( s <= end ) && ( e >= start ) ) { - // TCO is within given range - // Insert sorted by TCO's position - tcoV.insert(std::upper_bound(tcoV.begin(), tcoV.end(), tco, TrackContentObject::comparePosition), - tco); + // Clip is within given range + // Insert sorted by Clip's position + clipV.insert(std::upper_bound(clipV.begin(), clipV.end(), clip, Clip::comparePosition), + clip); } } } @@ -472,34 +472,34 @@ void Track::getTCOsInRange( tcoVector & tcoV, const TimePos & start, /*! \brief Swap the position of two trackContentObjects. * - * First, we arrange to swap the positions of the two TCOs in the + * First, we arrange to swap the positions of the two Clips in the * trackContentObjects list. Then we swap their start times as well. * - * \param tcoNum1 The first TrackContentObject to swap. - * \param tcoNum2 The second TrackContentObject to swap. + * \param clipNum1 The first Clip to swap. + * \param clipNum2 The second Clip to swap. */ -void Track::swapPositionOfTCOs( int tcoNum1, int tcoNum2 ) +void Track::swapPositionOfClips( int clipNum1, int clipNum2 ) { - qSwap( m_trackContentObjects[tcoNum1], - m_trackContentObjects[tcoNum2] ); + qSwap( m_trackContentObjects[clipNum1], + m_trackContentObjects[clipNum2] ); - const TimePos pos = m_trackContentObjects[tcoNum1]->startPosition(); + const TimePos pos = m_trackContentObjects[clipNum1]->startPosition(); - m_trackContentObjects[tcoNum1]->movePosition( - m_trackContentObjects[tcoNum2]->startPosition() ); - m_trackContentObjects[tcoNum2]->movePosition( pos ); + m_trackContentObjects[clipNum1]->movePosition( + m_trackContentObjects[clipNum2]->startPosition() ); + m_trackContentObjects[clipNum2]->movePosition( pos ); } -void Track::createTCOsForBB( int bb ) +void Track::createClipsForBB( int bb ) { - while( numOfTCOs() < bb + 1 ) + while( numOfClips() < bb + 1 ) { - TimePos position = TimePos( numOfTCOs(), 0 ); - TrackContentObject * tco = createTCO( position ); - tco->changeLength( TimePos( 1, 0 ) ); + TimePos position = TimePos( numOfClips(), 0 ); + Clip * clip = createClip( position ); + clip->changeLength( TimePos( 1, 0 ) ); } } @@ -510,14 +510,14 @@ void Track::createTCOsForBB( int bb ) * * \param pos The time at which we want to insert the bar. * \todo if we stepped through this list last to first, and the list was - * in ascending order by TCO time, once we hit a TCO that was earlier + * in ascending order by Clip time, once we hit a Clip that was earlier * than the insert time, we could fall out of the loop early. */ void Track::insertBar( const TimePos & pos ) { - // we'll increase the position of every TCO, positioned behind pos, by + // we'll increase the position of every Clip, positioned behind pos, by // one bar - for( tcoVector::iterator it = m_trackContentObjects.begin(); + for( clipVector::iterator it = m_trackContentObjects.begin(); it != m_trackContentObjects.end(); ++it ) { if( ( *it )->startPosition() >= pos ) @@ -537,9 +537,9 @@ void Track::insertBar( const TimePos & pos ) */ void Track::removeBar( const TimePos & pos ) { - // we'll decrease the position of every TCO, positioned behind pos, by + // we'll decrease the position of every Clip, positioned behind pos, by // one bar - for( tcoVector::iterator it = m_trackContentObjects.begin(); + for( clipVector::iterator it = m_trackContentObjects.begin(); it != m_trackContentObjects.end(); ++it ) { if( ( *it )->startPosition() >= pos ) @@ -554,7 +554,7 @@ void Track::removeBar( const TimePos & pos ) /*! \brief Return the length of the entire track in bars * - * We step through our list of TCOs and determine their end position, + * We step through our list of Clips and determine their end position, * keeping track of the latest time found in ticks. Then we return * that in bars by dividing by the number of ticks per bar. */ @@ -562,7 +562,7 @@ bar_t Track::length() const { // find last end-position tick_t last = 0; - for( tcoVector::const_iterator it = m_trackContentObjects.begin(); + for( clipVector::const_iterator it = m_trackContentObjects.begin(); it != m_trackContentObjects.end(); ++it ) { if( Engine::getSong()->isExporting() && @@ -649,7 +649,7 @@ void Track::toggleSolo() void Track::trackColorChanged( QColor & c ) { - for (int i = 0; i < numOfTCOs(); i++) + for (int i = 0; i < numOfClips(); i++) { m_trackContentObjects[i]->updateColor(); } @@ -659,7 +659,7 @@ void Track::trackColorChanged( QColor & c ) void Track::trackColorReset() { - for (int i = 0; i < numOfTCOs(); i++) + for (int i = 0; i < numOfClips(); i++) { m_trackContentObjects[i]->updateColor(); } diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index 84846a77ca3..906f1cf8457 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -238,7 +238,7 @@ bool TrackContainer::isEmpty() const for( TrackList::const_iterator it = m_tracks.begin(); it != m_tracks.end(); ++it ) { - if( !( *it )->getTCOs().isEmpty() ) + if( !( *it )->getClips().isEmpty() ) { return false; } @@ -248,15 +248,15 @@ bool TrackContainer::isEmpty() const -AutomatedValueMap TrackContainer::automatedValuesAt(TimePos time, int tcoNum) const +AutomatedValueMap TrackContainer::automatedValuesAt(TimePos time, int clipNum) const { - return automatedValuesFromTracks(tracks(), time, tcoNum); + return automatedValuesFromTracks(tracks(), time, clipNum); } -AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tracks, TimePos time, int tcoNum) +AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tracks, TimePos time, int clipNum) { - Track::tcoVector tcos; + Track::clipVector clips; for (Track* track: tracks) { @@ -269,11 +269,11 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra case Track::AutomationTrack: case Track::HiddenAutomationTrack: case Track::BBTrack: - if (tcoNum < 0) { - track->getTCOsInRange(tcos, 0, time); + if (clipNum < 0) { + track->getClipsInRange(clips, 0, time); } else { - Q_ASSERT(track->numOfTCOs() > tcoNum); - tcos << track->getTCO(tcoNum); + Q_ASSERT(track->numOfClips() > clipNum); + clips << track->getClip(clipNum); } default: break; @@ -282,15 +282,15 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra AutomatedValueMap valueMap; - Q_ASSERT(std::is_sorted(tcos.begin(), tcos.end(), TrackContentObject::comparePosition)); + Q_ASSERT(std::is_sorted(clips.begin(), clips.end(), Clip::comparePosition)); - for(TrackContentObject* tco : tcos) + for(Clip* clip : clips) { - if (tco->isMuted() || tco->startPosition() > time) { + if (clip->isMuted() || clip->startPosition() > time) { continue; } - if (auto* p = dynamic_cast(tco)) + if (auto* p = dynamic_cast(clip)) { if (! p->hasAutomation()) { continue; @@ -306,13 +306,13 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra valueMap[model] = value; } } - else if (auto* bb = dynamic_cast(tco)) + else if (auto* bb = dynamic_cast(clip)) { auto bbIndex = dynamic_cast(bb->getTrack())->index(); auto bbContainer = Engine::getBBTrackContainer(); - TimePos bbTime = time - tco->startPosition(); - bbTime = std::min(bbTime, tco->length()); + TimePos bbTime = time - clip->startPosition(); + bbTime = std::min(bbTime, clip->length()); bbTime = bbTime % (bbContainer->lengthOfBB(bbIndex) * TimePos::ticksPerBar()); auto bbValues = bbContainer->automatedValuesAt(bbTime, bbIndex); diff --git a/src/core/midi/MidiPort.cpp b/src/core/midi/MidiPort.cpp index 84d9cc8d1ce..30122b93b72 100644 --- a/src/core/midi/MidiPort.cpp +++ b/src/core/midi/MidiPort.cpp @@ -174,8 +174,8 @@ void MidiPort::saveSettings( QDomDocument& doc, QDomElement& thisElement ) { m_inputChannelModel.saveSettings( doc, thisElement, "inputchannel" ); m_outputChannelModel.saveSettings( doc, thisElement, "outputchannel" ); - m_inputControllerModel.saveSettings( doc, thisElement, "inputcontroller" ); - m_outputControllerModel.saveSettings( doc, thisElement, "outputcontroller" ); + m_inputControllerModel.saveSettings( doc, thisElement, "inpuclipntroller" ); + m_outputControllerModel.saveSettings( doc, thisElement, "outpuclipntroller" ); m_fixedInputVelocityModel.saveSettings( doc, thisElement, "fixedinputvelocity" ); m_fixedOutputVelocityModel.saveSettings( doc, thisElement, "fixedoutputvelocity" ); m_fixedOutputNoteModel.saveSettings( doc, thisElement, "fixedoutputnote" ); @@ -228,8 +228,8 @@ void MidiPort::loadSettings( const QDomElement& thisElement ) { m_inputChannelModel.loadSettings( thisElement, "inputchannel" ); m_outputChannelModel.loadSettings( thisElement, "outputchannel" ); - m_inputControllerModel.loadSettings( thisElement, "inputcontroller" ); - m_outputControllerModel.loadSettings( thisElement, "outputcontroller" ); + m_inputControllerModel.loadSettings( thisElement, "inpuclipntroller" ); + m_outputControllerModel.loadSettings( thisElement, "outpuclipntroller" ); m_fixedInputVelocityModel.loadSettings( thisElement, "fixedinputvelocity" ); m_fixedOutputVelocityModel.loadSettings( thisElement, "fixedoutputvelocity" ); m_outputProgramModel.loadSettings( thisElement, "outputprogram" ); diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 73a3b65a5d1..c113062406e 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -45,7 +45,7 @@ QPixmap * AutomationPatternView::s_pat_rec = NULL; AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern, TrackView * _parent ) : - TrackContentObjectView( _pattern, _parent ), + ClipView( _pattern, _parent ), m_pat( _pattern ), m_paintPixmap() { @@ -85,7 +85,7 @@ void AutomationPatternView::update() { ToolTip::add(this, m_pat->name()); - TrackContentObjectView::update(); + ClipView::update(); } @@ -273,21 +273,21 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) p.fillRect( rect(), c ); } - const float ppb = fixedTCOs() ? - ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) + const float ppb = fixedClips() ? + ( parentWidget()->width() - 2 * CLIP_BORDER_WIDTH ) / (float) m_pat->timeMapLength().getBar() : pixelsPerBar(); - const int x_base = TCO_BORDER_WIDTH; + const int x_base = CLIP_BORDER_WIDTH; const float min = m_pat->firstObject()->minValue(); const float max = m_pat->firstObject()->maxValue(); const float y_scale = max - min; - const float h = ( height() - 2 * TCO_BORDER_WIDTH ) / y_scale; + const float h = ( height() - 2 * CLIP_BORDER_WIDTH ) / y_scale; const float ppTick = ppb / TimePos::ticksPerBar(); - p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH ); + p.translate( 0.0f, max * height() / y_scale - CLIP_BORDER_WIDTH ); p.scale( 1.0f, -h ); QLinearGradient lin2grad( 0, min, 0, max ); @@ -307,8 +307,8 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) if( it+1 == m_pat->getTimeMap().end() ) { const float x1 = x_base + POS(it) * ppTick; - const float x2 = (float)( width() - TCO_BORDER_WIDTH ); - if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break; + const float x2 = (float)( width() - CLIP_BORDER_WIDTH ); + if( x1 > ( width() - CLIP_BORDER_WIDTH ) ) break; // We are drawing the space after the last node, so we use the outValue if( gradient() ) { @@ -347,7 +347,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) for (int i = POS(it) + 1; i < POS(it + 1); i++) { x = x_base + i * ppTick; - if( x > ( width() - TCO_BORDER_WIDTH ) ) break; + if( x > ( width() - CLIP_BORDER_WIDTH ) ) break; float value = values[i - POS(it)]; path.lineTo( QPointF( x, value ) ); @@ -374,12 +374,12 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) const int lineSize = 3; p.setPen( c.darker( 300 ) ); - for( bar_t t = 1; t < width() - TCO_BORDER_WIDTH; ++t ) + for( bar_t t = 1; t < width() - CLIP_BORDER_WIDTH; ++t ) { const int tx = x_base + static_cast( ppb * t ) - 2; - p.drawLine( tx, TCO_BORDER_WIDTH, tx, TCO_BORDER_WIDTH + lineSize ); - p.drawLine( tx, rect().bottom() - ( lineSize + TCO_BORDER_WIDTH ), - tx, rect().bottom() - TCO_BORDER_WIDTH ); + p.drawLine( tx, CLIP_BORDER_WIDTH, tx, CLIP_BORDER_WIDTH + lineSize ); + p.drawLine( tx, rect().bottom() - ( lineSize + CLIP_BORDER_WIDTH ), + tx, rect().bottom() - CLIP_BORDER_WIDTH ); } // recording icon for when recording automation @@ -394,8 +394,8 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) // inner border p.setPen( c.lighter( current ? 160 : 130 ) ); - p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, - rect().bottom() - TCO_BORDER_WIDTH ); + p.drawRect( 1, 1, rect().right() - CLIP_BORDER_WIDTH, + rect().bottom() - CLIP_BORDER_WIDTH ); // outer border p.setPen( current? c.lighter( 130 ) : c.darker( 300 ) ); @@ -404,7 +404,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) // draw the 'muted' pixmap only if the pattern was manualy muted if( m_pat->isMuted() ) { - const int spacing = TCO_BORDER_WIDTH; + const int spacing = CLIP_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); @@ -423,7 +423,7 @@ void AutomationPatternView::dragEnterEvent( QDragEnterEvent * _dee ) StringPairDrag::processDragEnterEvent( _dee, "automatable_model" ); if( !_dee->isAccepted() ) { - TrackContentObjectView::dragEnterEvent( _dee ); + ClipView::dragEnterEvent( _dee ); } } @@ -461,7 +461,7 @@ void AutomationPatternView::dropEvent( QDropEvent * _de ) } else { - TrackContentObjectView::dropEvent( _de ); + ClipView::dropEvent( _de ); } } diff --git a/src/gui/AutomationTrackView.cpp b/src/gui/AutomationTrackView.cpp index 13bcddc0096..c1c4d0042c5 100644 --- a/src/gui/AutomationTrackView.cpp +++ b/src/gui/AutomationTrackView.cpp @@ -78,8 +78,8 @@ void AutomationTrackView::dropEvent( QDropEvent * _de ) pos.setTicks( 0 ); } - TrackContentObject * tco = getTrack()->createTCO( pos ); - AutomationPattern * pat = dynamic_cast( tco ); + Clip * clip = getTrack()->createClip( pos ); + AutomationPattern * pat = dynamic_cast( clip ); pat->addObject( mod ); } } diff --git a/src/gui/BBTCOView.cpp b/src/gui/BBClipView.cpp similarity index 72% rename from src/gui/BBTCOView.cpp rename to src/gui/BBClipView.cpp index a09f1bd0ca7..1dd9b9c9a80 100644 --- a/src/gui/BBTCOView.cpp +++ b/src/gui/BBClipView.cpp @@ -1,5 +1,5 @@ /* - * BBTCOView.cpp + * BBClipView.cpp * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -22,7 +22,7 @@ * */ -#include "BBTCOView.h" +#include "BBClipView.h" #include #include @@ -36,18 +36,18 @@ #include "Song.h" #include "ToolTip.h" -BBTCOView::BBTCOView( TrackContentObject * _tco, TrackView * _tv ) : - TrackContentObjectView( _tco, _tv ), - m_bbTCO( dynamic_cast( _tco ) ), +BBClipView::BBClipView( Clip * _clip, TrackView * _tv ) : + ClipView( _clip, _tv ), + m_bbClip( dynamic_cast( _clip ) ), m_paintPixmap() { - connect( _tco->getTrack(), SIGNAL( dataChanged() ), + connect( _clip->getTrack(), SIGNAL( dataChanged() ), this, SLOT( update() ) ); setStyle( QApplication::style() ); } -void BBTCOView::constructContextMenu( QMenu * _cm ) +void BBClipView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "bb_track" ), tr( "Open in Beat+Bassline-Editor" ), @@ -67,7 +67,7 @@ void BBTCOView::constructContextMenu( QMenu * _cm ) -void BBTCOView::mouseDoubleClickEvent( QMouseEvent * ) +void BBClipView::mouseDoubleClickEvent( QMouseEvent * ) { openInBBEditor(); } @@ -75,7 +75,7 @@ void BBTCOView::mouseDoubleClickEvent( QMouseEvent * ) -void BBTCOView::paintEvent( QPaintEvent * ) +void BBClipView::paintEvent( QPaintEvent * ) { QPainter painter( this ); @@ -116,35 +116,35 @@ void BBTCOView::paintEvent( QPaintEvent * ) const int lineSize = 3; p.setPen( c.darker( 200 ) ); - bar_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() ); - if( m_bbTCO->length() > TimePos::ticksPerBar() && t > 0 ) + bar_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbClip->bbTrackIndex() ); + if( m_bbClip->length() > TimePos::ticksPerBar() && t > 0 ) { for( int x = static_cast( t * pixelsPerBar() ); x < width() - 2; x += static_cast( t * pixelsPerBar() ) ) { - p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize ); - p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ), - x, rect().bottom() - TCO_BORDER_WIDTH ); + p.drawLine( x, CLIP_BORDER_WIDTH, x, CLIP_BORDER_WIDTH + lineSize ); + p.drawLine( x, rect().bottom() - ( CLIP_BORDER_WIDTH + lineSize ), + x, rect().bottom() - CLIP_BORDER_WIDTH ); } } // pattern name - paintTextLabel(m_bbTCO->name(), p); + paintTextLabel(m_bbClip->name(), p); // inner border p.setPen( c.lighter( 130 ) ); - p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, - rect().bottom() - TCO_BORDER_WIDTH ); + p.drawRect( 1, 1, rect().right() - CLIP_BORDER_WIDTH, + rect().bottom() - CLIP_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted - if( m_bbTCO->isMuted() ) + if( m_bbClip->isMuted() ) { - const int spacing = TCO_BORDER_WIDTH; + const int spacing = CLIP_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); @@ -158,9 +158,9 @@ void BBTCOView::paintEvent( QPaintEvent * ) -void BBTCOView::openInBBEditor() +void BBClipView::openInBBEditor() { - Engine::getBBTrackContainer()->setCurrentBB( m_bbTCO->bbTrackIndex() ); + Engine::getBBTrackContainer()->setCurrentBB( m_bbClip->bbTrackIndex() ); gui->mainWindow()->toggleBBEditorWin( true ); } @@ -168,24 +168,24 @@ void BBTCOView::openInBBEditor() -void BBTCOView::resetName() { m_bbTCO->setName(""); } +void BBClipView::resetName() { m_bbClip->setName(""); } -void BBTCOView::changeName() +void BBClipView::changeName() { - QString s = m_bbTCO->name(); + QString s = m_bbClip->name(); RenameDialog rename_dlg( s ); rename_dlg.exec(); - m_bbTCO->setName( s ); + m_bbClip->setName( s ); } -void BBTCOView::update() +void BBClipView::update() { - ToolTip::add(this, m_bbTCO->name()); + ToolTip::add(this, m_bbClip->name()); - TrackContentObjectView::update(); + ClipView::update(); } \ No newline at end of file diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index d5556d03a77..86df67d8f7e 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -9,7 +9,7 @@ SET(LMMS_SRCS gui/AutomationTrackView.cpp gui/ControllerConnectionDialog.cpp gui/ControllerDialog.cpp - gui/BBTCOView.cpp + gui/BBClipView.cpp gui/BBTrackView.cpp gui/EffectControlDialog.cpp gui/EffectSelectDialog.cpp @@ -33,7 +33,7 @@ SET(LMMS_SRCS gui/PianoView.cpp gui/PluginBrowser.cpp gui/RowTableView.cpp - gui/SampleTCOView.cpp + gui/SampleClipView.cpp gui/SampleTrackView.cpp gui/SampleTrackWindow.cpp gui/SetupDialog.cpp @@ -42,7 +42,7 @@ SET(LMMS_SRCS gui/TimeLineWidget.cpp gui/ToolPluginView.cpp gui/TrackContainerView.cpp - gui/TrackContentObjectView.cpp + gui/ClipView.cpp gui/TrackView.cpp gui/dialogs/FileDialog.cpp diff --git a/src/gui/TrackContentObjectView.cpp b/src/gui/ClipView.cpp similarity index 65% rename from src/gui/TrackContentObjectView.cpp rename to src/gui/ClipView.cpp index 6055d26d5f8..6ff16050817 100644 --- a/src/gui/TrackContentObjectView.cpp +++ b/src/gui/ClipView.cpp @@ -1,5 +1,5 @@ /* - * TrackContentObjectView.cpp - implementation of TrackContentObjectView class + * ClipView.cpp - implementation of ClipView class * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -22,7 +22,7 @@ * */ -#include "TrackContentObjectView.h" +#include "ClipView.h" #include @@ -62,7 +62,7 @@ const int RESIZE_GRIP_WIDTH = 4; * beside the cursor as you move or resize elements of a track about. * This pointer keeps track of it, as you only ever need one at a time. */ -TextFloat * TrackContentObjectView::s_textFloat = NULL; +TextFloat * ClipView::s_textFloat = NULL; /*! \brief Create a new trackContentObjectView @@ -70,17 +70,17 @@ TextFloat * TrackContentObjectView::s_textFloat = NULL; * Creates a new track content object view for the given * track content object in the given track view. * - * \param _tco The track content object to be displayed + * \param _clip The track content object to be displayed * \param _tv The track view that will contain the new object */ -TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, +ClipView::ClipView( Clip * clip, TrackView * tv ) : selectableObject( tv->getTrackContentWidget() ), ModelView( NULL, this ), m_trackView( tv ), - m_initialTCOPos( TimePos(0) ), - m_initialTCOEnd( TimePos(0) ), - m_tco( tco ), + m_initialClipPos( TimePos(0) ), + m_initialClipEnd( TimePos(0) ), + m_clip( clip ), m_action( NoAction ), m_initialMousePos( QPoint( 0, 0 ) ), m_initialMouseGlobalPos( QPoint( 0, 0 ) ), @@ -117,17 +117,17 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, setAcceptDrops( true ); setMouseTracking( true ); - connect( m_tco, SIGNAL( lengthChanged() ), + connect( m_clip, SIGNAL( lengthChanged() ), this, SLOT( updateLength() ) ); connect( gui->songEditor()->m_editor->zoomingModel(), SIGNAL( dataChanged() ), this, SLOT( updateLength() ) ); - connect( m_tco, SIGNAL( positionChanged() ), + connect( m_clip, SIGNAL( positionChanged() ), this, SLOT( updatePosition() ) ); - connect( m_tco, SIGNAL( destroyedTCO() ), this, SLOT( close() ) ); - setModel( m_tco ); - connect( m_tco, SIGNAL( trackColorChanged() ), this, SLOT( update() ) ); + connect( m_clip, SIGNAL( destroyedClip() ), this, SLOT( close() ) ); + setModel( m_clip ); + connect( m_clip, SIGNAL( trackColorChanged() ), this, SLOT( update() ) ); connect( m_trackView->getTrackOperationsWidget(), SIGNAL( colorParented() ), this, SLOT( useTrackColor() ) ); - m_trackView->getTrackContentWidget()->addTCOView( this ); + m_trackView->getTrackContentWidget()->addClipView( this ); updateLength(); updatePosition(); } @@ -140,7 +140,7 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, * Destroys the given track content object view. * */ -TrackContentObjectView::~TrackContentObjectView() +ClipView::~ClipView() { delete m_hint; // we have to give our track-container the focus because otherwise the @@ -151,14 +151,14 @@ TrackContentObjectView::~TrackContentObjectView() } -/*! \brief Update a TrackContentObjectView +/*! \brief Update a ClipView * - * TCO's get drawn only when needed, - * and when a TCO is updated, + * Clip's get drawn only when needed, + * and when a Clip is updated, * it needs to be redrawn. * */ -void TrackContentObjectView::update() +void ClipView::update() { if( !m_cursorSetYet ) { @@ -168,7 +168,7 @@ void TrackContentObjectView::update() m_cursorSetYet = true; } - if( fixedTCOs() ) + if( fixedClips() ) { updateLength(); } @@ -178,80 +178,80 @@ void TrackContentObjectView::update() -/*! \brief Does this trackContentObjectView have a fixed TCO? +/*! \brief Does this trackContentObjectView have a fixed Clip? * * Returns whether the containing trackView has fixed - * TCOs. + * Clips. * - * \todo What the hell is a TCO here - track content object? And in + * \todo What the hell is a Clip here - track content object? And in * what circumstance are they fixed? */ -bool TrackContentObjectView::fixedTCOs() +bool ClipView::fixedClips() { - return m_trackView->trackContainerView()->fixedTCOs(); + return m_trackView->trackContainerView()->fixedClips(); } -// qproperty access functions, to be inherited & used by TCOviews +// qproperty access functions, to be inherited & used by Clipviews //! \brief CSS theming qproperty access method -QColor TrackContentObjectView::mutedColor() const +QColor ClipView::mutedColor() const { return m_mutedColor; } -QColor TrackContentObjectView::mutedBackgroundColor() const +QColor ClipView::mutedBackgroundColor() const { return m_mutedBackgroundColor; } -QColor TrackContentObjectView::selectedColor() const +QColor ClipView::selectedColor() const { return m_selectedColor; } -QColor TrackContentObjectView::textColor() const +QColor ClipView::textColor() const { return m_textColor; } -QColor TrackContentObjectView::textBackgroundColor() const +QColor ClipView::textBackgroundColor() const { return m_textBackgroundColor; } -QColor TrackContentObjectView::textShadowColor() const +QColor ClipView::textShadowColor() const { return m_textShadowColor; } -QColor TrackContentObjectView::BBPatternBackground() const +QColor ClipView::BBPatternBackground() const { return m_BBPatternBackground; } -bool TrackContentObjectView::gradient() const +bool ClipView::gradient() const { return m_gradient; } //! \brief CSS theming qproperty access method -void TrackContentObjectView::setMutedColor( const QColor & c ) +void ClipView::setMutedColor( const QColor & c ) { m_mutedColor = QColor( c ); } -void TrackContentObjectView::setMutedBackgroundColor( const QColor & c ) +void ClipView::setMutedBackgroundColor( const QColor & c ) { m_mutedBackgroundColor = QColor( c ); } -void TrackContentObjectView::setSelectedColor( const QColor & c ) +void ClipView::setSelectedColor( const QColor & c ) { m_selectedColor = QColor( c ); } -void TrackContentObjectView::setTextColor( const QColor & c ) +void ClipView::setTextColor( const QColor & c ) { m_textColor = QColor( c ); } -void TrackContentObjectView::setTextBackgroundColor( const QColor & c ) +void ClipView::setTextBackgroundColor( const QColor & c ) { m_textBackgroundColor = c; } -void TrackContentObjectView::setTextShadowColor( const QColor & c ) +void ClipView::setTextShadowColor( const QColor & c ) { m_textShadowColor = QColor( c ); } -void TrackContentObjectView::setBBPatternBackground( const QColor & c ) +void ClipView::setBBPatternBackground( const QColor & c ) { m_BBPatternBackground = QColor( c ); } -void TrackContentObjectView::setGradient( const bool & b ) +void ClipView::setGradient( const bool & b ) { m_gradient = b; } // access needsUpdate member variable -bool TrackContentObjectView::needsUpdate() +bool ClipView::needsUpdate() { return m_needsUpdate; } -void TrackContentObjectView::setNeedsUpdate( bool b ) +void ClipView::setNeedsUpdate( bool b ) { m_needsUpdate = b; } /*! \brief Close a trackContentObjectView @@ -261,9 +261,9 @@ void TrackContentObjectView::setNeedsUpdate( bool b ) * * \return Boolean state of whether the QWidget was able to close. */ -bool TrackContentObjectView::close() +bool ClipView::close() { - m_trackView->getTrackContentWidget()->removeTCOView( this ); + m_trackView->getTrackContentWidget()->removeClipView( this ); return QWidget::close(); } @@ -277,13 +277,13 @@ bool TrackContentObjectView::close() * scheduled for later deletion rather than closed immediately. * */ -void TrackContentObjectView::remove() +void ClipView::remove() { m_trackView->getTrack()->addJournalCheckPoint(); // delete ourself close(); - m_tco->deleteLater(); + m_clip->deleteLater(); } @@ -291,23 +291,23 @@ void TrackContentObjectView::remove() /*! \brief Updates a trackContentObjectView's length * - * If this track content object view has a fixed TCO, then we must + * If this track content object view has a fixed Clip, then we must * keep the width of our parent. Otherwise, calculate our width from * the track content object's length in pixels adding in the border. * */ -void TrackContentObjectView::updateLength() +void ClipView::updateLength() { - if( fixedTCOs() ) + if( fixedClips() ) { setFixedWidth( parentWidget()->width() ); } else { setFixedWidth( - static_cast( m_tco->length() * pixelsPerBar() / + static_cast( m_clip->length() * pixelsPerBar() / TimePos::ticksPerBar() ) + 1 /*+ - TCO_BORDER_WIDTH * 2-1*/ ); + CLIP_BORDER_WIDTH * 2-1*/ ); } m_trackView->trackContainerView()->update(); } @@ -322,10 +322,10 @@ void TrackContentObjectView::updateLength() * view's length. * */ -void TrackContentObjectView::updatePosition() +void ClipView::updatePosition() { m_trackView->getTrackContentWidget()->changePosition(); - // moving a TCO can result in change of song-length etc., + // moving a Clip can result in change of song-length etc., // therefore we update the track-container m_trackView->trackContainerView()->update(); } @@ -333,24 +333,24 @@ void TrackContentObjectView::updatePosition() -void TrackContentObjectView::changeClipColor() +void ClipView::changeClipColor() { // Get a color from the user - QColor new_color = ColorChooser( this ).withPalette( ColorChooser::Palette::Track )->getColor( m_tco->color() ); + QColor new_color = ColorChooser( this ).withPalette( ColorChooser::Palette::Track )->getColor( m_clip->color() ); if( ! new_color.isValid() ) { return; } // Use that color - m_tco->setColor( new_color ); - m_tco->useCustomClipColor( true ); + m_clip->setColor( new_color ); + m_clip->useCustomClipColor( true ); update(); } -void TrackContentObjectView::useTrackColor() +void ClipView::useTrackColor() { - m_tco->useCustomClipColor( false ); + m_clip->useCustomClipColor( false ); update(); } @@ -366,19 +366,19 @@ void TrackContentObjectView::useTrackColor() * * \param dee The QDragEnterEvent to watch. */ -void TrackContentObjectView::dragEnterEvent( QDragEnterEvent * dee ) +void ClipView::dragEnterEvent( QDragEnterEvent * dee ) { TrackContentWidget * tcw = getTrackView()->getTrackContentWidget(); - TimePos tcoPos = TimePos( m_tco->startPosition() ); + TimePos clipPos = TimePos( m_clip->startPosition() ); - if( tcw->canPasteSelection( tcoPos, dee ) == false ) + if( tcw->canPasteSelection( clipPos, dee ) == false ) { dee->ignore(); } else { - StringPairDrag::processDragEnterEvent( dee, "tco_" + - QString::number( m_tco->getTrack()->type() ) ); + StringPairDrag::processDragEnterEvent( dee, "clip_" + + QString::number( m_clip->getTrack()->type() ) ); } } @@ -394,13 +394,13 @@ void TrackContentObjectView::dragEnterEvent( QDragEnterEvent * dee ) * * \param de The QDropEvent to handle. */ -void TrackContentObjectView::dropEvent( QDropEvent * de ) +void ClipView::dropEvent( QDropEvent * de ) { QString type = StringPairDrag::decodeKey( de ); QString value = StringPairDrag::decodeValue( de ); // Track must be the same type to paste into - if( type != ( "tco_" + QString::number( m_tco->getTrack()->type() ) ) ) + if( type != ( "clip_" + QString::number( m_clip->getTrack()->type() ) ) ) { return; } @@ -409,29 +409,29 @@ void TrackContentObjectView::dropEvent( QDropEvent * de ) if( m_trackView->trackContainerView()->allowRubberband() == true ) { TrackContentWidget * tcw = getTrackView()->getTrackContentWidget(); - TimePos tcoPos = TimePos( m_tco->startPosition() ); + TimePos clipPos = TimePos( m_clip->startPosition() ); - if( tcw->pasteSelection( tcoPos, de ) == true ) + if( tcw->pasteSelection( clipPos, de ) == true ) { de->accept(); } return; } - // Don't allow pasting a tco into itself. + // Don't allow pasting a clip into itself. QObject* qwSource = de->source(); if( qwSource != NULL && - dynamic_cast( qwSource ) == this ) + dynamic_cast( qwSource ) == this ) { return; } - // Copy state into existing tco + // Copy state into existing clip DataFile dataFile( value.toUtf8() ); - TimePos pos = m_tco->startPosition(); - QDomElement tcos = dataFile.content().firstChildElement( "tcos" ); - m_tco->restoreState( tcos.firstChildElement().firstChildElement() ); - m_tco->movePosition( pos ); + TimePos pos = m_clip->startPosition(); + QDomElement clips = dataFile.content().firstChildElement( "clips" ); + m_clip->restoreState( clips.firstChildElement().firstChildElement() ); + m_clip->movePosition( pos ); AutomationPattern::resolveAllIDs(); de->accept(); } @@ -443,18 +443,18 @@ void TrackContentObjectView::dropEvent( QDropEvent * de ) * * @param me The QMouseEvent that is triggering the cursor change */ -void TrackContentObjectView::updateCursor(QMouseEvent * me) +void ClipView::updateCursor(QMouseEvent * me) { - SampleTCO * sTco = dynamic_cast(m_tco); + SampleClip * sClip = dynamic_cast(m_clip); // If we are at the edges, use the resize cursor - if ((me->x() > width() - RESIZE_GRIP_WIDTH && !me->buttons() && !m_tco->getAutoResize()) - || (me->x() < RESIZE_GRIP_WIDTH && !me->buttons() && sTco && !m_tco->getAutoResize())) + if ((me->x() > width() - RESIZE_GRIP_WIDTH && !me->buttons() && !m_clip->getAutoResize()) + || (me->x() < RESIZE_GRIP_WIDTH && !me->buttons() && sClip && !m_clip->getAutoResize())) { setCursor(Qt::SizeHorCursor); } // If we are in the middle on knife mode, use the knife cursor - else if (sTco && m_trackView->trackContainerView()->knifeMode()) + else if (sClip && m_trackView->trackContainerView()->knifeMode()) { setCursor(m_cursorKnife); } @@ -467,37 +467,37 @@ void TrackContentObjectView::updateCursor(QMouseEvent * me) /*! \brief Create a DataFile suitable for copying multiple trackContentObjects. * - * trackContentObjects in the vector are written to the "tcos" node in the + * trackContentObjects in the vector are written to the "clips" node in the * DataFile. The trackContentObjectView's initial mouse position is written * to the "initialMouseX" node in the DataFile. When dropped on a track, - * this is used to create copies of the TCOs. + * this is used to create copies of the Clips. * - * \param tcos The trackContectObjects to save in a DataFile + * \param clips The trackContectObjects to save in a DataFile */ -DataFile TrackContentObjectView::createTCODataFiles( - const QVector & tcoViews) const +DataFile ClipView::createClipDataFiles( + const QVector & clipViews) const { Track * t = m_trackView->getTrack(); TrackContainer * tc = t->trackContainer(); DataFile dataFile( DataFile::DragNDropData ); - QDomElement tcoParent = dataFile.createElement( "tcos" ); + QDomElement clipParent = dataFile.createElement( "clips" ); - typedef QVector tcoViewVector; - for( tcoViewVector::const_iterator it = tcoViews.begin(); - it != tcoViews.end(); ++it ) + typedef QVector clipViewVector; + for( clipViewVector::const_iterator it = clipViews.begin(); + it != clipViews.end(); ++it ) { - // Insert into the dom under the "tcos" element - Track* tcoTrack = ( *it )->m_trackView->getTrack(); - int trackIndex = tc->tracks().indexOf( tcoTrack ); - QDomElement tcoElement = dataFile.createElement( "tco" ); - tcoElement.setAttribute( "trackIndex", trackIndex ); - tcoElement.setAttribute( "trackType", tcoTrack->type() ); - tcoElement.setAttribute( "trackName", tcoTrack->name() ); - ( *it )->m_tco->saveState( dataFile, tcoElement ); - tcoParent.appendChild( tcoElement ); + // Insert into the dom under the "clips" element + Track* clipTrack = ( *it )->m_trackView->getTrack(); + int trackIndex = tc->tracks().indexOf( clipTrack ); + QDomElement clipElement = dataFile.createElement( "clip" ); + clipElement.setAttribute( "trackIndex", trackIndex ); + clipElement.setAttribute( "trackType", clipTrack->type() ); + clipElement.setAttribute( "trackName", clipTrack->name() ); + ( *it )->m_clip->saveState( dataFile, clipElement ); + clipParent.appendChild( clipElement ); } - dataFile.content().appendChild( tcoParent ); + dataFile.content().appendChild( clipParent ); // Add extra metadata needed for calculations later int initialTrackIndex = tc->tracks().indexOf( t ); @@ -510,15 +510,15 @@ DataFile TrackContentObjectView::createTCODataFiles( // initialTrackIndex is the index of the track that was touched metadata.setAttribute( "initialTrackIndex", initialTrackIndex ); metadata.setAttribute( "trackContainerId", tc->id() ); - // grabbedTCOPos is the pos of the bar containing the TCO we grabbed - metadata.setAttribute( "grabbedTCOPos", m_tco->startPosition() ); + // grabbedClipPos is the pos of the bar containing the Clip we grabbed + metadata.setAttribute( "grabbedClipPos", m_clip->startPosition() ); dataFile.content().appendChild( metadata ); return dataFile; } -void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & painter) +void ClipView::paintTextLabel(QString const & text, QPainter & painter) { if (text.trimmed() == "") { @@ -531,8 +531,8 @@ void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & pai labelFont.setHintingPreference( QFont::PreferFullHinting ); painter.setFont( labelFont ); - const int textTop = TCO_BORDER_WIDTH + 1; - const int textLeft = TCO_BORDER_WIDTH + 3; + const int textTop = CLIP_BORDER_WIDTH + 1; + const int textLeft = CLIP_BORDER_WIDTH + 3; QFontMetrics fontMetrics(labelFont); QString elidedPatternName = fontMetrics.elidedText(text, Qt::ElideMiddle, width() - 2 * textLeft); @@ -566,22 +566,22 @@ void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & pai * * \param me The QMouseEvent to handle. */ -void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) +void ClipView::mousePressEvent( QMouseEvent * me ) { // Right now, active is only used on right/mid clicks actions, so we use a ternary operator - // to avoid the overhead of calling getClickedTCOs when it's not used + // to avoid the overhead of calling getClickedClips when it's not used auto active = me->button() == Qt::LeftButton - ? QVector() - : getClickedTCOs(); + ? QVector() + : getClickedClips(); setInitialPos( me->pos() ); setInitialOffsets(); - if( !fixedTCOs() && me->button() == Qt::LeftButton ) + if( !fixedClips() && me->button() == Qt::LeftButton ) { - SampleTCO * sTco = dynamic_cast( m_tco ); + SampleClip * sClip = dynamic_cast( m_clip ); const bool knifeMode = m_trackView->trackContainerView()->knifeMode(); - if ( me->modifiers() & Qt::ControlModifier && !(sTco && knifeMode) ) + if ( me->modifiers() & Qt::ControlModifier && !(sClip && knifeMode) ) { if( isSelected() ) { @@ -600,20 +600,20 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) } else { - gui->songEditor()->m_editor->selectAllTcos( false ); - m_tco->addJournalCheckPoint(); + gui->songEditor()->m_editor->selectAllClips( false ); + m_clip->addJournalCheckPoint(); // Move, Resize and ResizeLeft - // Split action doesn't disable TCO journalling + // Split action doesn't disable Clip journalling if (m_action == Move || m_action == Resize || m_action == ResizeLeft) { - m_tco->setJournalling(false); + m_clip->setJournalling(false); } setInitialPos( me->pos() ); setInitialOffsets(); - if( m_tco->getAutoResize() ) + if( m_clip->getAutoResize() ) { // Always move clips that can't be manually resized m_action = Move; setCursor( Qt::SizeAllCursor ); @@ -623,12 +623,12 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) m_action = Resize; setCursor( Qt::SizeHorCursor ); } - else if( me->x() < RESIZE_GRIP_WIDTH && sTco ) + else if( me->x() < RESIZE_GRIP_WIDTH && sClip ) { m_action = ResizeLeft; setCursor( Qt::SizeHorCursor ); } - else if( sTco && knifeMode ) + else if( sClip && knifeMode ) { m_action = Split; setCursor( m_cursorKnife ); @@ -646,26 +646,26 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) { s_textFloat->setTitle( tr( "Current position" ) ); s_textFloat->setText( QString( "%1:%2" ). - arg( m_tco->startPosition().getBar() + 1 ). - arg( m_tco->startPosition().getTicks() % + arg( m_clip->startPosition().getBar() + 1 ). + arg( m_clip->startPosition().getTicks() % TimePos::ticksPerBar() ) ); } else if( m_action == Resize || m_action == ResizeLeft ) { s_textFloat->setTitle( tr( "Current length" ) ); s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ). - arg( m_tco->length().getBar() ). - arg( m_tco->length().getTicks() % + arg( m_clip->length().getBar() ). + arg( m_clip->length().getTicks() % TimePos::ticksPerBar() ). - arg( m_tco->startPosition().getBar() + 1 ). - arg( m_tco->startPosition().getTicks() % + arg( m_clip->startPosition().getBar() + 1 ). + arg( m_clip->startPosition().getTicks() % TimePos::ticksPerBar() ). - arg( m_tco->endPosition().getBar() + 1 ). - arg( m_tco->endPosition().getTicks() % + arg( m_clip->endPosition().getBar() + 1 ). + arg( m_clip->endPosition().getTicks() % TimePos::ticksPerBar() ) ); } // s_textFloat->reparent( this ); - // setup text-float as if TCO was already moved/resized + // setup text-float as if Clip was already moved/resized s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2) ); if ( m_action != Split) { s_textFloat->show(); } } @@ -684,15 +684,15 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) { toggleMute( active ); } - else if( me->modifiers() & Qt::ShiftModifier && !fixedTCOs() ) + else if( me->modifiers() & Qt::ShiftModifier && !fixedClips() ) { remove( active ); } if (m_action == Split) { m_action = NoAction; - SampleTCO * sTco = dynamic_cast( m_tco ); - if (sTco) + SampleClip * sClip = dynamic_cast( m_clip ); + if (sClip) { setMarkerEnabled( false ); update(); @@ -705,7 +705,7 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) { toggleMute( active ); } - else if( !fixedTCOs() ) + else if( !fixedClips() ) { remove( active ); } @@ -728,47 +728,47 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) * \param me The QMouseEvent to handle. * \todo what does the final else case do here? */ -void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) +void ClipView::mouseMoveEvent( QMouseEvent * me ) { if( m_action == CopySelection || m_action == ToggleSelected ) { if( mouseMovedDistance( me, 2 ) == true ) { - QVector tcoViews; + QVector clipViews; if( m_action == CopySelection ) { - // Collect all selected TCOs + // Collect all selected Clips QVector so = m_trackView->trackContainerView()->selectedObjects(); for( auto it = so.begin(); it != so.end(); ++it ) { - TrackContentObjectView * tcov = - dynamic_cast( *it ); - if( tcov != NULL ) + ClipView * clipv = + dynamic_cast( *it ); + if( clipv != NULL ) { - tcoViews.push_back( tcov ); + clipViews.push_back( clipv ); } } } else { - gui->songEditor()->m_editor->selectAllTcos( false ); - tcoViews.push_back( this ); + gui->songEditor()->m_editor->selectAllClips( false ); + clipViews.push_back( this ); } // Clear the action here because mouseReleaseEvent will not get // triggered once we go into drag. m_action = NoAction; - // Write the TCOs to the DataFile for copying - DataFile dataFile = createTCODataFiles( tcoViews ); + // Write the Clips to the DataFile for copying + DataFile dataFile = createClipDataFiles( clipViews ); // TODO -- thumbnail for all selected QPixmap thumbnail = grab().scaled( 128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - new StringPairDrag( QString( "tco_%1" ).arg( - m_tco->getTrack()->type() ), + new StringPairDrag( QString( "clip_%1" ).arg( + m_clip->getTrack()->type() ), dataFile.toString(), thumbnail, this ); } } @@ -782,10 +782,10 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); if( m_action == Move ) { - TimePos newPos = draggedTCOPos( me ); + TimePos newPos = draggedClipPos( me ); - m_tco->movePosition(newPos); - newPos = m_tco->startPosition(); // Get the real position the TCO was dragged to for the label + m_clip->movePosition(newPos); + newPos = m_clip->startPosition(); // Get the real position the Clip was dragged to for the label m_trackView->getTrackContentWidget()->changePosition(); s_textFloat->setText( QString( "%1:%2" ). arg( newPos.getBar() + 1 ). @@ -795,32 +795,32 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) } else if( m_action == MoveSelection ) { - // 1: Find the position we want to move the grabbed TCO to - TimePos newPos = draggedTCOPos( me ); + // 1: Find the position we want to move the grabbed Clip to + TimePos newPos = draggedClipPos( me ); - // 2: Handle moving the other selected TCOs the same distance + // 2: Handle moving the other selected Clips the same distance QVector so = m_trackView->trackContainerView()->selectedObjects(); - QVector tcos; // List of selected clips + QVector clips; // List of selected clips int leftmost = 0; // Leftmost clip's offset from grabbed clip - // Populate tcos, find leftmost + // Populate clips, find leftmost for( QVector::iterator it = so.begin(); it != so.end(); ++it ) { - TrackContentObjectView * tcov = - dynamic_cast( *it ); - if( tcov == NULL ) { continue; } - tcos.push_back( tcov->m_tco ); + ClipView * clipv = + dynamic_cast( *it ); + if( clipv == NULL ) { continue; } + clips.push_back( clipv->m_clip ); int index = std::distance( so.begin(), it ); leftmost = std::min(leftmost, m_initialOffsets[index].getTicks()); } // Make sure the leftmost clip doesn't get moved to a negative position if ( newPos.getTicks() + leftmost < 0 ) { newPos = -leftmost; } - for( QVector::iterator it = tcos.begin(); - it != tcos.end(); ++it ) + for( QVector::iterator it = clips.begin(); + it != clips.end(); ++it ) { - int index = std::distance( tcos.begin(), it ); + int index = std::distance( clips.begin(), it ); ( *it )->movePosition( newPos + m_initialOffsets[index] ); } } @@ -841,30 +841,30 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) // even if the user switches to snapping later setInitialPos( m_initialMousePos ); // Don't resize to less than 1 tick - m_tco->changeLength( qMax( 1, l ) ); + m_clip->changeLength( qMax( 1, l ) ); } else if ( me->modifiers() & Qt::ShiftModifier ) { // If shift is held, quantize clip's end position - TimePos end = TimePos( m_initialTCOPos + l ).quantize( snapSize ); + TimePos end = TimePos( m_initialClipPos + l ).quantize( snapSize ); // The end position has to be after the clip's start - TimePos min = m_initialTCOPos.quantize( snapSize ); - if ( min <= m_initialTCOPos ) min += snapLength; - m_tco->changeLength( qMax(min - m_initialTCOPos, end - m_initialTCOPos) ); + TimePos min = m_initialClipPos.quantize( snapSize ); + if ( min <= m_initialClipPos ) min += snapLength; + m_clip->changeLength( qMax(min - m_initialClipPos, end - m_initialClipPos) ); } else { // Otherwise, resize in fixed increments - TimePos initialLength = m_initialTCOEnd - m_initialTCOPos; + TimePos initialLength = m_initialClipEnd - m_initialClipPos; TimePos offset = TimePos( l - initialLength ).quantize( snapSize ); // Don't resize to less than 1 tick TimePos min = TimePos( initialLength % snapLength ); if (min < 1) min += snapLength; - m_tco->changeLength( qMax( min, initialLength + offset) ); + m_clip->changeLength( qMax( min, initialLength + offset) ); } } else { - SampleTCO * sTco = dynamic_cast( m_tco ); - if( sTco ) + SampleClip * sClip = dynamic_cast( m_clip ); + if( sClip ) { const int x = mapToParent( me->pos() ).x() - m_initialMousePos.x(); @@ -877,50 +877,50 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) // even if the user switches to snapping later setInitialPos( m_initialMousePos ); //Don't resize to less than 1 tick - t = qMin( m_initialTCOEnd - 1, t); + t = qMin( m_initialClipEnd - 1, t); } else if( me->modifiers() & Qt::ShiftModifier ) { // If shift is held, quantize clip's start position // Don't let the start position move past the end position - TimePos max = m_initialTCOEnd.quantize( snapSize ); - if ( max >= m_initialTCOEnd ) max -= snapLength; + TimePos max = m_initialClipEnd.quantize( snapSize ); + if ( max >= m_initialClipEnd ) max -= snapLength; t = qMin( max, t.quantize( snapSize ) ); } else { // Otherwise, resize in fixed increments // Don't resize to less than 1 tick - TimePos initialLength = m_initialTCOEnd - m_initialTCOPos; + TimePos initialLength = m_initialClipEnd - m_initialClipPos; TimePos minLength = TimePos( initialLength % snapLength ); if (minLength < 1) minLength += snapLength; - TimePos offset = TimePos(t - m_initialTCOPos).quantize( snapSize ); - t = qMin( m_initialTCOEnd - minLength, m_initialTCOPos + offset ); + TimePos offset = TimePos(t - m_initialClipPos).quantize( snapSize ); + t = qMin( m_initialClipEnd - minLength, m_initialClipPos + offset ); } - TimePos oldPos = m_tco->startPosition(); - if( m_tco->length() + ( oldPos - t ) >= 1 ) + TimePos oldPos = m_clip->startPosition(); + if( m_clip->length() + ( oldPos - t ) >= 1 ) { - m_tco->movePosition( t ); - m_tco->changeLength( m_tco->length() + ( oldPos - t ) ); - sTco->setStartTimeOffset( sTco->startTimeOffset() + ( oldPos - t ) ); + m_clip->movePosition( t ); + m_clip->changeLength( m_clip->length() + ( oldPos - t ) ); + sClip->setStartTimeOffset( sClip->startTimeOffset() + ( oldPos - t ) ); } } } s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ). - arg( m_tco->length().getBar() ). - arg( m_tco->length().getTicks() % + arg( m_clip->length().getBar() ). + arg( m_clip->length().getTicks() % TimePos::ticksPerBar() ). - arg( m_tco->startPosition().getBar() + 1 ). - arg( m_tco->startPosition().getTicks() % + arg( m_clip->startPosition().getBar() + 1 ). + arg( m_clip->startPosition().getTicks() % TimePos::ticksPerBar() ). - arg( m_tco->endPosition().getBar() + 1 ). - arg( m_tco->endPosition().getTicks() % + arg( m_clip->endPosition().getBar() + 1 ). + arg( m_clip->endPosition().getTicks() % TimePos::ticksPerBar() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2) ); } else if( m_action == Split ) { - SampleTCO * sTco = dynamic_cast( m_tco ); - if (sTco) { + SampleClip * sClip = dynamic_cast( m_clip ); + if (sClip) { setCursor( m_cursorKnife ); setMarkerPos( knifeMarkerPos( me ) ); } @@ -940,7 +940,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) * * \param me The QMouseEvent to handle. */ -void TrackContentObjectView::mouseReleaseEvent( QMouseEvent * me ) +void ClipView::mouseReleaseEvent( QMouseEvent * me ) { // If the CopySelection was chosen as the action due to mouse movement, // it will have been cleared. At this point Toggle is the desired action. @@ -953,14 +953,14 @@ void TrackContentObjectView::mouseReleaseEvent( QMouseEvent * me ) } else if( m_action == Move || m_action == Resize || m_action == ResizeLeft ) { - // TODO: Fix m_tco->setJournalling() consistency - m_tco->setJournalling( true ); + // TODO: Fix m_clip->setJournalling() consistency + m_clip->setJournalling( true ); } else if( m_action == Split ) { const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); const TimePos relPos = me->pos().x() * TimePos::ticksPerBar() / ppb; - splitTCO(unquantizedModHeld(me) ? + splitClip(unquantizedModHeld(me) ? relPos : quantizeSplitPos(relPos, me->modifiers() & Qt::ShiftModifier) ); @@ -984,13 +984,13 @@ void TrackContentObjectView::mouseReleaseEvent( QMouseEvent * me ) * * \param cme The QContextMenuEvent to add the actions to. */ -void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme ) +void ClipView::contextMenuEvent( QContextMenuEvent * cme ) { - QVector selectedTCOs = getClickedTCOs(); + QVector selectedClips = getClickedClips(); - // Depending on whether we right-clicked a selection or an individual TCO we will have + // Depending on whether we right-clicked a selection or an individual Clip we will have // different labels for the actions. - bool individualTCO = selectedTCOs.size() <= 1; + bool individualClip = selectedClips.size() <= 1; if( cme->modifiers() ) { @@ -999,11 +999,11 @@ void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme ) QMenu contextMenu( this ); - if( fixedTCOs() == false ) + if( fixedClips() == false ) { contextMenu.addAction( embed::getIconPixmap( "cancel" ), - individualTCO + individualClip ? tr("Delete (middle mousebutton)") : tr("Delete selection (middle mousebutton)"), [this](){ contextMenuAction( Remove ); } ); @@ -1012,12 +1012,12 @@ void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme ) contextMenu.addAction( embed::getIconPixmap( "edit_cut" ), - individualTCO + individualClip ? tr("Cut") : tr("Cut selection"), [this](){ contextMenuAction( Cut ); } ); - if (canMergeSelection(selectedTCOs)) + if (canMergeSelection(selectedClips)) { contextMenu.addAction( embed::getIconPixmap("edit_merge"), @@ -1029,7 +1029,7 @@ void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme ) contextMenu.addAction( embed::getIconPixmap( "edit_copy" ), - individualTCO + individualClip ? tr("Copy") : tr("Copy selection"), [this](){ contextMenuAction( Copy ); } ); @@ -1043,7 +1043,7 @@ void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme ) contextMenu.addAction( embed::getIconPixmap( "muted" ), - (individualTCO + (individualClip ? tr("Mute/unmute (<%1> + middle click)") : tr("Mute/unmute selection (<%1> + middle click)")).arg(UI_CTRL_KEY), [this](){ contextMenuAction( Mute ); } ); @@ -1060,10 +1060,10 @@ void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme ) contextMenu.exec( QCursor::pos() ); } -// This method processes the actions from the context menu of the TCO View. -void TrackContentObjectView::contextMenuAction( ContextMenuAction action ) +// This method processes the actions from the context menu of the Clip View. +void ClipView::contextMenuAction( ContextMenuAction action ) { - QVector active = getClickedTCOs(); + QVector active = getClickedClips(); // active will be later used for the remove, copy, cut or toggleMute methods switch( action ) @@ -1084,116 +1084,116 @@ void TrackContentObjectView::contextMenuAction( ContextMenuAction action ) toggleMute( active ); break; case Merge: - mergeTCOs(active); + mergeClips(active); break; } } -QVector TrackContentObjectView::getClickedTCOs() +QVector ClipView::getClickedClips() { // Get a list of selected selectableObjects QVector sos = gui->songEditor()->m_editor->selectedObjects(); - // Convert to a list of selected TCOVs - QVector selection; + // Convert to a list of selected ClipVs + QVector selection; selection.reserve( sos.size() ); for( auto so: sos ) { - TrackContentObjectView *tcov = dynamic_cast ( so ); - if( tcov != nullptr ) + ClipView *clipv = dynamic_cast ( so ); + if( clipv != nullptr ) { - selection.append( tcov ); + selection.append( clipv ); } } // If we clicked part of the selection, affect all selected clips. Otherwise affect the clip we clicked return selection.contains(this) ? selection - : QVector( 1, this ); + : QVector( 1, this ); } -void TrackContentObjectView::remove( QVector tcovs ) +void ClipView::remove( QVector clipvs ) { - for( auto tcov: tcovs ) + for( auto clipv: clipvs ) { // No need to check if it's nullptr because we check when building the QVector - tcov->remove(); + clipv->remove(); } } -void TrackContentObjectView::copy( QVector tcovs ) +void ClipView::copy( QVector clipvs ) { // For copyStringPair() using namespace Clipboard; - // Write the TCOs to a DataFile for copying - DataFile dataFile = createTCODataFiles( tcovs ); + // Write the Clips to a DataFile for copying + DataFile dataFile = createClipDataFiles( clipvs ); - // Copy the TCO type as a key and the TCO data file to the clipboard - copyStringPair( QString( "tco_%1" ).arg( m_tco->getTrack()->type() ), + // Copy the Clip type as a key and the Clip data file to the clipboard + copyStringPair( QString( "clip_%1" ).arg( m_clip->getTrack()->type() ), dataFile.toString() ); } -void TrackContentObjectView::cut( QVector tcovs ) +void ClipView::cut( QVector clipvs ) { - // Copy the selected TCOs - copy( tcovs ); + // Copy the selected Clips + copy( clipvs ); - // Now that the TCOs are copied we can delete them, since we are cutting - remove( tcovs ); + // Now that the Clips are copied we can delete them, since we are cutting + remove( clipvs ); } -void TrackContentObjectView::paste() +void ClipView::paste() { // For getMimeData() using namespace Clipboard; // If possible, paste the selection on the TimePos of the selected Track and remove it - TimePos tcoPos = TimePos( m_tco->startPosition() ); + TimePos clipPos = TimePos( m_clip->startPosition() ); TrackContentWidget *tcw = getTrackView()->getTrackContentWidget(); - if( tcw->pasteSelection( tcoPos, getMimeData() ) ) + if( tcw->pasteSelection( clipPos, getMimeData() ) ) { - // If we succeed on the paste we delete the TCO we pasted on + // If we succeed on the paste we delete the Clip we pasted on remove(); } } -void TrackContentObjectView::toggleMute( QVector tcovs ) +void ClipView::toggleMute( QVector clipvs ) { - for( auto tcov: tcovs ) + for( auto clipv: clipvs ) { - // No need to check for nullptr because we check while building the tcovs QVector - tcov->getTrackContentObject()->toggleMute(); + // No need to check for nullptr because we check while building the clipvs QVector + clipv->getClip()->toggleMute(); } } -bool TrackContentObjectView::canMergeSelection(QVector tcovs) +bool ClipView::canMergeSelection(QVector clipvs) { - // Can't merge a single TCO - if (tcovs.size() < 2) { return false; } + // Can't merge a single Clip + if (clipvs.size() < 2) { return false; } - // We check if the owner of the first TCO is an Instrument Track - bool isInstrumentTrack = dynamic_cast(tcovs.at(0)->getTrackView()); + // We check if the owner of the first Clip is an Instrument Track + bool isInstrumentTrack = dynamic_cast(clipvs.at(0)->getTrackView()); - // Then we create a set with all the TCOs owners + // Then we create a set with all the Clips owners std::set ownerTracks; - for (auto tcov: tcovs) { ownerTracks.insert(tcov->getTrackView()); } + for (auto clipv: clipvs) { ownerTracks.insert(clipv->getTrackView()); } // Can merge if there's only one owner track and it's an Instrument Track return isInstrumentTrack && ownerTracks.size() == 1; } -void TrackContentObjectView::mergeTCOs(QVector tcovs) +void ClipView::mergeClips(QVector clipvs) { - // Get the track that we are merging TCOs in + // Get the track that we are merging Clips in InstrumentTrack* track = - dynamic_cast(tcovs.at(0)->getTrackView()->getTrack()); + dynamic_cast(clipvs.at(0)->getTrackView()->getTrack()); if (!track) { - qWarning("Warning: Couldn't retrieve InstrumentTrack in mergeTCOs()"); + qWarning("Warning: Couldn't retrieve InstrumentTrack in mergeClips()"); return; } @@ -1201,43 +1201,43 @@ void TrackContentObjectView::mergeTCOs(QVector tcovs) track->addJournalCheckPoint(); track->saveJournallingState(false); - // Find the earliest position of all the selected TCOVs - const auto earliestTCOV = std::min_element(tcovs.constBegin(), tcovs.constEnd(), - [](TrackContentObjectView* a, TrackContentObjectView* b) + // Find the earliest position of all the selected ClipVs + const auto earliestClipV = std::min_element(clipvs.constBegin(), clipvs.constEnd(), + [](ClipView* a, ClipView* b) { - return a->getTrackContentObject()->startPosition() < - b->getTrackContentObject()->startPosition(); + return a->getClip()->startPosition() < + b->getClip()->startPosition(); } ); - const TimePos earliestPos = (*earliestTCOV)->getTrackContentObject()->startPosition(); + const TimePos earliestPos = (*earliestClipV)->getClip()->startPosition(); // Create a pattern where all notes will be added - Pattern* newPattern = dynamic_cast(track->createTCO(earliestPos)); + Pattern* newPattern = dynamic_cast(track->createClip(earliestPos)); if (!newPattern) { - qWarning("Warning: Failed to convert TCO to Pattern on mergeTCOs"); + qWarning("Warning: Failed to convert Clip to Pattern on mergeClips"); return; } newPattern->saveJournallingState(false); - // Add the notes and remove the TCOs that are being merged - for (auto tcov: tcovs) + // Add the notes and remove the Clips that are being merged + for (auto clipv: clipvs) { - // Convert TCOV to PatternView - PatternView* pView = dynamic_cast(tcov); + // Convert ClipV to PatternView + PatternView* pView = dynamic_cast(clipv); if (!pView) { - qWarning("Warning: Non-pattern TCO on InstrumentTrack"); + qWarning("Warning: Non-pattern Clip on InstrumentTrack"); continue; } - NoteVector currentTCONotes = pView->getPattern()->notes(); + NoteVector currentClipNotes = pView->getPattern()->notes(); TimePos pViewPos = pView->getPattern()->startPosition(); - for (Note* note: currentTCONotes) + for (Note* note: currentClipNotes) { Note* newNote = newPattern->addNote(*note, false); TimePos originalNotePos = newNote->pos(); @@ -1246,9 +1246,9 @@ void TrackContentObjectView::mergeTCOs(QVector tcovs) // We disable the journalling system before removing, so the // removal doesn't get added to the undo/redo history - tcov->getTrackContentObject()->saveJournallingState(false); - // No need to check for nullptr because we check while building the tcovs QVector - tcov->remove(); + clipv->getClip()->saveJournallingState(false); + // No need to check for nullptr because we check while building the clipvs QVector + clipv->remove(); } // Update length since we might have moved notes beyond the end of the pattern length @@ -1270,27 +1270,27 @@ void TrackContentObjectView::mergeTCOs(QVector tcovs) * * \return the number of pixels per bar. */ -float TrackContentObjectView::pixelsPerBar() +float ClipView::pixelsPerBar() { return m_trackView->trackContainerView()->pixelsPerBar(); } /*! \brief Save the offsets between all selected tracks and a clicked track */ -void TrackContentObjectView::setInitialOffsets() +void ClipView::setInitialOffsets() { QVector so = m_trackView->trackContainerView()->selectedObjects(); QVector offsets; for( QVector::iterator it = so.begin(); it != so.end(); ++it ) { - TrackContentObjectView * tcov = - dynamic_cast( *it ); - if( tcov == NULL ) + ClipView * clipv = + dynamic_cast( *it ); + if( clipv == NULL ) { continue; } - offsets.push_back( tcov->m_tco->startPosition() - m_initialTCOPos ); + offsets.push_back( clipv->m_clip->startPosition() - m_initialClipPos ); } m_initialOffsets = offsets; @@ -1304,7 +1304,7 @@ void TrackContentObjectView::setInitialOffsets() * \param _me The QMouseEvent. * \param distance The threshold distance that the mouse has moved to return true. */ -bool TrackContentObjectView::mouseMovedDistance( QMouseEvent * me, int distance ) +bool ClipView::mouseMovedDistance( QMouseEvent * me, int distance ) { QPoint dPos = mapToGlobal( me->pos() ) - m_initialMouseGlobalPos; const int pixelsMoved = dPos.manhattanLength(); @@ -1314,7 +1314,7 @@ bool TrackContentObjectView::mouseMovedDistance( QMouseEvent * me, int distance -bool TrackContentObjectView::unquantizedModHeld( QMouseEvent * me ) +bool ClipView::unquantizedModHeld( QMouseEvent * me ) { return me->modifiers() & Qt::ControlModifier || me->modifiers() & Qt::AltModifier; } @@ -1322,19 +1322,19 @@ bool TrackContentObjectView::unquantizedModHeld( QMouseEvent * me ) -/*! \brief Calculate the new position of a dragged TCO from a mouse event +/*! \brief Calculate the new position of a dragged Clip from a mouse event * * * \param me The QMouseEvent */ -TimePos TrackContentObjectView::draggedTCOPos( QMouseEvent * me ) +TimePos ClipView::draggedClipPos( QMouseEvent * me ) { //Pixels per bar const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); // The pixel distance that the mouse has moved const int mouseOff = mapToGlobal(me->pos()).x() - m_initialMouseGlobalPos.x(); - TimePos newPos = m_initialTCOPos + mouseOff * TimePos::ticksPerBar() / ppb; - TimePos offset = newPos - m_initialTCOPos; + TimePos newPos = m_initialClipPos + mouseOff * TimePos::ticksPerBar() / ppb; + TimePos offset = newPos - m_initialClipPos; // If the user is holding alt, or pressed ctrl after beginning the drag, don't quantize if ( me->button() != Qt::NoButton || unquantizedModHeld(me) ) { // We want to preserve this adjusted offset, even if the user switches to snapping @@ -1345,22 +1345,22 @@ TimePos TrackContentObjectView::draggedTCOPos( QMouseEvent * me ) // or end position, whichever is closest to the actual position TimePos startQ = newPos.quantize( gui->songEditor()->m_editor->getSnapSize() ); // Find start position that gives snapped clip end position - TimePos endQ = ( newPos + m_tco->length() ); + TimePos endQ = ( newPos + m_clip->length() ); endQ = endQ.quantize( gui->songEditor()->m_editor->getSnapSize() ); - endQ = endQ - m_tco->length(); + endQ = endQ - m_clip->length(); // Select the position closest to actual position if ( abs(newPos - startQ) < abs(newPos - endQ) ) newPos = startQ; else newPos = endQ; } else { // Otherwise, quantize moved distance (preserves user offsets) - newPos = m_initialTCOPos + offset.quantize( gui->songEditor()->m_editor->getSnapSize() ); + newPos = m_initialClipPos + offset.quantize( gui->songEditor()->m_editor->getSnapSize() ); } return newPos; } -int TrackContentObjectView::knifeMarkerPos( QMouseEvent * me ) +int ClipView::knifeMarkerPos( QMouseEvent * me ) { //Position relative to start of clip const int markerPos = me->pos().x(); @@ -1382,64 +1382,64 @@ int TrackContentObjectView::knifeMarkerPos( QMouseEvent * me ) -TimePos TrackContentObjectView::quantizeSplitPos( TimePos midiPos, bool shiftMode ) +TimePos ClipView::quantizeSplitPos( TimePos midiPos, bool shiftMode ) { const float snapSize = gui->songEditor()->m_editor->getSnapSize(); if ( shiftMode ) { //If shift is held we quantize the length of the new left clip... const TimePos leftPos = midiPos.quantize( snapSize ); //...or right clip... - const TimePos rightOff = m_tco->length() - midiPos; - const TimePos rightPos = m_tco->length() - rightOff.quantize( snapSize ); + const TimePos rightOff = m_clip->length() - midiPos; + const TimePos rightPos = m_clip->length() - rightOff.quantize( snapSize ); //...whichever gives a position closer to the cursor if ( abs(leftPos - midiPos) < abs(rightPos - midiPos) ) { return leftPos; } else { return rightPos; } } else { - return TimePos(midiPos + m_initialTCOPos).quantize( snapSize ) - m_initialTCOPos; + return TimePos(midiPos + m_initialClipPos).quantize( snapSize ) - m_initialClipPos; } } -// Return the color that the TCO's background should be -QColor TrackContentObjectView::getColorForDisplay( QColor defaultColor ) +// Return the color that the Clip's background should be +QColor ClipView::getColorForDisplay( QColor defaultColor ) { - // Get the pure TCO color - auto tcoColor = m_tco->hasColor() - ? m_tco->usesCustomClipColor() - ? m_tco->color() - : m_tco->getTrack()->color() + // Get the pure Clip color + auto clipColor = m_clip->hasColor() + ? m_clip->usesCustomClipColor() + ? m_clip->color() + : m_clip->getTrack()->color() : defaultColor; // Set variables QColor c, mutedCustomColor; - bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); - mutedCustomColor = tcoColor; + bool muted = m_clip->getTrack()->isMuted() || m_clip->isMuted(); + mutedCustomColor = clipColor; mutedCustomColor.setHsv( mutedCustomColor.hsvHue(), mutedCustomColor.hsvSaturation() / 4, mutedCustomColor.value() ); // Change the pure color by state: selected, muted, colored, normal if( isSelected() ) { - c = m_tco->hasColor() + c = m_clip->hasColor() ? ( muted ? mutedCustomColor.darker( 350 ) - : tcoColor.darker( 150 ) ) + : clipColor.darker( 150 ) ) : selectedColor(); } else { if( muted ) { - c = m_tco->hasColor() + c = m_clip->hasColor() ? mutedCustomColor.darker( 250 ) : mutedBackgroundColor(); } else { - c = tcoColor; + c = clipColor; } } diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 60b62d9a275..0671064c0b4 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -862,7 +862,7 @@ bool FileBrowserTreeWidget::openInNewSampleTrack(FileItem* item) // Add the sample clip to the track Engine::mixer()->requestChangeInModel(); - SampleTCO* clip = static_cast(sampleTrack->createTCO(0)); + SampleClip* clip = static_cast(sampleTrack->createClip(0)); clip->setSampleFile(item->fullName()); Engine::mixer()->doneChangeInModel(); return true; diff --git a/src/gui/PatternView.cpp b/src/gui/PatternView.cpp index 9de17fd8bd2..4953ff44a2c 100644 --- a/src/gui/PatternView.cpp +++ b/src/gui/PatternView.cpp @@ -36,7 +36,7 @@ #include "RenameDialog.h" PatternView::PatternView( Pattern* pattern, TrackView* parent ) : - TrackContentObjectView( pattern, parent ), + ClipView( pattern, parent ), m_pat( pattern ), m_paintPixmap(), m_noteFillColor(255, 255, 255, 220), @@ -92,7 +92,7 @@ void PatternView::update() { ToolTip::add(this, m_pat->name()); - TrackContentObjectView::update(); + ClipView::update(); } @@ -182,7 +182,7 @@ void PatternView::constructContextMenu( QMenu * _cm ) void PatternView::mousePressEvent( QMouseEvent * _me ) { - bool displayBB = fixedTCOs() || (pixelsPerBar() >= 96 && m_legacySEBB); + bool displayBB = fixedClips() || (pixelsPerBar() >= 96 && m_legacySEBB); if( _me->button() == Qt::LeftButton && m_pat->m_patternType == Pattern::BeatPattern && displayBB && _me->y() > height() - s_stepBtnOff->height() ) @@ -193,8 +193,8 @@ void PatternView::mousePressEvent( QMouseEvent * _me ) { // get the step number that was clicked on and // do calculations in floats to prevent rounding errors... - float tmp = ( ( float(_me->x()) - TCO_BORDER_WIDTH ) * - float( m_pat -> m_steps ) ) / float(width() - TCO_BORDER_WIDTH*2); + float tmp = ( ( float(_me->x()) - CLIP_BORDER_WIDTH ) * + float( m_pat -> m_steps ) ) / float(width() - CLIP_BORDER_WIDTH*2); int step = int( tmp ); @@ -232,7 +232,7 @@ void PatternView::mousePressEvent( QMouseEvent * _me ) // if not in beat/bassline -mode, let parent class handle the event { - TrackContentObjectView::mousePressEvent( _me ); + ClipView::mousePressEvent( _me ); } } @@ -243,7 +243,7 @@ void PatternView::mouseDoubleClickEvent(QMouseEvent *_me) _me->ignore(); return; } - if( m_pat->m_patternType == Pattern::MelodyPattern || !fixedTCOs() ) + if( m_pat->m_patternType == Pattern::MelodyPattern || !fixedClips() ) { openInPianoRoll(); } @@ -255,13 +255,13 @@ void PatternView::mouseDoubleClickEvent(QMouseEvent *_me) void PatternView::wheelEvent(QWheelEvent * we) { if(m_pat->m_patternType == Pattern::BeatPattern && - (fixedTCOs() || pixelsPerBar() >= 96) && + (fixedClips() || pixelsPerBar() >= 96) && position(we).y() > height() - s_stepBtnOff->height()) { // get the step number that was wheeled on and // do calculations in floats to prevent rounding errors... - float tmp = ((float(position(we).x()) - TCO_BORDER_WIDTH) * - float(m_pat -> m_steps)) / float(width() - TCO_BORDER_WIDTH*2); + float tmp = ((float(position(we).x()) - CLIP_BORDER_WIDTH) * + float(m_pat -> m_steps)) / float(width() - CLIP_BORDER_WIDTH*2); int step = int( tmp ); @@ -300,7 +300,7 @@ void PatternView::wheelEvent(QWheelEvent * we) } else { - TrackContentObjectView::wheelEvent(we); + ClipView::wheelEvent(we); } } @@ -336,7 +336,7 @@ void PatternView::paintEvent( QPaintEvent * ) if( beatPattern ) { - // Do not paint BBTCOs how we paint pattern TCOs + // Do not paint BBClips how we paint pattern Clips c = BBPatternBackground(); } else @@ -366,9 +366,9 @@ void PatternView::paintEvent( QPaintEvent * ) bool const drawName = !m_pat->name().isEmpty(); bool const drawTextBox = !beatPattern && drawName; - // TODO Warning! This might cause problems if TrackContentObjectView::paintTextLabel changes + // TODO Warning! This might cause problems if ClipView::paintTextLabel changes int textBoxHeight = 0; - const int textTop = TCO_BORDER_WIDTH + 1; + const int textTop = CLIP_BORDER_WIDTH + 1; if (drawTextBox) { QFont labelFont = this->font(); @@ -379,17 +379,17 @@ void PatternView::paintEvent( QPaintEvent * ) } // Compute pixels per bar - const int baseWidth = fixedTCOs() ? parentWidget()->width() - 2 * TCO_BORDER_WIDTH - : width() - TCO_BORDER_WIDTH; + const int baseWidth = fixedClips() ? parentWidget()->width() - 2 * CLIP_BORDER_WIDTH + : width() - CLIP_BORDER_WIDTH; const float pixelsPerBar = baseWidth / (float) m_pat->length().getBar(); // Length of one bar/beat in the [0,1] x [0,1] coordinate system const float barLength = 1. / m_pat->length().getBar(); const float tickLength = barLength / TimePos::ticksPerBar(); - const int x_base = TCO_BORDER_WIDTH; + const int x_base = CLIP_BORDER_WIDTH; - bool displayBB = fixedTCOs() || (pixelsPerBar >= 96 && m_legacySEBB); + bool displayBB = fixedClips() || (pixelsPerBar >= 96 && m_legacySEBB); // melody pattern paint event NoteVector const & noteCollection = m_pat->m_notes; if( m_pat->m_patternType == Pattern::MelodyPattern && !noteCollection.empty() ) @@ -514,7 +514,7 @@ void PatternView::paintEvent( QPaintEvent * ) QPixmap stepoffl; const int steps = qMax( 1, m_pat->m_steps ); - const int w = width() - 2 * TCO_BORDER_WIDTH; + const int w = width() - 2 * CLIP_BORDER_WIDTH; // scale step graphics to fit the beat pattern length stepon0 = s_stepBtnOn0->scaled( w / steps, @@ -539,7 +539,7 @@ void PatternView::paintEvent( QPaintEvent * ) Note * n = m_pat->noteAtStep( it ); // figure out x and y coordinates for step graphic - const int x = TCO_BORDER_WIDTH + static_cast( it * w / steps ); + const int x = CLIP_BORDER_WIDTH + static_cast( it * w / steps ); const int y = height() - s_stepBtnOff->height() - 1; if( n ) @@ -577,12 +577,12 @@ void PatternView::paintEvent( QPaintEvent * ) for( bar_t t = 1; t < m_pat->length().getBar(); ++t ) { p.drawLine( x_base + static_cast( pixelsPerBar * t ) - 1, - TCO_BORDER_WIDTH, x_base + static_cast( - pixelsPerBar * t ) - 1, TCO_BORDER_WIDTH + lineSize ); + CLIP_BORDER_WIDTH, x_base + static_cast( + pixelsPerBar * t ) - 1, CLIP_BORDER_WIDTH + lineSize ); p.drawLine( x_base + static_cast( pixelsPerBar * t ) - 1, - rect().bottom() - ( lineSize + TCO_BORDER_WIDTH ), + rect().bottom() - ( lineSize + CLIP_BORDER_WIDTH ), x_base + static_cast( pixelsPerBar * t ) - 1, - rect().bottom() - TCO_BORDER_WIDTH ); + rect().bottom() - CLIP_BORDER_WIDTH ); } // pattern name @@ -591,12 +591,12 @@ void PatternView::paintEvent( QPaintEvent * ) paintTextLabel(m_pat->name(), p); } - if( !( fixedTCOs() && beatPattern ) ) + if( !( fixedClips() && beatPattern ) ) { // inner border p.setPen( c.lighter( current ? 160 : 130 ) ); - p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, - rect().bottom() - TCO_BORDER_WIDTH ); + p.drawRect( 1, 1, rect().right() - CLIP_BORDER_WIDTH, + rect().bottom() - CLIP_BORDER_WIDTH ); // outer border p.setPen( current ? c.lighter( 130 ) : c.darker( 300 ) ); @@ -606,7 +606,7 @@ void PatternView::paintEvent( QPaintEvent * ) // draw the 'muted' pixmap only if the pattern was manually muted if( m_pat->isMuted() ) { - const int spacing = TCO_BORDER_WIDTH; + const int spacing = CLIP_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); diff --git a/src/gui/SampleTCOView.cpp b/src/gui/SampleClipView.cpp similarity index 63% rename from src/gui/SampleTCOView.cpp rename to src/gui/SampleClipView.cpp index ad8738ca778..e336ec74a13 100644 --- a/src/gui/SampleTCOView.cpp +++ b/src/gui/SampleClipView.cpp @@ -1,5 +1,5 @@ /* - * SampleTCOView.cpp + * SampleClipView.cpp * * Copyright (c) 2005-2014 Tobias Doerffel * @@ -22,7 +22,7 @@ * */ -#include "SampleTCOView.h" +#include "SampleClipView.h" #include #include @@ -34,40 +34,40 @@ #include "StringPairDrag.h" #include "ToolTip.h" -SampleTCOView::SampleTCOView( SampleTCO * _tco, TrackView * _tv ) : - TrackContentObjectView( _tco, _tv ), - m_tco( _tco ), +SampleClipView::SampleClipView( SampleClip * _clip, TrackView * _tv ) : + ClipView( _clip, _tv ), + m_clip( _clip ), m_paintPixmap() { // update UI and tooltip updateSample(); - // track future changes of SampleTCO - connect(m_tco, SIGNAL(sampleChanged()), this, SLOT(updateSample())); + // track future changes of SampleClip + connect(m_clip, SIGNAL(sampleChanged()), this, SLOT(updateSample())); - connect(m_tco, SIGNAL(wasReversed()), this, SLOT(update())); + connect(m_clip, SIGNAL(wasReversed()), this, SLOT(update())); setStyle( QApplication::style() ); } -void SampleTCOView::updateSample() +void SampleClipView::updateSample() { update(); // set tooltip to filename so that user can see what sample this - // sample-tco contains - ToolTip::add( this, ( m_tco->m_sampleBuffer->audioFile() != "" ) ? - PathUtil::toAbsolute(m_tco->m_sampleBuffer->audioFile()) : + // sample-clip contains + ToolTip::add( this, ( m_clip->m_sampleBuffer->audioFile() != "" ) ? + PathUtil::toAbsolute(m_clip->m_sampleBuffer->audioFile()) : tr( "Double-click to open sample" ) ); } -void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme ) +void SampleClipView::contextMenuEvent( QContextMenuEvent * _cme ) { - // Depending on whether we right-clicked a selection or an individual TCO we will have + // Depending on whether we right-clicked a selection or an individual Clip we will have // different labels for the actions. - bool individualTCO = getClickedTCOs().size() <= 1; + bool individualClip = getClickedClips().size() <= 1; if( _cme->modifiers() ) { @@ -76,11 +76,11 @@ void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme ) QMenu contextMenu( this ); - if( fixedTCOs() == false ) + if( fixedClips() == false ) { contextMenu.addAction( embed::getIconPixmap( "cancel" ), - individualTCO + individualClip ? tr("Delete (middle mousebutton)") : tr("Delete selection (middle mousebutton)"), [this](){ contextMenuAction( Remove ); } ); @@ -89,7 +89,7 @@ void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme ) contextMenu.addAction( embed::getIconPixmap( "edit_cut" ), - individualTCO + individualClip ? tr("Cut") : tr("Cut selection"), [this](){ contextMenuAction( Cut ); } ); @@ -97,7 +97,7 @@ void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme ) contextMenu.addAction( embed::getIconPixmap( "edit_copy" ), - individualTCO + individualClip ? tr("Copy") : tr("Copy selection"), [this](){ contextMenuAction( Copy ); } ); @@ -111,14 +111,14 @@ void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme ) contextMenu.addAction( embed::getIconPixmap( "muted" ), - (individualTCO + (individualClip ? tr("Mute/unmute (<%1> + middle click)") : tr("Mute/unmute selection (<%1> + middle click)")).arg(UI_CTRL_KEY), [this](){ contextMenuAction( Mute ); } ); /*contextMenu.addAction( embed::getIconPixmap( "record" ), tr( "Set/clear record" ), - m_tco, SLOT( toggleRecord() ) );*/ + m_clip, SLOT( toggleRecord() ) );*/ contextMenu.addAction( embed::getIconPixmap("flip_x"), @@ -142,12 +142,12 @@ void SampleTCOView::contextMenuEvent( QContextMenuEvent * _cme ) -void SampleTCOView::dragEnterEvent( QDragEnterEvent * _dee ) +void SampleClipView::dragEnterEvent( QDragEnterEvent * _dee ) { if( StringPairDrag::processDragEnterEvent( _dee, "samplefile,sampledata" ) == false ) { - TrackContentObjectView::dragEnterEvent( _dee ); + ClipView::dragEnterEvent( _dee ); } } @@ -156,85 +156,85 @@ void SampleTCOView::dragEnterEvent( QDragEnterEvent * _dee ) -void SampleTCOView::dropEvent( QDropEvent * _de ) +void SampleClipView::dropEvent( QDropEvent * _de ) { if( StringPairDrag::decodeKey( _de ) == "samplefile" ) { - m_tco->setSampleFile( StringPairDrag::decodeValue( _de ) ); + m_clip->setSampleFile( StringPairDrag::decodeValue( _de ) ); _de->accept(); } else if( StringPairDrag::decodeKey( _de ) == "sampledata" ) { - m_tco->m_sampleBuffer->loadFromBase64( + m_clip->m_sampleBuffer->loadFromBase64( StringPairDrag::decodeValue( _de ) ); - m_tco->updateLength(); + m_clip->updateLength(); update(); _de->accept(); Engine::getSong()->setModified(); } else { - TrackContentObjectView::dropEvent( _de ); + ClipView::dropEvent( _de ); } } -void SampleTCOView::mousePressEvent( QMouseEvent * _me ) +void SampleClipView::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton && _me->modifiers() & Qt::ControlModifier && _me->modifiers() & Qt::ShiftModifier ) { - m_tco->toggleRecord(); + m_clip->toggleRecord(); } else { if( _me->button() == Qt::MiddleButton && _me->modifiers() == Qt::ControlModifier ) { - SampleTCO * sTco = dynamic_cast( getTrackContentObject() ); - if( sTco ) + SampleClip * sClip = dynamic_cast( getClip() ); + if( sClip ) { - sTco->updateTrackTcos(); + sClip->updateTrackClips(); } } - TrackContentObjectView::mousePressEvent( _me ); + ClipView::mousePressEvent( _me ); } } -void SampleTCOView::mouseReleaseEvent(QMouseEvent *_me) +void SampleClipView::mouseReleaseEvent(QMouseEvent *_me) { if( _me->button() == Qt::MiddleButton && !_me->modifiers() ) { - SampleTCO * sTco = dynamic_cast( getTrackContentObject() ); - if( sTco ) + SampleClip * sClip = dynamic_cast( getClip() ); + if( sClip ) { - sTco->playbackPositionChanged(); + sClip->playbackPositionChanged(); } } - TrackContentObjectView::mouseReleaseEvent( _me ); + ClipView::mouseReleaseEvent( _me ); } -void SampleTCOView::mouseDoubleClickEvent( QMouseEvent * ) +void SampleClipView::mouseDoubleClickEvent( QMouseEvent * ) { - QString af = m_tco->m_sampleBuffer->openAudioFile(); + QString af = m_clip->m_sampleBuffer->openAudioFile(); if ( af.isEmpty() ) {} //Don't do anything if no file is loaded - else if ( af == m_tco->m_sampleBuffer->audioFile() ) + else if ( af == m_clip->m_sampleBuffer->audioFile() ) { //Instead of reloading the existing file, just reset the size - int length = (int) ( m_tco->m_sampleBuffer->frames() / Engine::framesPerTick() ); - m_tco->changeLength(length); + int length = (int) ( m_clip->m_sampleBuffer->frames() / Engine::framesPerTick() ); + m_clip->changeLength(length); } else { //Otherwise load the new file as ususal - m_tco->setSampleFile( af ); + m_clip->setSampleFile( af ); Engine::getSong()->setModified(); } } @@ -242,7 +242,7 @@ void SampleTCOView::mouseDoubleClickEvent( QMouseEvent * ) -void SampleTCOView::paintEvent( QPaintEvent * pe ) +void SampleClipView::paintEvent( QPaintEvent * pe ) { QPainter painter( this ); @@ -261,7 +261,7 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) QPainter p( &m_paintPixmap ); - bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); + bool muted = m_clip->getTrack()->isMuted() || m_clip->isMuted(); bool selected = isSelected(); QLinearGradient lingrad(0, 0, 0, height()); @@ -284,13 +284,13 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) p.fillRect( rect(), c ); } - auto tcoColor = m_tco->hasColor() - ? (m_tco->usesCustomClipColor() - ? m_tco->color() - : m_tco->getTrack()->color()) + auto clipColor = m_clip->hasColor() + ? (m_clip->usesCustomClipColor() + ? m_clip->color() + : m_clip->getTrack()->color()) : painter.pen().brush().color(); - p.setPen(tcoColor); + p.setPen(clipColor); if (muted) { @@ -303,22 +303,22 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) p.setPen(p.pen().brush().color().darker(150)); } - const int spacing = TCO_BORDER_WIDTH + 1; - const float ppb = fixedTCOs() ? - ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) - / (float) m_tco->length().getBar() : + const int spacing = CLIP_BORDER_WIDTH + 1; + const float ppb = fixedClips() ? + ( parentWidget()->width() - 2 * CLIP_BORDER_WIDTH ) + / (float) m_clip->length().getBar() : pixelsPerBar(); float nom = Engine::getSong()->getTimeSigModel().getNumerator(); float den = Engine::getSong()->getTimeSigModel().getDenominator(); float ticksPerBar = DefaultTicksPerBar * nom / den; - float offset = m_tco->startTimeOffset() / ticksPerBar * pixelsPerBar(); - QRect r = QRect( TCO_BORDER_WIDTH + offset, spacing, - qMax( static_cast( m_tco->sampleLength() * ppb / ticksPerBar ), 1 ), rect().bottom() - 2 * spacing ); - m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); + float offset = m_clip->startTimeOffset() / ticksPerBar * pixelsPerBar(); + QRect r = QRect( CLIP_BORDER_WIDTH + offset, spacing, + qMax( static_cast( m_clip->sampleLength() * ppb / ticksPerBar ), 1 ), rect().bottom() - 2 * spacing ); + m_clip->m_sampleBuffer->visualize( p, r, pe->rect() ); - QString name = PathUtil::cleanName(m_tco->m_sampleBuffer->audioFile()); + QString name = PathUtil::cleanName(m_clip->m_sampleBuffer->audioFile()); paintTextLabel(name, p); // disable antialiasing for borders, since its not needed @@ -326,17 +326,17 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) // inner border p.setPen( c.lighter( 135 ) ); - p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, - rect().bottom() - TCO_BORDER_WIDTH ); + p.drawRect( 1, 1, rect().right() - CLIP_BORDER_WIDTH, + rect().bottom() - CLIP_BORDER_WIDTH ); // outer border p.setPen( c.darker( 200 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted - if( m_tco->isMuted() ) + if( m_clip->isMuted() ) { - const int spacing = TCO_BORDER_WIDTH; + const int spacing = CLIP_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); @@ -348,7 +348,7 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) } // recording sample tracks is not possible at the moment - /* if( m_tco->isRecord() ) + /* if( m_clip->isRecord() ) { p.setFont( pointSize<7>( p.font() ) ); @@ -369,9 +369,9 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) -void SampleTCOView::reverseSample() +void SampleClipView::reverseSample() { - m_tco->sampleBuffer()->setReversed(!m_tco->sampleBuffer()->reversed()); + m_clip->sampleBuffer()->setReversed(!m_clip->sampleBuffer()->reversed()); Engine::getSong()->setModified(); update(); } @@ -379,31 +379,31 @@ void SampleTCOView::reverseSample() -//! Split this TCO. +//! Split this Clip. /*! \param pos the position of the split, relative to the start of the clip */ -bool SampleTCOView::splitTCO( const TimePos pos ) +bool SampleClipView::splitClip( const TimePos pos ) { setMarkerEnabled( false ); - const TimePos splitPos = m_initialTCOPos + pos; + const TimePos splitPos = m_initialClipPos + pos; - //Don't split if we slid off the TCO or if we're on the clip's start/end + //Don't split if we slid off the Clip or if we're on the clip's start/end //Cutting at exactly the start/end position would create a zero length //clip (bad), and a clip the same length as the original one (pointless). - if ( splitPos > m_initialTCOPos && splitPos < m_initialTCOEnd ) + if ( splitPos > m_initialClipPos && splitPos < m_initialClipEnd ) { - m_tco->getTrack()->addJournalCheckPoint(); - m_tco->getTrack()->saveJournallingState( false ); + m_clip->getTrack()->addJournalCheckPoint(); + m_clip->getTrack()->saveJournallingState( false ); - SampleTCO * rightTCO = new SampleTCO ( *m_tco ); + SampleClip * rightClip = new SampleClip ( *m_clip ); - m_tco->changeLength( splitPos - m_initialTCOPos ); + m_clip->changeLength( splitPos - m_initialClipPos ); - rightTCO->movePosition( splitPos ); - rightTCO->changeLength( m_initialTCOEnd - splitPos ); - rightTCO->setStartTimeOffset( m_tco->startTimeOffset() - m_tco->length() ); + rightClip->movePosition( splitPos ); + rightClip->changeLength( m_initialClipEnd - splitPos ); + rightClip->setStartTimeOffset( m_clip->startTimeOffset() - m_clip->length() ); - m_tco->getTrack()->restoreJournallingState(); + m_clip->getTrack()->restoreJournallingState(); return true; } else { return false; } diff --git a/src/gui/SampleTrackView.cpp b/src/gui/SampleTrackView.cpp index 743cffcafb8..a32b786dca4 100644 --- a/src/gui/SampleTrackView.cpp +++ b/src/gui/SampleTrackView.cpp @@ -193,14 +193,14 @@ void SampleTrackView::dropEvent(QDropEvent *de) ? trackHeadWidth : de->pos().x(); - TimePos tcoPos = trackContainerView()->fixedTCOs() + TimePos clipPos = trackContainerView()->fixedClips() ? TimePos(0) : TimePos(((xPos - trackHeadWidth) / trackContainerView()->pixelsPerBar() * TimePos::ticksPerBar()) + trackContainerView()->currentPosition() ).quantize(1.0); - SampleTCO * sTco = static_cast(getTrack()->createTCO(tcoPos)); - if (sTco) { sTco->setSampleFile(value); } + SampleClip * sClip = static_cast(getTrack()->createClip(clipPos)); + if (sClip) { sClip->setSampleFile(value); } } } diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index e7e7ca113e0..f21c74e2a19 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -324,7 +324,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) } else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) ) { - m_action = SelectSongTCO; + m_action = SelectSongClip; m_initalXSelect = event->x(); } else if( event->button() == Qt::RightButton ) @@ -416,7 +416,7 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) update(); break; } - case SelectSongTCO: + case SelectSongClip: emit regionSelectedFromPixels( m_initalXSelect , event->x() ); break; @@ -432,6 +432,6 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event ) { delete m_hint; m_hint = NULL; - if ( m_action == SelectSongTCO ) { emit selectionFinished(); } + if ( m_action == SelectSongClip ) { emit selectionFinished(); } m_action = NoAction; } diff --git a/src/gui/TrackView.cpp b/src/gui/TrackView.cpp index a9387ea0d80..d813d18bebc 100644 --- a/src/gui/TrackView.cpp +++ b/src/gui/TrackView.cpp @@ -44,7 +44,7 @@ #include "ToolTip.h" #include "Track.h" #include "TrackContainerView.h" -#include "TrackContentObjectView.h" +#include "ClipView.h" /*! \brief Create a new track View. @@ -89,8 +89,8 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) : connect( m_track, SIGNAL( destroyedTrack() ), this, SLOT( close() ) ); connect( m_track, - SIGNAL( trackContentObjectAdded( TrackContentObject * ) ), - this, SLOT( createTCOView( TrackContentObject * ) ), + SIGNAL( trackContentObjectAdded( Clip * ) ), + this, SLOT( createClipView( Clip * ) ), Qt::QueuedConnection ); connect( &m_track->m_mutedModel, SIGNAL( dataChanged() ), @@ -108,12 +108,12 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) : connect( &m_trackOperationsWidget, SIGNAL( colorReset() ), m_track, SLOT( trackColorReset() ) ); - // create views for already existing TCOs - for( Track::tcoVector::iterator it = + // create views for already existing Clips + for( Track::clipVector::iterator it = m_track->m_trackContentObjects.begin(); it != m_track->m_trackContentObjects.end(); ++it ) { - createTCOView( *it ); + createClipView( *it ); } m_trackContainerView->addTrackView( this ); @@ -161,7 +161,7 @@ void TrackView::resizeEvent( QResizeEvent * re ) void TrackView::update() { m_trackContentWidget.update(); - if( !m_trackContainerView->fixedTCOs() ) + if( !m_trackContainerView->fixedClips() ) { m_trackContentWidget.changePosition(); } @@ -424,19 +424,19 @@ void TrackView::paintEvent( QPaintEvent * pe ) -/*! \brief Create a TrackContentObject View in this track View. +/*! \brief Create a Clip View in this track View. * - * \param tco the TrackContentObject to create the view for. + * \param clip the Clip to create the view for. * \todo is this a good description for what this method does? */ -void TrackView::createTCOView( TrackContentObject * tco ) +void TrackView::createClipView( Clip * clip ) { - TrackContentObjectView * tv = tco->createView( this ); - if( tco->getSelectViewOnCreate() == true ) + ClipView * tv = clip->createView( this ); + if( clip->getSelectViewOnCreate() == true ) { tv->setSelected( true ); } - tco->selectViewOnCreate( false ); + clip->selectViewOnCreate( false ); } diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index f40d30bdac8..c4b76dc1948 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -59,12 +59,12 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : "compacttrackbuttons" ).toInt() ) { setMinimumWidth( TRACK_OP_WIDTH_COMPACT + DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT - + 2 * TCO_BORDER_WIDTH + 384 ); + + 2 * CLIP_BORDER_WIDTH + 384 ); } else { setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH - + 2 * TCO_BORDER_WIDTH + 384 ); + + 2 * CLIP_BORDER_WIDTH + 384 ); } @@ -196,7 +196,7 @@ void BBTrackContainerView::removeSteps() { if( ( *it )->type() == Track::InstrumentTrack ) { - Pattern* p = static_cast( ( *it )->getTCO( m_bbtc->currentBB() ) ); + Pattern* p = static_cast( ( *it )->getClip( m_bbtc->currentBB() ) ); p->removeSteps(); } } @@ -225,7 +225,7 @@ void BBTrackContainerView::removeBBView(int bb) { for( TrackView* view : trackViews() ) { - view->getTrackContentWidget()->removeTCOView( bb ); + view->getTrackContentWidget()->removeClipView( bb ); } } @@ -254,24 +254,24 @@ void BBTrackContainerView::dropEvent(QDropEvent* de) DataFile dataFile( value.toUtf8() ); Track * t = Track::create( dataFile.content().firstChild().toElement(), model() ); - // Ensure BB TCOs exist - bool hasValidBBTCOs = false; - if (t->getTCOs().size() == m_bbtc->numOfBBs()) + // Ensure BB Clips exist + bool hasValidBBClips = false; + if (t->getClips().size() == m_bbtc->numOfBBs()) { - hasValidBBTCOs = true; - for (int i = 0; i < t->getTCOs().size(); ++i) + hasValidBBClips = true; + for (int i = 0; i < t->getClips().size(); ++i) { - if (t->getTCOs()[i]->startPosition() != TimePos(i, 0)) + if (t->getClips()[i]->startPosition() != TimePos(i, 0)) { - hasValidBBTCOs = false; + hasValidBBClips = false; break; } } } - if (!hasValidBBTCOs) + if (!hasValidBBClips) { - t->deleteTCOs(); - t->createTCOsForBB(m_bbtc->numOfBBs() - 1); + t->deleteClips(); + t->createClipsForBB(m_bbtc->numOfBBs() - 1); } m_bbtc->updateAfterTrackAdd(); @@ -304,7 +304,7 @@ void BBTrackContainerView::makeSteps( bool clone ) { if( ( *it )->type() == Track::InstrumentTrack ) { - Pattern* p = static_cast( ( *it )->getTCO( m_bbtc->currentBB() ) ); + Pattern* p = static_cast( ( *it )->getClip( m_bbtc->currentBB() ) ); if( clone ) { p->cloneSteps(); @@ -316,7 +316,7 @@ void BBTrackContainerView::makeSteps( bool clone ) } } -// Creates a clone of the current BB track with the same pattern, but no TCOs in the song editor +// Creates a clone of the current BB track with the same pattern, but no Clips in the song editor // TODO: Avoid repeated code from cloneTrack and clearTrack in TrackOperationsWidget somehow void BBTrackContainerView::clonePattern() { @@ -329,8 +329,8 @@ void BBTrackContainerView::clonePattern() // Clone the track Track *newTrack = bbt->clone(); - // Track still have the TCOs which is undesirable in this case, clear the track + // Track still have the Clips which is undesirable in this case, clear the track newTrack->lock(); - newTrack->deleteTCOs(); + newTrack->deleteClips(); newTrack->unlock(); } diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 17bac949851..860a3b18e3a 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -352,7 +352,7 @@ void SongEditor::selectRegionFromPixels(int xStart, int xEnd) { m_selectRegion = true; - //deselect all tcos + //deselect all clips for (auto &it : findChildren()) { it->setSelected(false); } rubberBand()->setEnabled(true); @@ -419,17 +419,17 @@ void SongEditor::updateRubberband() / pixelsPerBar() * TimePos::ticksPerBar()) + m_currentPosition; - //are tcos in the rect of selection? + //are clips in the rect of selection? for (auto &it : findChildren()) { - TrackContentObjectView * tco = dynamic_cast(it); - if (tco) + ClipView * clip = dynamic_cast(it); + if (clip) { - auto indexOfTrackView = trackViews().indexOf(tco->getTrackView()); + auto indexOfTrackView = trackViews().indexOf(clip->getTrackView()); bool isBeetweenRubberbandViews = indexOfTrackView >= qMin(m_rubberBandStartTrackview, rubberBandTrackview) && indexOfTrackView <= qMax(m_rubberBandStartTrackview, rubberBandTrackview); - bool isBeetweenRubberbandTimePos = tco->getTrackContentObject()->endPosition() >= qMin(m_rubberbandStartTimePos, rubberbandTimePos) - && tco->getTrackContentObject()->startPosition() <= qMax(m_rubberbandStartTimePos, rubberbandTimePos); + bool isBeetweenRubberbandTimePos = clip->getClip()->endPosition() >= qMin(m_rubberbandStartTimePos, rubberbandTimePos) + && clip->getClip()->startPosition() <= qMax(m_rubberbandStartTimePos, rubberbandTimePos); it->setSelected(isBeetweenRubberbandViews && isBeetweenRubberbandTimePos); } } @@ -506,18 +506,18 @@ void SongEditor::keyPressEvent( QKeyEvent * ke ) for( QVector::iterator it = so.begin(); it != so.end(); ++it ) { - TrackContentObjectView * tcov = - dynamic_cast( *it ); - tcov->remove(); + ClipView * clipv = + dynamic_cast( *it ); + clipv->remove(); } } else if( ke->key() == Qt::Key_A && ke->modifiers() & Qt::ControlModifier ) { - selectAllTcos( !isShiftPressed ); + selectAllClips( !isShiftPressed ); } else if( ke->key() == Qt::Key_Escape ) { - selectAllTcos( false ); + selectAllClips( false ); } else { @@ -559,7 +559,7 @@ void SongEditor::wheelEvent( QWheelEvent * we ) // update timeline m_song->m_playPos[Song::Mode_PlaySong].m_timeLine-> setPixelsPerBar( pixelsPerBar() ); - // and make sure, all TCO's are resized and relocated + // and make sure, all Clip's are resized and relocated realignTracks(); } @@ -845,7 +845,7 @@ void SongEditor::zoomingChanged() } -void SongEditor::selectAllTcos( bool select ) +void SongEditor::selectAllClips( bool select ) { QVector so = select ? rubberBand()->selectableObjects() : rubberBand()->selectedObjects(); for( int i = 0; i < so.count(); ++i ) diff --git a/src/gui/widgets/EnvelopeAndLfoView.cpp b/src/gui/widgets/EnvelopeAndLfoView.cpp index 4635dc831e8..a959137d327 100644 --- a/src/gui/widgets/EnvelopeAndLfoView.cpp +++ b/src/gui/widgets/EnvelopeAndLfoView.cpp @@ -305,7 +305,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) void EnvelopeAndLfoView::dragEnterEvent( QDragEnterEvent * _dee ) { StringPairDrag::processDragEnterEvent( _dee, - QString( "samplefile,tco_%1" ).arg( + QString( "samplefile,clip_%1" ).arg( Track::SampleTrack ) ); } @@ -325,7 +325,7 @@ void EnvelopeAndLfoView::dropEvent( QDropEvent * _de ) _de->accept(); update(); } - else if( type == QString( "tco_%1" ).arg( Track::SampleTrack ) ) + else if( type == QString( "clip_%1" ).arg( Track::SampleTrack ) ) { DataFile dataFile( value.toUtf8() ); m_params->m_userWave.setAudioFile( dataFile.content(). diff --git a/src/gui/widgets/TrackContentWidget.cpp b/src/gui/widgets/TrackContentWidget.cpp index d7dee1a1ba1..6d26d2d0339 100644 --- a/src/gui/widgets/TrackContentWidget.cpp +++ b/src/gui/widgets/TrackContentWidget.cpp @@ -40,7 +40,7 @@ #include "SongEditor.h" #include "StringPairDrag.h" #include "TrackContainerView.h" -#include "TrackContentObjectView.h" +#include "ClipView.h" #include "TrackView.h" @@ -137,17 +137,17 @@ void TrackContentWidget::updateBackground() * Adds a(nother) trackContentObjectView to our list of views. We also * check that our position is up-to-date. * - * \param tcov The trackContentObjectView to add. + * \param clipv The trackContentObjectView to add. */ -void TrackContentWidget::addTCOView( TrackContentObjectView * tcov ) +void TrackContentWidget::addClipView( ClipView * clipv ) { - TrackContentObject * tco = tcov->getTrackContentObject(); + Clip * clip = clipv->getClip(); - m_tcoViews.push_back( tcov ); + m_clipViews.push_back( clipv ); - tco->saveJournallingState( false ); + clip->saveJournallingState( false ); changePosition(); - tco->restoreJournallingState(); + clip->restoreJournallingState(); } @@ -157,16 +157,16 @@ void TrackContentWidget::addTCOView( TrackContentObjectView * tcov ) * * Removes the given trackContentObjectView from our list of views. * - * \param tcov The trackContentObjectView to add. + * \param clipv The trackContentObjectView to add. */ -void TrackContentWidget::removeTCOView( TrackContentObjectView * tcov ) +void TrackContentWidget::removeClipView( ClipView * clipv ) { - tcoViewVector::iterator it = std::find( m_tcoViews.begin(), - m_tcoViews.end(), - tcov ); - if( it != m_tcoViews.end() ) + clipViewVector::iterator it = std::find( m_clipViews.begin(), + m_clipViews.end(), + clipv ); + if( it != m_clipViews.end() ) { - m_tcoViews.erase( it ); + m_clipViews.erase( it ); Engine::getSong()->setModified(); } } @@ -179,8 +179,8 @@ void TrackContentWidget::removeTCOView( TrackContentObjectView * tcov ) */ void TrackContentWidget::update() { - for( tcoViewVector::iterator it = m_tcoViews.begin(); - it != m_tcoViews.end(); ++it ) + for( clipViewVector::iterator it = m_clipViews.begin(); + it != m_clipViews.end(); ++it ) { ( *it )->setFixedHeight( height() - 1 ); ( *it )->update(); @@ -204,11 +204,11 @@ void TrackContentWidget::changePosition( const TimePos & newPos ) const int curBB = Engine::getBBTrackContainer()->currentBB(); setUpdatesEnabled( false ); - // first show TCO for current BB... - for( tcoViewVector::iterator it = m_tcoViews.begin(); - it != m_tcoViews.end(); ++it ) + // first show Clip for current BB... + for( clipViewVector::iterator it = m_clipViews.begin(); + it != m_clipViews.end(); ++it ) { - if( ( *it )->getTrackContentObject()-> + if( ( *it )->getClip()-> startPosition().getBar() == curBB ) { ( *it )->move( 0, ( *it )->y() ); @@ -221,10 +221,10 @@ void TrackContentWidget::changePosition( const TimePos & newPos ) } } // ...then hide others to avoid flickering - for( tcoViewVector::iterator it = m_tcoViews.begin(); - it != m_tcoViews.end(); ++it ) + for( clipViewVector::iterator it = m_clipViews.begin(); + it != m_clipViews.end(); ++it ) { - if( ( *it )->getTrackContentObject()-> + if( ( *it )->getClip()-> startPosition().getBar() != curBB ) { ( *it )->hide(); @@ -245,31 +245,31 @@ void TrackContentWidget::changePosition( const TimePos & newPos ) const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); setUpdatesEnabled( false ); - for( tcoViewVector::iterator it = m_tcoViews.begin(); - it != m_tcoViews.end(); ++it ) + for( clipViewVector::iterator it = m_clipViews.begin(); + it != m_clipViews.end(); ++it ) { - TrackContentObjectView * tcov = *it; - TrackContentObject * tco = tcov->getTrackContentObject(); + ClipView * clipv = *it; + Clip * clip = clipv->getClip(); - tco->changeLength( tco->length() ); + clip->changeLength( clip->length() ); - const int ts = tco->startPosition(); - const int te = tco->endPosition()-3; + const int ts = clip->startPosition(); + const int te = clip->endPosition()-3; if( ( ts >= begin && ts <= end ) || ( te >= begin && te <= end ) || ( ts <= begin && te >= end ) ) { - tcov->move( static_cast( ( ts - begin ) * ppb / + clipv->move( static_cast( ( ts - begin ) * ppb / TimePos::ticksPerBar() ), - tcov->y() ); - if( !tcov->isVisible() ) + clipv->y() ); + if( !clipv->isVisible() ) { - tcov->show(); + clipv->show(); } } else { - tcov->move( -tcov->width()-10, tcov->y() ); + clipv->move( -clipv->width()-10, clipv->y() ); } } setUpdatesEnabled( true ); @@ -303,14 +303,14 @@ TimePos TrackContentWidget::getPosition( int mouseX ) */ void TrackContentWidget::dragEnterEvent( QDragEnterEvent * dee ) { - TimePos tcoPos = getPosition( dee->pos().x() ); - if( canPasteSelection( tcoPos, dee ) == false ) + TimePos clipPos = getPosition( dee->pos().x() ); + if( canPasteSelection( clipPos, dee ) == false ) { dee->ignore(); } else { - StringPairDrag::processDragEnterEvent( dee, "tco_" + + StringPairDrag::processDragEnterEvent( dee, "clip_" + QString::number( getTrack()->type() ) ); } } @@ -318,24 +318,24 @@ void TrackContentWidget::dragEnterEvent( QDragEnterEvent * dee ) -/*! \brief Returns whether a selection of TCOs can be pasted into this +/*! \brief Returns whether a selection of Clips can be pasted into this * - * \param tcoPos the position of the TCO slot being pasted on + * \param clipPos the position of the Clip slot being pasted on * \param de the DropEvent generated */ -bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QDropEvent* de ) +bool TrackContentWidget::canPasteSelection( TimePos clipPos, const QDropEvent* de ) { const QMimeData * mimeData = de->mimeData(); // If the source of the DropEvent is the current instance of LMMS we don't allow pasting in the same bar // if it's another instance of LMMS we allow it return de->source() - ? canPasteSelection( tcoPos, mimeData ) - : canPasteSelection( tcoPos, mimeData, true ); + ? canPasteSelection( clipPos, mimeData ) + : canPasteSelection( clipPos, mimeData, true ); } // Overloaded method to make it possible to call this method without a Drag&Drop event -bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QMimeData* md , bool allowSameBar ) +bool TrackContentWidget::canPasteSelection( TimePos clipPos, const QMimeData* md , bool allowSameBar ) { // For decodeKey() and decodeValue() using namespace Clipboard; @@ -345,20 +345,20 @@ bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QMimeData* md QString value = decodeValue( md ); // We can only paste into tracks of the same type - if( type != ( "tco_" + QString::number( t->type() ) ) || - m_trackView->trackContainerView()->fixedTCOs() == true ) + if( type != ( "clip_" + QString::number( t->type() ) ) || + m_trackView->trackContainerView()->fixedClips() == true ) { return false; } - // value contains XML needed to reconstruct TCOs and place them + // value contains XML needed to reconstruct Clips and place them DataFile dataFile( value.toUtf8() ); - // Extract the metadata and which TCO was grabbed + // Extract the metadata and which Clip was grabbed QDomElement metadata = dataFile.content().firstChildElement( "copyMetadata" ); - QDomAttr tcoPosAttr = metadata.attributeNode( "grabbedTCOPos" ); - TimePos grabbedTCOPos = tcoPosAttr.value().toInt(); - TimePos grabbedTCOBar = TimePos( grabbedTCOPos.getBar(), 0 ); + QDomAttr clipPosAttr = metadata.attributeNode( "grabbedClipPos" ); + TimePos grabbedClipPos = clipPosAttr.value().toInt(); + TimePos grabbedClipBar = TimePos( grabbedClipPos.getBar(), 0 ); // Extract the track index that was originally clicked QDomAttr tiAttr = metadata.attributeNode( "initialTrackIndex" ); @@ -371,20 +371,20 @@ bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QMimeData* md // Don't paste if we're on the same bar and allowSameBar is false auto sourceTrackContainerId = metadata.attributeNode( "trackContainerId" ).value().toUInt(); if( !allowSameBar && sourceTrackContainerId == t->trackContainer()->id() && - tcoPos == grabbedTCOBar && currentTrackIndex == initialTrackIndex ) + clipPos == grabbedClipBar && currentTrackIndex == initialTrackIndex ) { return false; } - // Extract the tco data - QDomElement tcoParent = dataFile.content().firstChildElement( "tcos" ); - QDomNodeList tcoNodes = tcoParent.childNodes(); + // Extract the clip data + QDomElement clipParent = dataFile.content().firstChildElement( "clips" ); + QDomNodeList clipNodes = clipParent.childNodes(); - // Determine if all the TCOs will land on a valid track - for( int i = 0; i < tcoNodes.length(); i++ ) + // Determine if all the Clips will land on a valid track + for( int i = 0; i < clipNodes.length(); i++ ) { - QDomElement tcoElement = tcoNodes.item( i ).toElement(); - int trackIndex = tcoElement.attributeNode( "trackIndex" ).value().toInt(); + QDomElement clipElement = clipNodes.item( i ).toElement(); + int trackIndex = clipElement.attributeNode( "trackIndex" ).value().toInt(); int finalTrackIndex = trackIndex + currentTrackIndex - initialTrackIndex; // Track must be in TrackContainer's tracks @@ -394,7 +394,7 @@ bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QMimeData* md } // Track must be of the same type - auto startTrackType = tcoElement.attributeNode("trackType").value().toInt(); + auto startTrackType = clipElement.attributeNode("trackType").value().toInt(); Track * endTrack = tracks.at( finalTrackIndex ); if( startTrackType != endTrack->type() ) { @@ -405,32 +405,32 @@ bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QMimeData* md return true; } -/*! \brief Pastes a selection of TCOs onto the track +/*! \brief Pastes a selection of Clips onto the track * - * \param tcoPos the position of the TCO slot being pasted on + * \param clipPos the position of the Clip slot being pasted on * \param de the DropEvent generated */ -bool TrackContentWidget::pasteSelection( TimePos tcoPos, QDropEvent * de ) +bool TrackContentWidget::pasteSelection( TimePos clipPos, QDropEvent * de ) { const QMimeData * mimeData = de->mimeData(); - if( canPasteSelection( tcoPos, de ) == false ) + if( canPasteSelection( clipPos, de ) == false ) { return false; } // We set skipSafetyCheck to true because we already called canPasteSelection - return pasteSelection( tcoPos, mimeData, true ); + return pasteSelection( clipPos, mimeData, true ); } // Overloaded method so we can call it without a Drag&Drop event -bool TrackContentWidget::pasteSelection( TimePos tcoPos, const QMimeData * md, bool skipSafetyCheck ) +bool TrackContentWidget::pasteSelection( TimePos clipPos, const QMimeData * md, bool skipSafetyCheck ) { // For decodeKey() and decodeValue() using namespace Clipboard; // When canPasteSelection was already called before, skipSafetyCheck will skip this - if( !skipSafetyCheck && canPasteSelection( tcoPos, md ) == false ) + if( !skipSafetyCheck && canPasteSelection( clipPos, md ) == false ) { return false; } @@ -440,19 +440,19 @@ bool TrackContentWidget::pasteSelection( TimePos tcoPos, const QMimeData * md, b getTrack()->addJournalCheckPoint(); - // value contains XML needed to reconstruct TCOs and place them + // value contains XML needed to reconstruct Clips and place them DataFile dataFile( value.toUtf8() ); - // Extract the tco data - QDomElement tcoParent = dataFile.content().firstChildElement( "tcos" ); - QDomNodeList tcoNodes = tcoParent.childNodes(); + // Extract the clip data + QDomElement clipParent = dataFile.content().firstChildElement( "clips" ); + QDomNodeList clipNodes = clipParent.childNodes(); // Extract the track index that was originally clicked QDomElement metadata = dataFile.content().firstChildElement( "copyMetadata" ); QDomAttr tiAttr = metadata.attributeNode( "initialTrackIndex" ); int initialTrackIndex = tiAttr.value().toInt(); - QDomAttr tcoPosAttr = metadata.attributeNode( "grabbedTCOPos" ); - TimePos grabbedTCOPos = tcoPosAttr.value().toInt(); + QDomAttr clipPosAttr = metadata.attributeNode( "grabbedClipPos" ); + TimePos grabbedClipPos = clipPosAttr.value().toInt(); // Snap the mouse position to the beginning of the dropped bar, in ticks const TrackContainer::TrackList tracks = getTrack()->trackContainer()->tracks(); @@ -470,52 +470,52 @@ bool TrackContentWidget::pasteSelection( TimePos tcoPos, const QMimeData * md, b } - // TODO -- Need to draw the hovericon either way, or ghost the TCOs + // TODO -- Need to draw the hovericon either way, or ghost the Clips // onto their final position. float snapSize = gui->songEditor()->m_editor->getSnapSize(); // All patterns should be offset the same amount as the grabbed pattern - TimePos offset = TimePos(tcoPos - grabbedTCOPos); + TimePos offset = TimePos(clipPos - grabbedClipPos); // Users expect clips to "fall" backwards, so bias the offset offset -= TimePos::ticksPerBar() * snapSize / 2; // The offset is quantized (rather than the positions) to preserve fine adjustments offset = offset.quantize(snapSize); - // Get the leftmost TCO and fix the offset if it reaches below bar 0 - TimePos leftmostPos = grabbedTCOPos; - for(int i = 0; i < tcoNodes.length(); ++i) + // Get the leftmost Clip and fix the offset if it reaches below bar 0 + TimePos leftmostPos = grabbedClipPos; + for(int i = 0; i < clipNodes.length(); ++i) { - QDomElement outerTCOElement = tcoNodes.item(i).toElement(); - QDomElement tcoElement = outerTCOElement.firstChildElement(); + QDomElement outerClipElement = clipNodes.item(i).toElement(); + QDomElement clipElement = outerClipElement.firstChildElement(); - TimePos pos = tcoElement.attributeNode("pos").value().toInt(); + TimePos pos = clipElement.attributeNode("pos").value().toInt(); if(pos < leftmostPos) { leftmostPos = pos; } } - // Fix offset if it sets the left most TCO to a negative position + // Fix offset if it sets the left most Clip to a negative position offset = std::max(offset.getTicks(), -leftmostPos.getTicks()); - for( int i = 0; isongEditor()->m_editor->getSnapSize(); if (offset == 0 && initialTrackIndex == currentTrackIndex) { pos += shift; } - TrackContentObject * tco = t->createTCO( pos ); - tco->restoreState( tcoElement ); - tco->movePosition(pos); // Because we restored the state, we need to move the TCO again. + Clip * clip = t->createClip( pos ); + clip->restoreState( clipElement ); + clip->movePosition(pos); // Because we restored the state, we need to move the Clip again. if( wasSelection ) { - tco->selectViewOnCreate( true ); + clip->selectViewOnCreate( true ); } } @@ -531,8 +531,8 @@ bool TrackContentWidget::pasteSelection( TimePos tcoPos, const QMimeData * md, b */ void TrackContentWidget::dropEvent( QDropEvent * de ) { - TimePos tcoPos = TimePos( getPosition( de->pos().x() ) ); - if( pasteSelection( tcoPos, de ) == true ) + TimePos clipPos = TimePos( getPosition( de->pos().x() ) ); + if( pasteSelection( clipPos, de ) == true ) { de->accept(); } @@ -548,7 +548,7 @@ void TrackContentWidget::dropEvent( QDropEvent * de ) void TrackContentWidget::mousePressEvent( QMouseEvent * me ) { // Enable box select if control is held when clicking an empty space - // (If we had clicked a TCO it would have intercepted the mouse event) + // (If we had clicked a Clip it would have intercepted the mouse event) if( me->modifiers() & Qt::ControlModifier ){ gui->songEditor()->m_editor->setEditMode(SongEditor::EditMode::SelectMode); } @@ -562,9 +562,9 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me ) { QWidget::mousePressEvent( me ); } - // For an unmodified click, create a new TCO + // For an unmodified click, create a new Clip else if( me->button() == Qt::LeftButton && - !m_trackView->trackContainerView()->fixedTCOs() ) + !m_trackView->trackContainerView()->fixedClips() ) { QVector so = m_trackView->trackContainerView()->rubberBand()->selectedObjects(); for( int i = 0; i < so.count(); ++i ) @@ -574,7 +574,7 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me ) getTrack()->addJournalCheckPoint(); const TimePos pos = getPosition( me->x() ).getBar() * TimePos::ticksPerBar(); - getTrack()->createTCO(pos); + getTrack()->createClip(pos); } } @@ -658,7 +658,7 @@ void TrackContentWidget::contextMenuEvent( QContextMenuEvent * cme ) return; } - // If we don't have TCO data in the clipboard there's no need to create this menu + // If we don't have Clip data in the clipboard there's no need to create this menu // since "paste" is the only action at the moment. if( ! hasFormat( MimeType::StringPair ) ) { @@ -683,9 +683,9 @@ void TrackContentWidget::contextMenuAction( QContextMenuEvent * cme, ContextMenu { case Paste: // Paste the selection on the TimePos of the context menu event - TimePos tcoPos = getPosition( cme->x() ); + TimePos clipPos = getPosition( cme->x() ); - pasteSelection( tcoPos, getMimeData() ); + pasteSelection( clipPos, getMimeData() ); break; } } diff --git a/src/gui/widgets/TrackOperationsWidget.cpp b/src/gui/widgets/TrackOperationsWidget.cpp index 48a9607440b..cd2df2f832b 100644 --- a/src/gui/widgets/TrackOperationsWidget.cpp +++ b/src/gui/widgets/TrackOperationsWidget.cpp @@ -252,13 +252,13 @@ void TrackOperationsWidget::cloneTrack() } -/*! \brief Clear this track - clears all TCOs from the track */ +/*! \brief Clear this track - clears all Clips from the track */ void TrackOperationsWidget::clearTrack() { Track * t = m_trackView->getTrack(); t->addJournalCheckPoint(); t->lock(); - t->deleteTCOs(); + t->deleteClips(); t->unlock(); } @@ -317,7 +317,7 @@ void TrackOperationsWidget::useTrackColor() * For all track types, we have the Clone and Remove options. * For instrument-tracks we also offer the MIDI-control-menu * For automation tracks, extra options: turn on/off recording - * on all TCOs (same should be added for sample tracks when + * on all Clips (same should be added for sample tracks when * sampletrack recording is implemented) */ void TrackOperationsWidget::updateMenu() @@ -331,7 +331,7 @@ void TrackOperationsWidget::updateMenu() tr( "Remove this track" ), this, SLOT( removeTrack() ) ); - if( ! m_trackView->trackContainerView()->fixedTCOs() ) + if( ! m_trackView->trackContainerView()->fixedClips() ) { toMenu->addAction( tr( "Clear this track" ), this, SLOT( clearTrack() ) ); } @@ -369,9 +369,9 @@ void TrackOperationsWidget::toggleRecording( bool on ) AutomationTrackView * atv = dynamic_cast( m_trackView ); if( atv ) { - for( TrackContentObject * tco : atv->getTrack()->getTCOs() ) + for( Clip * clip : atv->getTrack()->getClips() ) { - AutomationPattern * ap = dynamic_cast( tco ); + AutomationPattern * ap = dynamic_cast( clip ); if( ap ) { ap->setRecording( on ); } } atv->update(); diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index 034ad4251d0..21d10cb24ea 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -35,7 +35,7 @@ AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : } bool AutomationTrack::play( const TimePos & time_start, const fpp_t _frames, - const f_cnt_t _frame_base, int _tco_num ) + const f_cnt_t _frame_base, int _clip_num ) { return false; } @@ -51,7 +51,7 @@ TrackView * AutomationTrack::createView( TrackContainerView* tcv ) -TrackContentObject* AutomationTrack::createTCO(const TimePos & pos) +Clip* AutomationTrack::createClip(const TimePos & pos) { AutomationPattern* p = new AutomationPattern(this); p->movePosition(pos); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 354412e0249..fd2f2a60822 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -43,7 +43,7 @@ BBTrack::BBTrack( TrackContainer* tc ) : s_infoMap[this] = bbNum; setName( tr( "Beat/Bassline %1" ).arg( bbNum ) ); - Engine::getBBTrackContainer()->createTCOsForBB( bbNum ); + Engine::getBBTrackContainer()->createClipsForBB( bbNum ); Engine::getBBTrackContainer()->setCurrentBB( bbNum ); Engine::getBBTrackContainer()->updateComboBox(); @@ -82,31 +82,31 @@ BBTrack::~BBTrack() -// play _frames frames of given TCO within starting with _start +// play _frames frames of given Clip within starting with _start bool BBTrack::play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _offset, int _tco_num ) + const f_cnt_t _offset, int _clip_num ) { if( isMuted() ) { return false; } - if( _tco_num >= 0 ) + if( _clip_num >= 0 ) { return Engine::getBBTrackContainer()->play( _start, _frames, _offset, s_infoMap[this] ); } - tcoVector tcos; - getTCOsInRange( tcos, _start, _start + static_cast( _frames / Engine::framesPerTick() ) ); + clipVector clips; + getClipsInRange( clips, _start, _start + static_cast( _frames / Engine::framesPerTick() ) ); - if( tcos.size() == 0 ) + if( clips.size() == 0 ) { return false; } TimePos lastPosition; TimePos lastLen; - for( tcoVector::iterator it = tcos.begin(); it != tcos.end(); ++it ) + for( clipVector::iterator it = clips.begin(); it != clips.end(); ++it ) { if( !( *it )->isMuted() && ( *it )->startPosition() >= lastPosition ) @@ -134,11 +134,11 @@ TrackView * BBTrack::createView( TrackContainerView* tcv ) -TrackContentObject* BBTrack::createTCO(const TimePos & pos) +Clip* BBTrack::createClip(const TimePos & pos) { - BBTCO* bbtco = new BBTCO(this); - bbtco->movePosition(pos); - return bbtco; + BBClip* bbclip = new BBClip(this); + bbclip->movePosition(pos); + return bbclip; } @@ -179,13 +179,13 @@ void BBTrack::loadTrackSpecificSettings( const QDomElement & _this ) const int dst = s_infoMap[this]; TrackContainer::TrackList tl = Engine::getBBTrackContainer()->tracks(); - // copy TCOs of all tracks from source BB (at bar "src") to destination - // TCOs (which are created if they do not exist yet) + // copy Clips of all tracks from source BB (at bar "src") to destination + // Clips (which are created if they do not exist yet) for( TrackContainer::TrackList::iterator it = tl.begin(); it != tl.end(); ++it ) { - TrackContentObject::copyStateTo( ( *it )->getTCO( src ), - ( *it )->getTCO( dst ) ); + Clip::copyStateTo( ( *it )->getClip( src ), + ( *it )->getClip( dst ) ); } setName( tr( "Clone of %1" ).arg( _this.parentNode().toElement().attribute( "name" ) ) ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 0ca8d657187..dab835acfce 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -656,7 +656,7 @@ void InstrumentTrack::removeMidiPortNode( DataFile & _dataFile ) bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _offset, int _tco_num ) + const f_cnt_t _offset, int _clip_num ) { if( ! m_instrument || ! tryLock() ) { @@ -664,20 +664,20 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, } const float frames_per_tick = Engine::framesPerTick(); - tcoVector tcos; + clipVector clips; ::BBTrack * bb_track = NULL; - if( _tco_num >= 0 ) + if( _clip_num >= 0 ) { - TrackContentObject * tco = getTCO( _tco_num ); - tcos.push_back( tco ); + Clip * clip = getClip( _clip_num ); + clips.push_back( clip ); if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer()) { - bb_track = BBTrack::findBBTrack( _tco_num ); + bb_track = BBTrack::findBBTrack( _clip_num ); } } else { - getTCOsInRange( tcos, _start, _start + static_cast( + getClipsInRange( clips, _start, _start + static_cast( _frames / frames_per_tick ) ); } @@ -688,7 +688,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, ( *it )->processTimePos( _start ); } - if ( tcos.size() == 0 ) + if ( clips.size() == 0 ) { unlock(); return false; @@ -696,7 +696,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, bool played_a_note = false; // will be return variable - for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it ) + for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it ) { Pattern* p = dynamic_cast( *it ); // everything which is not a pattern won't be played @@ -708,7 +708,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, continue; } TimePos cur_start = _start; - if( _tco_num < 0 ) + if( _clip_num < 0 ) { cur_start -= p->startPosition(); } @@ -741,7 +741,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, NotePlayHandle* notePlayHandle = NotePlayHandleManager::acquire( this, _offset, note_frames, *cur_note ); notePlayHandle->setBBTrack( bb_track ); // are we playing global song? - if( _tco_num < 0 ) + if( _clip_num < 0 ) { // then set song-global offset of pattern in order to // properly perform the note detuning @@ -760,7 +760,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, -TrackContentObject* InstrumentTrack::createTCO(const TimePos & pos) +Clip* InstrumentTrack::createClip(const TimePos & pos) { Pattern* p = new Pattern(this); p->movePosition(pos); diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index d9939959f33..067eeaa3b57 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -41,7 +41,7 @@ QPixmap * PatternView::s_stepBtnOffLight = NULL; Pattern::Pattern( InstrumentTrack * _instrument_track ) : - TrackContentObject( _instrument_track ), + Clip( _instrument_track ), m_instrumentTrack( _instrument_track ), m_patternType( BeatPattern ), m_steps( TimePos::stepsPerBar() ) @@ -59,7 +59,7 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) : Pattern::Pattern( const Pattern& other ) : - TrackContentObject( other.m_instrumentTrack ), + Clip( other.m_instrumentTrack ), m_instrumentTrack( other.m_instrumentTrack ), m_patternType( other.m_patternType ), m_steps( other.m_steps ) @@ -112,10 +112,10 @@ void Pattern::resizeToFirstTrack() { if(tracks.at(trackID) != m_instrumentTrack) { - unsigned int currentTCO = m_instrumentTrack-> - getTCOs().indexOf(this); + unsigned int currentClip = m_instrumentTrack-> + getClips().indexOf(this); m_steps = static_cast - (tracks.at(trackID)->getTCO(currentTCO)) + (tracks.at(trackID)->getClip(currentClip)) ->m_steps; } break; @@ -480,9 +480,9 @@ Pattern * Pattern::nextPattern() const Pattern * Pattern::adjacentPatternByOffset(int offset) const { - QVector tcos = m_instrumentTrack->getTCOs(); - int tcoNum = m_instrumentTrack->getTCONum(this); - return dynamic_cast(tcos.value(tcoNum + offset, NULL)); + QVector clips = m_instrumentTrack->getClips(); + int clipNum = m_instrumentTrack->getClipNum(this); + return dynamic_cast(clips.value(clipNum + offset, NULL)); } @@ -546,7 +546,7 @@ void Pattern::removeSteps() -TrackContentObjectView * Pattern::createView( TrackView * _tv ) +ClipView * Pattern::createView( TrackView * _tv ) { return new PatternView( this, _tv ); } diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index d035e747c8c..096cc3d7f0b 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -61,16 +61,16 @@ SampleTrack::~SampleTrack() bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, - const f_cnt_t _offset, int _tco_num ) + const f_cnt_t _offset, int _clip_num ) { m_audioPort.effects()->startRunning(); bool played_a_note = false; // will be return variable - tcoVector tcos; + clipVector clips; ::BBTrack * bb_track = NULL; - if( _tco_num >= 0 ) + if( _clip_num >= 0 ) { - if (_start > getTCO(_tco_num)->length()) + if (_start > getClip(_clip_num)->length()) { setPlaying(false); } @@ -78,55 +78,55 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, { return false; } - tcos.push_back( getTCO( _tco_num ) ); + clips.push_back( getClip( _clip_num ) ); if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer()) { - bb_track = BBTrack::findBBTrack( _tco_num ); + bb_track = BBTrack::findBBTrack( _clip_num ); setPlaying(true); } } else { bool nowPlaying = false; - for( int i = 0; i < numOfTCOs(); ++i ) + for( int i = 0; i < numOfClips(); ++i ) { - TrackContentObject * tco = getTCO( i ); - SampleTCO * sTco = dynamic_cast( tco ); + Clip * clip = getClip( i ); + SampleClip * sClip = dynamic_cast( clip ); - if( _start >= sTco->startPosition() && _start < sTco->endPosition() ) + if( _start >= sClip->startPosition() && _start < sClip->endPosition() ) { - if( sTco->isPlaying() == false && _start >= (sTco->startPosition() + sTco->startTimeOffset()) ) + if( sClip->isPlaying() == false && _start >= (sClip->startPosition() + sClip->startTimeOffset()) ) { - auto bufferFramesPerTick = Engine::framesPerTick (sTco->sampleBuffer ()->sampleRate ()); - f_cnt_t sampleStart = bufferFramesPerTick * ( _start - sTco->startPosition() - sTco->startTimeOffset() ); - f_cnt_t tcoFrameLength = bufferFramesPerTick * ( sTco->endPosition() - sTco->startPosition() - sTco->startTimeOffset() ); - f_cnt_t sampleBufferLength = sTco->sampleBuffer()->frames(); - //if the Tco smaller than the sample length we play only until Tco end + auto bufferFramesPerTick = Engine::framesPerTick (sClip->sampleBuffer ()->sampleRate ()); + f_cnt_t sampleStart = bufferFramesPerTick * ( _start - sClip->startPosition() - sClip->startTimeOffset() ); + f_cnt_t clipFrameLength = bufferFramesPerTick * ( sClip->endPosition() - sClip->startPosition() - sClip->startTimeOffset() ); + f_cnt_t sampleBufferLength = sClip->sampleBuffer()->frames(); + //if the Clip smaller than the sample length we play only until Clip end //else we play the sample to the end but nothing more - f_cnt_t samplePlayLength = tcoFrameLength > sampleBufferLength ? sampleBufferLength : tcoFrameLength; + f_cnt_t samplePlayLength = clipFrameLength > sampleBufferLength ? sampleBufferLength : clipFrameLength; //we only play within the sampleBuffer limits if( sampleStart < sampleBufferLength ) { - sTco->setSampleStartFrame( sampleStart ); - sTco->setSamplePlayLength( samplePlayLength ); - tcos.push_back( sTco ); - sTco->setIsPlaying( true ); + sClip->setSampleStartFrame( sampleStart ); + sClip->setSamplePlayLength( samplePlayLength ); + clips.push_back( sClip ); + sClip->setIsPlaying( true ); nowPlaying = true; } } } else { - sTco->setIsPlaying( false ); + sClip->setIsPlaying( false ); } - nowPlaying = nowPlaying || sTco->isPlaying(); + nowPlaying = nowPlaying || sClip->isPlaying(); } setPlaying(nowPlaying); } - for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it ) + for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it ) { - SampleTCO * st = dynamic_cast( *it ); + SampleClip * st = dynamic_cast( *it ); if( !st->isMuted() ) { PlayHandle* handle; @@ -167,11 +167,11 @@ TrackView * SampleTrack::createView( TrackContainerView* tcv ) -TrackContentObject * SampleTrack::createTCO(const TimePos & pos) +Clip * SampleTrack::createClip(const TimePos & pos) { - SampleTCO * sTco = new SampleTCO(this); - sTco->movePosition(pos); - return sTco; + SampleClip * sClip = new SampleClip(this); + sClip->movePosition(pos); + return sClip; } @@ -216,22 +216,22 @@ void SampleTrack::loadTrackSpecificSettings( const QDomElement & _this ) -void SampleTrack::updateTcos() +void SampleTrack::updateClips() { Engine::mixer()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); - setPlayingTcos( false ); + setPlayingClips( false ); } -void SampleTrack::setPlayingTcos( bool isPlaying ) +void SampleTrack::setPlayingClips( bool isPlaying ) { - for( int i = 0; i < numOfTCOs(); ++i ) + for( int i = 0; i < numOfClips(); ++i ) { - TrackContentObject * tco = getTCO( i ); - SampleTCO * sTco = dynamic_cast( tco ); - sTco->setIsPlaying( isPlaying ); + Clip * clip = getClip( i ); + SampleClip * sClip = dynamic_cast( clip ); + sClip->setIsPlaying( isPlaying ); } } From d5fce19010bfb6911ba3c782fe66f0097116981b Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 8 Jun 2021 09:00:50 +0530 Subject: [PATCH 3/6] Update tests --- tests/src/tracks/AutomationTrackTest.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index f86bfe44d2b..920ccabf045 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -140,7 +140,7 @@ private slots: InstrumentTrack* instrumentTrack = dynamic_cast(Track::create(Track::InstrumentTrack, song)); - Pattern* notePattern = dynamic_cast(instrumentTrack->createTCO(0)); + Pattern* notePattern = dynamic_cast(instrumentTrack->createClip(0)); notePattern->changeLength(TimePos(4, 0)); Note* note = notePattern->addNote(Note(TimePos(4, 0)), false); note->createDetuning(); @@ -164,8 +164,8 @@ private slots: BBTrack bbTrack(song); Track* automationTrack = Track::create(Track::AutomationTrack, bbContainer); - QVERIFY(automationTrack->numOfTCOs()); - AutomationPattern* p1 = dynamic_cast(automationTrack->getTCO(0)); + QVERIFY(automationTrack->numOfClips()); + AutomationPattern* p1 = dynamic_cast(automationTrack->getClip(0)); QVERIFY(p1); FloatModel model; @@ -185,9 +185,9 @@ private slots: QCOMPARE(bbContainer->automatedValuesAt(5, bbTrack.index())[&model], 0.5f); QVERIFY(! bbContainer->automatedValuesAt(5, bbTrack2.index()).size()); - BBTCO tco(&bbTrack); - tco.changeLength(TimePos::ticksPerBar() * 2); - tco.movePosition(0); + BBClip clip(&bbTrack); + clip.changeLength(TimePos::ticksPerBar() * 2); + clip.movePosition(0); QCOMPARE(song->automatedValuesAt(0)[&model], 0.0f); QCOMPARE(song->automatedValuesAt(5)[&model], 0.5f); From 5ba4346ed79309f21d2bdde6d571dda11a4754e3 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 8 Jun 2021 09:32:16 +0530 Subject: [PATCH 4/6] Complete partial rename of AutomationPattern and related --- include/AutomationEditor.h | 34 +- include/AutomationNode.h | 18 +- include/AutomationPattern.h | 211 ---- include/AutomationPatternView.h | 79 -- include/InlineAutomation.h | 10 +- include/Song.h | 4 +- include/TrackContainer.h | 4 +- plugins/LadspaEffect/LadspaEffect.cpp | 4 +- plugins/MidiImport/MidiImport.cpp | 16 +- src/core/AutomatableModel.cpp | 48 +- src/core/AutomationNode.cpp | 28 +- src/core/AutomationPattern.cpp | 1184 --------------------- src/core/CMakeLists.txt | 2 +- src/core/Clip.cpp | 6 +- src/core/InlineAutomation.cpp | 4 +- src/core/MeterModel.cpp | 6 +- src/core/Note.cpp | 2 +- src/core/Song.cpp | 16 +- src/core/Track.cpp | 4 +- src/core/TrackContainer.cpp | 4 +- src/gui/AutomatableModelView.cpp | 6 +- src/gui/AutomationPatternView.cpp | 508 --------- src/gui/AutomationTrackView.cpp | 4 +- src/gui/CMakeLists.txt | 2 +- src/gui/ClipView.cpp | 4 +- src/gui/MainWindow.cpp | 2 +- src/gui/editors/AutomationEditor.cpp | 258 ++--- src/gui/editors/PianoRoll.cpp | 10 +- src/gui/widgets/TrackContentWidget.cpp | 4 +- src/gui/widgets/TrackOperationsWidget.cpp | 4 +- src/tracks/AutomationTrack.cpp | 4 +- src/tracks/InstrumentTrack.cpp | 4 +- tests/src/tracks/AutomationTrackTest.cpp | 38 +- 33 files changed, 275 insertions(+), 2257 deletions(-) delete mode 100644 include/AutomationPattern.h delete mode 100644 include/AutomationPatternView.h delete mode 100644 src/core/AutomationPattern.cpp delete mode 100644 src/gui/AutomationPatternView.cpp diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index e11600c71f2..4be2756aa7a 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -34,7 +34,7 @@ #include "lmms_basics.h" #include "JournallingObject.h" #include "TimePos.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "ComboBoxModel.h" #include "Knob.h" @@ -61,16 +61,16 @@ class AutomationEditor : public QWidget, public JournallingObject Q_PROPERTY(QColor crossColor MEMBER m_crossColor) Q_PROPERTY(QColor backgroundShade MEMBER m_backgroundShade) public: - void setCurrentPattern(AutomationPattern * new_pattern); + void setCurrentClip(AutomationClip * new_clip); - inline const AutomationPattern * currentPattern() const + inline const AutomationClip * currentClip() const { - return m_pattern; + return m_clip; } - inline bool validPattern() const + inline bool validClip() const { - return m_pattern != nullptr; + return m_clip != nullptr; } void saveSettings(QDomDocument & doc, QDomElement & parent) override; @@ -89,11 +89,11 @@ class AutomationEditor : public QWidget, public JournallingObject public slots: void update(); - void updateAfterPatternChange(); + void updateAfterClipChange(); protected: - typedef AutomationPattern::timeMap timeMap; + typedef AutomationClip::timeMap timeMap; void keyPressEvent(QKeyEvent * ke) override; void leaveEvent(QEvent * e) override; @@ -125,7 +125,7 @@ protected slots: void setEditMode(AutomationEditor::EditModes mode); void setEditMode(int mode); - void setProgressionType(AutomationPattern::ProgressionTypes type); + void setProgressionType(AutomationClip::ProgressionTypes type); void setProgressionType(int type); void setTension(); @@ -134,7 +134,7 @@ protected slots: void zoomingXChanged(); void zoomingYChanged(); - /// Updates the pattern's quantization using the current user selected value. + /// Updates the clip's quantization using the current user selected value. void setQuantization(); private: @@ -178,7 +178,7 @@ protected slots: FloatModel * m_tensionModel; - AutomationPattern * m_pattern; + AutomationClip * m_clip; float m_minLevel; float m_maxLevel; float m_step; @@ -234,7 +234,7 @@ protected slots: signals: - void currentPatternChanged(); + void currentClipChanged(); void positionChanged( const TimePos & ); } ; @@ -251,23 +251,23 @@ class AutomationEditorWindow : public Editor AutomationEditorWindow(); ~AutomationEditorWindow(); - void setCurrentPattern(AutomationPattern* pattern); - const AutomationPattern* currentPattern(); + void setCurrentClip(AutomationClip* clip); + const AutomationClip* currentClip(); void dropEvent( QDropEvent * _de ) override; void dragEnterEvent( QDragEnterEvent * _dee ) override; - void open(AutomationPattern* pattern); + void open(AutomationClip* clip); AutomationEditor* m_editor; QSize sizeHint() const override; public slots: - void clearCurrentPattern(); + void clearCurrentClip(); signals: - void currentPatternChanged(); + void currentClipChanged(); protected: void focusInEvent(QFocusEvent * event) override; diff --git a/include/AutomationNode.h b/include/AutomationNode.h index d65b7f42637..073f29cf1b3 100644 --- a/include/AutomationNode.h +++ b/include/AutomationNode.h @@ -34,18 +34,18 @@ #define OUTTAN(x) ((x).value().getOutTangent()) #define POS(x) ((x).key()) -class AutomationPattern; +class AutomationClip; -// Note: We use the default copy-assignment on the AutomationPattern constructor. It's +// Note: We use the default copy-assignment on the AutomationClip constructor. It's // fine for now as we don't have dynamic allocated members, but if any are added we should // have an user-defined one to perform a deep-copy. class AutomationNode { public: AutomationNode(); // Dummy constructor for the QMap - AutomationNode(AutomationPattern* pat, float value, int pos); - AutomationNode(AutomationPattern* pat, float inValue, float outValue, int pos); + AutomationNode(AutomationClip* pat, float value, int pos); + AutomationNode(AutomationClip* pat, float inValue, float outValue, int pos); AutomationNode& operator+=(float f) { @@ -131,18 +131,18 @@ class AutomationNode } /** - * @brief Sets the pattern this node belongs to - * @param AutomationPattern* pattern that m_pattern will be + * @brief Sets the clip this node belongs to + * @param AutomationClip* clip that m_clip will be * set to */ - inline void setPattern(AutomationPattern* pat) + inline void setClip(AutomationClip* pat) { - m_pattern = pat; + m_clip = pat; } private: // Pattern that this node belongs to - AutomationPattern* m_pattern; + AutomationClip* m_clip; // Time position of this node (matches the timeMap key) int m_pos; diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h deleted file mode 100644 index 57c9b657ec7..00000000000 --- a/include/AutomationPattern.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * AutomationPattern.h - declaration of class AutomationPattern, which contains - * all information about an automation pattern - * - * Copyright (c) 2008-2014 Tobias Doerffel - * Copyright (c) 2006-2008 Javier Serrano Polo - * - * This file is part of LMMS - https://lmms.io - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program (see COPYING); if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - -#ifndef AUTOMATION_PATTERN_H -#define AUTOMATION_PATTERN_H - -#include -#include - -#include "AutomationNode.h" -#include "Clip.h" - - -class AutomationTrack; -class TimePos; - - - -class LMMS_EXPORT AutomationPattern : public Clip -{ - Q_OBJECT -public: - enum ProgressionTypes - { - DiscreteProgression, - LinearProgression, - CubicHermiteProgression - } ; - - typedef QMap timeMap; - typedef QVector> objectVector; - - AutomationPattern( AutomationTrack * _auto_track ); - AutomationPattern( const AutomationPattern & _pat_to_copy ); - virtual ~AutomationPattern() = default; - - bool addObject( AutomatableModel * _obj, bool _search_dup = true ); - - const AutomatableModel * firstObject() const; - const objectVector& objects() const; - - // progression-type stuff - inline ProgressionTypes progressionType() const - { - return m_progressionType; - } - void setProgressionType( ProgressionTypes _new_progression_type ); - - inline float getTension() const - { - return m_tension; - } - void setTension( QString _new_tension ); - - TimePos timeMapLength() const; - void updateLength(); - - TimePos putValue( - const TimePos & time, - const float value, - const bool quantPos = true, - const bool ignoreSurroundingPoints = true - ); - - TimePos putValues( - const TimePos & time, - const float inValue, - const float outValue, - const bool quantPos = true, - const bool ignoreSurroundingPoints = true - ); - - void removeNode(const TimePos & time); - void removeNodes(const int tick0, const int tick1); - - void resetNodes(const int tick0, const int tick1); - - void recordValue(TimePos time, float value); - - TimePos setDragValue( const TimePos & time, - const float value, - const bool quantPos = true, - const bool controlKey = false ); - - void applyDragValue(); - - - bool isDragging() const - { - return m_dragging; - } - - inline const timeMap & getTimeMap() const - { - return m_timeMap; - } - - inline timeMap & getTimeMap() - { - return m_timeMap; - } - - inline float getMin() const - { - return firstObject()->minValue(); - } - - inline float getMax() const - { - return firstObject()->maxValue(); - } - - inline bool hasAutomation() const - { - return m_timeMap.isEmpty() == false; - } - - float valueAt( const TimePos & _time ) const; - float *valuesAfter( const TimePos & _time ) const; - - const QString name() const; - - // settings-management - void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; - void loadSettings( const QDomElement & _this ) override; - - static const QString classNodeName() { return "automationpattern"; } - QString nodeName() const override { return classNodeName(); } - - ClipView * createView( TrackView * _tv ) override; - - - static bool isAutomated( const AutomatableModel * _m ); - static QVector patternsForModel( const AutomatableModel * _m ); - static AutomationPattern * globalAutomationPattern( AutomatableModel * _m ); - static void resolveAllIDs(); - - bool isRecording() const { return m_isRecording; } - void setRecording( const bool b ) { m_isRecording = b; } - - static int quantization() { return s_quantization; } - static void setQuantization(int q) { s_quantization = q; } - -public slots: - void clear(); - void objectDestroyed( jo_id_t ); - void flipY( int min, int max ); - void flipY(); - void flipX( int length = -1 ); - -private: - void cleanObjects(); - void generateTangents(); - void generateTangents(timeMap::iterator it, int numToGenerate); - float valueAt( timeMap::const_iterator v, int offset ) const; - - // Mutex to make methods involving automation patterns thread safe - // Mutable so we can lock it from const objects - mutable QMutex m_patternMutex; - - AutomationTrack * m_autoTrack; - QVector m_idsToResolve; - objectVector m_objects; - timeMap m_timeMap; // actual values - timeMap m_oldTimeMap; // old values for storing the values before setDragValue() is called. - float m_tension; - bool m_hasAutomation; - ProgressionTypes m_progressionType; - - bool m_dragging; - bool m_dragKeepOutValue; // Should we keep the current dragged node's outValue? - float m_dragOutValue; // The outValue of the dragged node's - - bool m_isRecording; - float m_lastRecordedValue; - - static int s_quantization; - - static const float DEFAULT_MIN_VALUE; - static const float DEFAULT_MAX_VALUE; - - friend class AutomationPatternView; - friend class AutomationNode; - -} ; - - -#endif diff --git a/include/AutomationPatternView.h b/include/AutomationPatternView.h deleted file mode 100644 index 8c1af5a1ba1..00000000000 --- a/include/AutomationPatternView.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * AutomationPatternView.h - declaration of class AutomationPatternView - * - * Copyright (c) 2008-2010 Tobias Doerffel - * - * This file is part of LMMS - https://lmms.io - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program (see COPYING); if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - -#ifndef AUTOMATION_PATTERN_VIEW_H -#define AUTOMATION_PATTERN_VIEW_H - -#include - -#include "AutomationPattern.h" -#include "Song.h" -#include "SongEditor.h" -#include "ClipView.h" - - -class AutomationPatternView : public ClipView -{ - Q_OBJECT - - -public: - AutomationPatternView( AutomationPattern * _pat, TrackView * _parent ); - virtual ~AutomationPatternView(); - -public slots: - /// Opens this view's pattern in the global automation editor - void openInAutomationEditor(); - void update() override; - - -protected slots: - void resetName(); - void changeName(); - void disconnectObject( QAction * _a ); - void toggleRecording(); - void flipY(); - void flipX(); - -protected: - void constructContextMenu( QMenu * ) override; - void mouseDoubleClickEvent(QMouseEvent * me ) override; - void paintEvent( QPaintEvent * pe ) override; - void dragEnterEvent( QDragEnterEvent * _dee ) override; - void dropEvent( QDropEvent * _de ) override; - - -private: - AutomationPattern * m_pat; - QPixmap m_paintPixmap; - - QStaticText m_staticTextName; - - static QPixmap * s_pat_rec; - - void scaleTimemapToFit( float oldMin, float oldMax ); -} ; - - -#endif diff --git a/include/InlineAutomation.h b/include/InlineAutomation.h index aa47d6e334f..5a599b7e1d6 100644 --- a/include/InlineAutomation.h +++ b/include/InlineAutomation.h @@ -26,7 +26,7 @@ #define INLINE_AUTOMATION_H #include "AutomationNode.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "shared_object.h" @@ -57,7 +57,7 @@ class InlineAutomation : public FloatModel, public sharedObject // Prevent saving inline automation if there's just one node at the beginning of // the pattern, which has a InValue equal to the value of model (which is going // to be saved anyways) and no offset between the InValue and OutValue - AutomationPattern::timeMap::const_iterator firstNode = + AutomationClip::timeMap::const_iterator firstNode = m_autoPattern->getTimeMap().begin(); if (isAtInitValue() @@ -75,11 +75,11 @@ class InlineAutomation : public FloatModel, public sharedObject return false; } - AutomationPattern * automationPattern() + AutomationClip * automationPattern() { if( m_autoPattern == NULL ) { - m_autoPattern = new AutomationPattern( NULL ); + m_autoPattern = new AutomationClip( NULL ); m_autoPattern->addObject( this ); } return m_autoPattern; @@ -90,7 +90,7 @@ class InlineAutomation : public FloatModel, public sharedObject private: - AutomationPattern * m_autoPattern; + AutomationClip * m_autoPattern; } ; diff --git a/include/Song.h b/include/Song.h index d05c4391001..0171d3c526d 100644 --- a/include/Song.h +++ b/include/Song.h @@ -63,7 +63,7 @@ class LMMS_EXPORT Song : public TrackContainer Mode_PlaySong, Mode_PlayBB, Mode_PlayPattern, - Mode_PlayAutomationPattern, + Mode_PlayAutomationClip, Mode_Count } ; @@ -272,7 +272,7 @@ class LMMS_EXPORT Song : public TrackContainer bpm_t getTempo(); - AutomationPattern * tempoAutomationPattern() override; + AutomationClip * tempoAutomationClip() override; AutomationTrack * globalAutomationTrack() { diff --git a/include/TrackContainer.h b/include/TrackContainer.h index 06d2d0a056e..58553cebdcc 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -32,7 +32,7 @@ #include "JournallingObject.h" -class AutomationPattern; +class AutomationClip; class InstrumentTrack; class TrackContainerView; @@ -56,7 +56,7 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject void loadSettings( const QDomElement & _this ) override; - virtual AutomationPattern * tempoAutomationPattern() + virtual AutomationClip * tempoAutomationClip() { return NULL; } diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index 117e1e0e10e..1344dc0cfe4 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -36,7 +36,7 @@ #include "LadspaSubPluginFeatures.h" #include "Mixer.h" #include "EffectChain.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "ControllerConnection.h" #include "MemoryManager.h" #include "ValueBuffer.h" @@ -122,7 +122,7 @@ void LadspaEffect::changeSampleRate() // the IDs of re-created controls have been saved and now need to be // resolved again - AutomationPattern::resolveAllIDs(); + AutomationClip::resolveAllIDs(); } diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 93bea56e75b..2c8352a9379 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -37,7 +37,7 @@ #include "TrackContainer.h" #include "InstrumentTrack.h" #include "AutomationTrack.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "ConfigManager.h" #include "Pattern.h" #include "Instrument.h" @@ -159,7 +159,7 @@ class smfMidiCC { } AutomationTrack * at; - AutomationPattern * ap; + AutomationClip * ap; TimePos lastPos; smfMidiCC & create( TrackContainer* tc, QString tn ) @@ -192,7 +192,7 @@ class smfMidiCC if( !ap || time > lastPos + DefaultTicksPerBar ) { TimePos pPos = TimePos( time.getBar(), 0 ); - ap = dynamic_cast( + ap = dynamic_cast( at->createClip(pPos)); ap->addObject( objModel ); } @@ -336,12 +336,12 @@ bool MidiImport::readSMF( TrackContainer* tc ) AutomationTrack * dt = dynamic_cast( Track::create(Track::AutomationTrack, Engine::getSong())); dt->setName(tr("MIDI Time Signature Denominator")); - AutomationPattern * timeSigNumeratorPat = - new AutomationPattern(nt); + AutomationClip * timeSigNumeratorPat = + new AutomationClip(nt); timeSigNumeratorPat->setDisplayName(tr("Numerator")); timeSigNumeratorPat->addObject(&timeSigMM.numeratorModel()); - AutomationPattern * timeSigDenominatorPat = - new AutomationPattern(dt); + AutomationClip * timeSigDenominatorPat = + new AutomationClip(dt); timeSigDenominatorPat->setDisplayName(tr("Denominator")); timeSigDenominatorPat->addObject(&timeSigMM.denominatorModel()); @@ -364,7 +364,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) pd.setValue( 2 ); // Tempo stuff - AutomationPattern * tap = tc->tempoAutomationPattern(); + AutomationClip * tap = tc->tempoAutomationClip(); if( tap ) { tap->clear(); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 2c1162e0d18..77bf3c4005e 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -26,7 +26,7 @@ #include "lmms_math.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "ControllerConnection.h" #include "LocaleHelper.h" #include "Mixer.h" @@ -87,7 +87,7 @@ AutomatableModel::~AutomatableModel() bool AutomatableModel::isAutomated() const { - return AutomationPattern::isAutomated( this ); + return AutomationClip::isAutomated( this ); } @@ -176,13 +176,13 @@ void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, co void AutomatableModel::loadSettings( const QDomElement& element, const QString& name ) { // compat code - QDomNode node = element.namedItem( AutomationPattern::classNodeName() ); + QDomNode node = element.namedItem( AutomationClip::classNodeName() ); if( node.isElement() ) { node = node.namedItem( name ); if( node.isElement() ) { - AutomationPattern * p = AutomationPattern::globalAutomationPattern( this ); + AutomationClip * p = AutomationClip::globalAutomationClip( this ); p->loadSettings( node.toElement() ); setValue( p->valueAt( 0 ) ); // in older projects we sometimes have odd automations @@ -718,57 +718,57 @@ void AutomatableModel::reset() float AutomatableModel::globalAutomationValueAt( const TimePos& time ) { - // get patterns that connect to this model - QVector patterns = AutomationPattern::patternsForModel( this ); - if( patterns.isEmpty() ) + // get clips that connect to this model + QVector clips = AutomationClip::clipsForModel( this ); + if( clips.isEmpty() ) { - // if no such patterns exist, return current value + // if no such clips exist, return current value return m_value; } else { - // of those patterns: - // find the patterns which overlap with the time position - QVector patternsInRange; - for( QVector::ConstIterator it = patterns.begin(); it != patterns.end(); it++ ) + // of those clips: + // find the clips which overlap with the time position + QVector clipsInRange; + for( QVector::ConstIterator it = clips.begin(); it != clips.end(); it++ ) { int s = ( *it )->startPosition(); int e = ( *it )->endPosition(); - if( s <= time && e >= time ) { patternsInRange += ( *it ); } + if( s <= time && e >= time ) { clipsInRange += ( *it ); } } - AutomationPattern * latestPattern = NULL; + AutomationClip * latestClip = NULL; - if( ! patternsInRange.isEmpty() ) + if( ! clipsInRange.isEmpty() ) { - // if there are more than one overlapping patterns, just use the first one because - // multiple pattern behaviour is undefined anyway - latestPattern = patternsInRange[0]; + // if there are more than one overlapping clips, just use the first one because + // multiple clip behaviour is undefined anyway + latestClip = clipsInRange[0]; } else - // if we find no patterns at the exact time, we need to search for the last pattern before time and use that + // if we find no clips at the exact time, we need to search for the last clip before time and use that { int latestPosition = 0; - for( QVector::ConstIterator it = patterns.begin(); it != patterns.end(); it++ ) + for( QVector::ConstIterator it = clips.begin(); it != clips.end(); it++ ) { int e = ( *it )->endPosition(); if( e <= time && e > latestPosition ) { latestPosition = e; - latestPattern = ( *it ); + latestClip = ( *it ); } } } - if( latestPattern ) + if( latestClip ) { // scale/fit the value appropriately and return it - const float value = latestPattern->valueAt( time - latestPattern->startPosition() ); + const float value = latestClip->valueAt( time - latestClip->startPosition() ); const float scaled_value = scaledValue( value ); return fittedValue( scaled_value ); } - // if we still find no pattern, the value at that time is undefined so + // if we still find no clip, the value at that time is undefined so // just return current value as the best we can do else return m_value; } diff --git a/src/core/AutomationNode.cpp b/src/core/AutomationNode.cpp index d289b2f216f..1e80f9a527b 100644 --- a/src/core/AutomationNode.cpp +++ b/src/core/AutomationNode.cpp @@ -1,6 +1,6 @@ /* - * AutomationPattern.cpp - Implementation of class AutomationNode which - * holds information on a single automation pattern node + * AutomationClip.cpp - Implementation of class AutomationNode which + * holds information on a single automation clip node * * Copyright (c) 2020 Ian Caio * @@ -24,12 +24,12 @@ */ #include "AutomationNode.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" // Dummy constructor for the QMap AutomationNode::AutomationNode() : - m_pattern(nullptr), + m_clip(nullptr), m_pos(0), m_inValue(0), m_outValue(0), @@ -38,8 +38,8 @@ AutomationNode::AutomationNode() : { } -AutomationNode::AutomationNode(AutomationPattern* pat, float value, int pos) : - m_pattern(pat), +AutomationNode::AutomationNode(AutomationClip* pat, float value, int pos) : + m_clip(pat), m_pos(pos), m_inValue(value), m_outValue(value), @@ -48,8 +48,8 @@ AutomationNode::AutomationNode(AutomationPattern* pat, float value, int pos) : { } -AutomationNode::AutomationNode(AutomationPattern* pat, float inValue, float outValue, int pos) : - m_pattern(pat), +AutomationNode::AutomationNode(AutomationClip* pat, float inValue, float outValue, int pos) : + m_clip(pat), m_pos(pos), m_inValue(inValue), m_outValue(outValue), @@ -67,15 +67,15 @@ void AutomationNode::setInValue(float value) m_inValue = value; // Recalculate the tangents from neighbor nodes - AutomationPattern::timeMap & tm = m_pattern->getTimeMap(); + AutomationClip::timeMap & tm = m_clip->getTimeMap(); // Get an iterator pointing to this node - AutomationPattern::timeMap::iterator it = tm.lowerBound(m_pos); + AutomationClip::timeMap::iterator it = tm.lowerBound(m_pos); // If it's not the first node, get the one immediately behind it if (it != tm.begin()) { --it; } // Generate tangents from the previously, current and next nodes - m_pattern->generateTangents(it, 3); + m_clip->generateTangents(it, 3); } /** @@ -87,15 +87,15 @@ void AutomationNode::setOutValue(float value) m_outValue = value; // Recalculate the tangents from neighbor nodes - AutomationPattern::timeMap & tm = m_pattern->getTimeMap(); + AutomationClip::timeMap & tm = m_clip->getTimeMap(); // Get an iterator pointing to this node - AutomationPattern::timeMap::iterator it = tm.lowerBound(m_pos); + AutomationClip::timeMap::iterator it = tm.lowerBound(m_pos); // If it's not the first node, get the one immediately behind it if (it != tm.begin()) { --it; } // Generate tangents from the previously, current and next nodes - m_pattern->generateTangents(it, 3); + m_clip->generateTangents(it, 3); } /** diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp deleted file mode 100644 index f010e3e26ed..00000000000 --- a/src/core/AutomationPattern.cpp +++ /dev/null @@ -1,1184 +0,0 @@ -/* - * AutomationPattern.cpp - implementation of class AutomationPattern which - * holds dynamic values - * - * Copyright (c) 2008-2014 Tobias Doerffel - * Copyright (c) 2006-2008 Javier Serrano Polo - * - * This file is part of LMMS - https://lmms.io - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program (see COPYING); if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - -#include "AutomationPattern.h" - -#include "AutomationNode.h" -#include "AutomationPatternView.h" -#include "AutomationTrack.h" -#include "BBTrackContainer.h" -#include "LocaleHelper.h" -#include "ProjectJournal.h" -#include "Song.h" - -#include - -int AutomationPattern::s_quantization = 1; -const float AutomationPattern::DEFAULT_MIN_VALUE = 0; -const float AutomationPattern::DEFAULT_MAX_VALUE = 1; - - -AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : - Clip( _auto_track ), - m_patternMutex(QMutex::Recursive), - m_autoTrack( _auto_track ), - m_objects(), - m_tension( 1.0 ), - m_progressionType( DiscreteProgression ), - m_dragging( false ), - m_isRecording( false ), - m_lastRecordedValue( 0 ) -{ - changeLength( TimePos( 1, 0 ) ); - if( getTrack() ) - { - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::BBContainer: - setAutoResize( true ); - break; - - case TrackContainer::SongContainer: - // move down - default: - setAutoResize( false ); - break; - } - } -} - - - - -AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : - Clip( _pat_to_copy.m_autoTrack ), - m_patternMutex(QMutex::Recursive), - m_autoTrack( _pat_to_copy.m_autoTrack ), - m_objects( _pat_to_copy.m_objects ), - m_tension( _pat_to_copy.m_tension ), - m_progressionType( _pat_to_copy.m_progressionType ) -{ - // Locks the mutex of the copied AutomationPattern to make sure it - // doesn't change while it's being copied - QMutexLocker m(&_pat_to_copy.m_patternMutex); - - for( timeMap::const_iterator it = _pat_to_copy.m_timeMap.begin(); - it != _pat_to_copy.m_timeMap.end(); ++it ) - { - // Copies the automation node (in/out values and in/out tangents) - m_timeMap[POS(it)] = it.value(); - // Sets the node's pattern to this one - m_timeMap[POS(it)].setPattern(this); - } - if (!getTrack()){ return; } - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::BBContainer: - setAutoResize( true ); - break; - - case TrackContainer::SongContainer: - // move down - default: - setAutoResize( false ); - break; - } -} - -bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) -{ - QMutexLocker m(&m_patternMutex); - - if( _search_dup && m_objects.contains(_obj) ) - { - return false; - } - - // the automation track is unconnected and there is nothing in the track - if( m_objects.isEmpty() && hasAutomation() == false ) - { - // then initialize first value - putValue( TimePos(0), _obj->inverseScaledValue( _obj->value() ), false ); - } - - m_objects += _obj; - - connect( _obj, SIGNAL( destroyed( jo_id_t ) ), - this, SLOT( objectDestroyed( jo_id_t ) ), - Qt::DirectConnection ); - - emit dataChanged(); - - return true; -} - - - - -void AutomationPattern::setProgressionType( - ProgressionTypes _new_progression_type ) -{ - QMutexLocker m(&m_patternMutex); - - if ( _new_progression_type == DiscreteProgression || - _new_progression_type == LinearProgression || - _new_progression_type == CubicHermiteProgression ) - { - m_progressionType = _new_progression_type; - emit dataChanged(); - } -} - - - - -void AutomationPattern::setTension( QString _new_tension ) -{ - QMutexLocker m(&m_patternMutex); - - bool ok; - float nt = LocaleHelper::toFloat(_new_tension, & ok); - - if( ok && nt > -0.01 && nt < 1.01 ) - { - m_tension = nt; - } -} - - - - -const AutomatableModel * AutomationPattern::firstObject() const -{ - QMutexLocker m(&m_patternMutex); - - AutomatableModel* model; - if (!m_objects.isEmpty() && (model = m_objects.first()) != nullptr) - { - return model; - } - - static FloatModel fm(0, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, 0.001); - return &fm; -} - -const AutomationPattern::objectVector& AutomationPattern::objects() const -{ - QMutexLocker m(&m_patternMutex); - - return m_objects; -} - - - - -TimePos AutomationPattern::timeMapLength() const -{ - QMutexLocker m(&m_patternMutex); - - TimePos one_bar = TimePos(1, 0); - if (m_timeMap.isEmpty()) { return one_bar; } - - timeMap::const_iterator it = m_timeMap.end(); - tick_t last_tick = static_cast(POS(it - 1)); - // if last_tick is 0 (single item at tick 0) - // return length as a whole bar to prevent disappearing Clip - if (last_tick == 0) { return one_bar; } - - return TimePos(last_tick); -} - - - - -void AutomationPattern::updateLength() -{ - // Do not resize down in case user manually extended up - changeLength(qMax(length(), timeMapLength())); -} - - - - -/** - * @brief Puts an automation node on the timeMap with the given value. - * The inValue and outValue of the created node will be the same. - * @param TimePos time to add the node to - * @param Float inValue and outValue of the node - * @param Boolean True to quantize the position (defaults to true) - * @param Boolean True to ignore unquantized surrounding nodes (defaults to true) - * @return TimePos of the recently added automation node - */ -TimePos AutomationPattern::putValue( - const TimePos & time, - const float value, - const bool quantPos, - const bool ignoreSurroundingPoints -) -{ - QMutexLocker m(&m_patternMutex); - - cleanObjects(); - - TimePos newTime = quantPos ? Note::quantized(time, quantization()) : time; - - // Create a node or replace the existing one on newTime - m_timeMap[newTime] = AutomationNode(this, value, newTime); - - timeMap::iterator it = m_timeMap.find(newTime); - - // Remove control points that are covered by the new points - // quantization value. Control Key to override - if (!ignoreSurroundingPoints) - { - // We need to check that to avoid removing nodes from - // newTime + 1 to newTime (removing the node we are adding) - if (quantization() > 1) - { - // Remove nodes between the quantization points, them not - // being included - removeNodes(newTime + 1, newTime + quantization() - 1); - } - } - if (it != m_timeMap.begin()) { --it; } - generateTangents(it, 3); - - updateLength(); - - emit dataChanged(); - - return newTime; -} - - - - -/** - * @brief Puts an automation node on the timeMap with the given inValue - * and outValue. - * @param TimePos time to add the node to - * @param Float inValue of the node - * @param Float outValue of the node - * @param Boolean True to quantize the position (defaults to true) - * @param Boolean True to ignore unquantized surrounding nodes (defaults to true) - * @return TimePos of the recently added automation node - */ -TimePos AutomationPattern::putValues( - const TimePos & time, - const float inValue, - const float outValue, - const bool quantPos, - const bool ignoreSurroundingPoints -) -{ - QMutexLocker m(&m_patternMutex); - - cleanObjects(); - - TimePos newTime = quantPos ? Note::quantized(time, quantization()) : time; - - // Create a node or replace the existing one on newTime - m_timeMap[newTime] = AutomationNode(this, inValue, outValue, newTime); - - timeMap::iterator it = m_timeMap.find(newTime); - - // Remove control points that are covered by the new points - // quantization value. Control Key to override - if (!ignoreSurroundingPoints) - { - // We need to check that to avoid removing nodes from - // newTime + 1 to newTime (removing the node we are adding) - if (quantization() > 1) - { - // Remove nodes between the quantization points, them not - // being included - removeNodes(newTime + 1, newTime + quantization() - 1); - } - } - if (it != m_timeMap.begin()) { --it; } - generateTangents(it, 3); - - updateLength(); - - emit dataChanged(); - - return newTime; -} - - - - -void AutomationPattern::removeNode(const TimePos & time) -{ - QMutexLocker m(&m_patternMutex); - - cleanObjects(); - - m_timeMap.remove( time ); - timeMap::iterator it = m_timeMap.lowerBound(time); - if( it != m_timeMap.begin() ) - { - --it; - } - generateTangents(it, 3); - - updateLength(); - - emit dataChanged(); -} - - - - -/** - * @brief Removes all automation nodes between the given ticks - * @param Int first tick of the range - * @param Int second tick of the range - */ -void AutomationPattern::removeNodes(const int tick0, const int tick1) -{ - if (tick0 == tick1) - { - removeNode(TimePos(tick0)); - return; - } - - TimePos start = TimePos(qMin(tick0, tick1)); - TimePos end = TimePos(qMax(tick0, tick1)); - - // Make a list of TimePos with nodes to be removed - // because we can't simply remove the nodes from - // the timeMap while we are iterating it. - QVector nodesToRemove; - - for (auto it = m_timeMap.lowerBound(start), endIt = m_timeMap.upperBound(end); it != endIt; ++it) - { - nodesToRemove.append(POS(it)); - } - - for (auto node: nodesToRemove) - { - removeNode(node); - } -} - - - - -/** - * @brief Resets the outValues of all automation nodes between the given ticks - * @param Int first tick of the range - * @param Int second tick of the range - */ -void AutomationPattern::resetNodes(const int tick0, const int tick1) -{ - if (tick0 == tick1) - { - auto it = m_timeMap.find(TimePos(tick0)); - if (it != m_timeMap.end()) { it.value().resetOutValue(); } - return; - } - - TimePos start = TimePos(qMin(tick0, tick1)); - TimePos end = TimePos(qMax(tick0, tick1)); - - for (auto it = m_timeMap.lowerBound(start), endIt = m_timeMap.upperBound(end); it != endIt; ++it) - { - it.value().resetOutValue(); - } -} - - - - -void AutomationPattern::recordValue(TimePos time, float value) -{ - QMutexLocker m(&m_patternMutex); - - if( value != m_lastRecordedValue ) - { - putValue( time, value, true ); - m_lastRecordedValue = value; - } - else if( valueAt( time ) != value ) - { - removeNode(time); - } -} - - - - -/** - * @brief Set the position of the point that is being dragged. - * Calling this function will also automatically set m_dragging to true. - * When applyDragValue() is called, m_dragging is set back to false. - * @param TimePos of the node being dragged - * @param Float with the value to assign to the point being dragged - * @param Boolean. True to snip x position - * @param Boolean. True to ignore unquantized surrounding nodes - * @return TimePos with current time of the dragged value - */ -TimePos AutomationPattern::setDragValue( - const TimePos & time, - const float value, - const bool quantPos, - const bool controlKey -) -{ - QMutexLocker m(&m_patternMutex); - - if (m_dragging == false) - { - TimePos newTime = quantPos ? Note::quantized(time, quantization()) : time; - - // We will keep the same outValue only if it's different from the - // inValue - m_dragKeepOutValue = false; - - // Check if we already have a node on the position we are dragging - // and if we do, store the outValue so the discrete jump can be kept - timeMap::iterator it = m_timeMap.find(newTime); - if (it != m_timeMap.end()) - { - if (OFFSET(it) != 0) - { - m_dragKeepOutValue = true; - m_dragOutValue = OUTVAL(it); - } - } - - this->removeNode(newTime); - m_oldTimeMap = m_timeMap; - m_dragging = true; - } - - //Restore to the state before it the point were being dragged - m_timeMap = m_oldTimeMap; - - generateTangents(); - - if (m_dragKeepOutValue) - { - return this->putValues(time, value, m_dragOutValue, quantPos, controlKey); - } - - return this->putValue(time, value, quantPos, controlKey); -} - - - - -/** - * @brief After the point is dragged, this function is called to apply the change. - */ -void AutomationPattern::applyDragValue() -{ - QMutexLocker m(&m_patternMutex); - - m_dragging = false; -} - - - - -float AutomationPattern::valueAt( const TimePos & _time ) const -{ - QMutexLocker m(&m_patternMutex); - - if( m_timeMap.isEmpty() ) - { - return 0; - } - - // If we have a node at that time, just return its value - if (m_timeMap.contains(_time)) - { - // When the time is exactly the node's time, we want the inValue - return m_timeMap[_time].getInValue(); - } - - // lowerBound returns next value with equal or greater key. Since we already - // checked if the key contains a node, we know the returned node has a greater - // key than _time. Therefore we take the previous element to calculate the current value - timeMap::const_iterator v = m_timeMap.lowerBound(_time); - - if( v == m_timeMap.begin() ) - { - return 0; - } - if( v == m_timeMap.end() ) - { - // When the time is after the last node, we want the outValue of it - return OUTVAL(v - 1); - } - - return valueAt(v - 1, _time - POS(v - 1)); -} - - - - -// This method will get the value at an offset from a node, so we use the outValue of -// that node and the inValue of the next node for the calculations. -float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const -{ - QMutexLocker m(&m_patternMutex); - - // We never use it with offset 0, but doesn't hurt to return a correct - // value if we do - if (offset == 0) { return INVAL(v); } - - if (m_progressionType == DiscreteProgression) - { - return OUTVAL(v); - } - else if( m_progressionType == LinearProgression ) - { - float slope = - (INVAL(v + 1) - OUTVAL(v)) - / (POS(v + 1) - POS(v)); - - return OUTVAL(v) + offset * slope; - } - else /* CubicHermiteProgression */ - { - // Implements a Cubic Hermite spline as explained at: - // http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Unit_interval_.280.2C_1.29 - // - // Note that we are not interpolating a 2 dimensional point over - // time as the article describes. We are interpolating a single - // value: y. To make this work we map the values of x that this - // segment spans to values of t for t = 0.0 -> 1.0 and scale the - // tangents _m1 and _m2 - int numValues = (POS(v + 1) - POS(v)); - float t = (float) offset / (float) numValues; - float m1 = OUTTAN(v) * numValues * m_tension; - float m2 = INTAN(v + 1) * numValues * m_tension; - - auto t2 = pow(t, 2); - auto t3 = pow(t, 3); - return (2 * t3 - 3 * t2 + 1) * OUTVAL(v) - + (t3 - 2 * t2 + t) * m1 - + (-2 * t3 + 3 * t2) * INVAL(v + 1) - + (t3 - t2) * m2; - } -} - - - - -float *AutomationPattern::valuesAfter( const TimePos & _time ) const -{ - QMutexLocker m(&m_patternMutex); - - timeMap::const_iterator v = m_timeMap.lowerBound(_time); - if( v == m_timeMap.end() || (v+1) == m_timeMap.end() ) - { - return NULL; - } - - int numValues = POS(v + 1) - POS(v); - float *ret = new float[numValues]; - - for( int i = 0; i < numValues; i++ ) - { - ret[i] = valueAt( v, i ); - } - - return ret; -} - - - - -void AutomationPattern::flipY(int min, int max) -{ - QMutexLocker m(&m_patternMutex); - - bool changedTimeMap = false; - - for (auto it = m_timeMap.begin(); it != m_timeMap.end(); ++it) - { - // Get distance from IN/OUT values to max value - float inValDist = max - INVAL(it); - float outValDist = max - OUTVAL(it); - - // To flip, that will be the new distance between - // the IN/OUT values and the min value - it.value().setInValue(min + inValDist); - it.value().setOutValue(min + outValDist); - - changedTimeMap = true; - } - - if (changedTimeMap) - { - generateTangents(); - emit dataChanged(); - } -} - - - - -void AutomationPattern::flipY() -{ - flipY(getMin(), getMax()); -} - - - - -void AutomationPattern::flipX(int length) -{ - QMutexLocker m(&m_patternMutex); - - timeMap::const_iterator it = m_timeMap.lowerBound(0); - - if (it == m_timeMap.end()) { return; } - - // Temporary map where we will store the flipped version - // of our pattern - timeMap tempMap; - - float tempValue = 0; - float tempOutValue = 0; - - // We know the QMap isn't empty, making this safe: - float realLength = m_timeMap.lastKey(); - - // If we have a positive length, we want to flip the area covered by that - // length, even if it goes beyond the pattern. A negative length means that - // we just want to flip the nodes we have - if (length >= 0 && length != realLength) - { - // If length to be flipped is bigger than the real length - if (realLength < length) - { - // We are flipping an area that goes beyond the last node. So we add a node to the - // beginning of the flipped timeMap representing the value of the end of the area - tempValue = valueAt(length); - tempMap[0] = AutomationNode(this, tempValue, 0); - - // Now flip the nodes we have in relation to the length - do - { - // We swap the inValue and outValue when flipping horizontally - tempValue = OUTVAL(it); - tempOutValue = INVAL(it); - TimePos newTime = TimePos(length - POS(it)); - - tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); - - ++it; - } while (it != m_timeMap.end()); - } - else // If the length to be flipped is smaller than the real length - { - do - { - TimePos newTime; - - // Only flips the length to be flipped and keep the remaining values in place - // We also only swap the inValue and outValue if we are flipping the node - if (POS(it) <= length) - { - newTime = length - POS(it); - tempValue = OUTVAL(it); - tempOutValue = INVAL(it); - } - else - { - newTime = POS(it); - tempValue = INVAL(it); - tempOutValue = OUTVAL(it); - } - - tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); - - ++it; - } while (it != m_timeMap.end()); - } - } - else // Length to be flipped is the same as the real length - { - do - { - // Swap the inValue and outValue - tempValue = OUTVAL(it); - tempOutValue = INVAL(it); - - TimePos newTime = TimePos(realLength - POS(it)); - tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); - - ++it; - } while (it != m_timeMap.end()); - } - - m_timeMap.clear(); - - m_timeMap = tempMap; - - cleanObjects(); - - generateTangents(); - emit dataChanged(); -} - - - - -void AutomationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this ) -{ - QMutexLocker m(&m_patternMutex); - - _this.setAttribute( "pos", startPosition() ); - _this.setAttribute( "len", length() ); - _this.setAttribute( "name", name() ); - _this.setAttribute( "prog", QString::number( progressionType() ) ); - _this.setAttribute( "tens", QString::number( getTension() ) ); - _this.setAttribute( "mute", QString::number( isMuted() ) ); - - if( usesCustomClipColor() ) - { - _this.setAttribute( "color", color().name() ); - } - - for( timeMap::const_iterator it = m_timeMap.begin(); - it != m_timeMap.end(); ++it ) - { - QDomElement element = _doc.createElement( "time" ); - element.setAttribute("pos", POS(it)); - element.setAttribute("value", INVAL(it)); - element.setAttribute("outValue", OUTVAL(it)); - _this.appendChild( element ); - } - - for( objectVector::const_iterator it = m_objects.begin(); - it != m_objects.end(); ++it ) - { - if( *it ) - { - QDomElement element = _doc.createElement( "object" ); - element.setAttribute( "id", - ProjectJournal::idToSave( ( *it )->id() ) ); - _this.appendChild( element ); - } - } -} - - - - -void AutomationPattern::loadSettings( const QDomElement & _this ) -{ - QMutexLocker m(&m_patternMutex); - - clear(); - - movePosition( _this.attribute( "pos" ).toInt() ); - setName( _this.attribute( "name" ) ); - setProgressionType( static_cast( _this.attribute( - "prog" ).toInt() ) ); - setTension( _this.attribute( "tens" ) ); - setMuted(_this.attribute( "mute", QString::number( false ) ).toInt() ); - - for( QDomNode node = _this.firstChild(); !node.isNull(); - node = node.nextSibling() ) - { - QDomElement element = node.toElement(); - if( element.isNull() ) - { - continue; - } - if( element.tagName() == "time" ) - { - int timeMapPos = element.attribute("pos").toInt(); - float timeMapInValue = LocaleHelper::toFloat(element.attribute("value")); - float timeMapOutValue = LocaleHelper::toFloat(element.attribute("outValue")); - - m_timeMap[timeMapPos] = AutomationNode(this, timeMapInValue, timeMapOutValue, timeMapPos); - } - else if( element.tagName() == "object" ) - { - m_idsToResolve << element.attribute( "id" ).toInt(); - } - } - - if( _this.hasAttribute( "color" ) ) - { - useCustomClipColor( true ); - setColor( _this.attribute( "color" ) ); - } - - int len = _this.attribute( "len" ).toInt(); - if( len <= 0 ) - { - // TODO: Handle with an upgrade method - updateLength(); - } - else - { - changeLength( len ); - } - generateTangents(); -} - - - - -const QString AutomationPattern::name() const -{ - QMutexLocker m(&m_patternMutex); - - if( !Clip::name().isEmpty() ) - { - return Clip::name(); - } - if( !m_objects.isEmpty() && m_objects.first() != NULL ) - { - return m_objects.first()->fullDisplayName(); - } - return tr( "Drag a control while pressing <%1>" ).arg(UI_CTRL_KEY); -} - - - - -ClipView * AutomationPattern::createView( TrackView * _tv ) -{ - QMutexLocker m(&m_patternMutex); - - return new AutomationPatternView( this, _tv ); -} - - - - - -bool AutomationPattern::isAutomated( const AutomatableModel * _m ) -{ - TrackContainer::TrackList l; - l += Engine::getSong()->tracks(); - l += Engine::getBBTrackContainer()->tracks(); - l += Engine::getSong()->globalAutomationTrack(); - - for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) - { - if( ( *it )->type() == Track::AutomationTrack || - ( *it )->type() == Track::HiddenAutomationTrack ) - { - const Track::clipVector & v = ( *it )->getClips(); - for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) - { - const AutomationPattern * a = dynamic_cast( *j ); - if( a && a->hasAutomation() ) - { - for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k ) - { - if( *k == _m ) - { - return true; - } - } - } - } - } - } - return false; -} - - -/** - * @brief returns a list of all the automation patterns that are connected to a specific model - * @param _m the model we want to look for - */ -QVector AutomationPattern::patternsForModel( const AutomatableModel * _m ) -{ - QVector patterns; - TrackContainer::TrackList l; - l += Engine::getSong()->tracks(); - l += Engine::getBBTrackContainer()->tracks(); - l += Engine::getSong()->globalAutomationTrack(); - - // go through all tracks... - for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) - { - // we want only automation tracks... - if( ( *it )->type() == Track::AutomationTrack || - ( *it )->type() == Track::HiddenAutomationTrack ) - { - // get patterns in those tracks.... - const Track::clipVector & v = ( *it )->getClips(); - // go through all the patterns... - for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) - { - AutomationPattern * a = dynamic_cast( *j ); - // check that the pattern has automation - if( a && a->hasAutomation() ) - { - // now check is the pattern is connected to the model we want by going through all the connections - // of the pattern - bool has_object = false; - for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k ) - { - if( *k == _m ) - { - has_object = true; - } - } - // if the patterns is connected to the model, add it to the list - if( has_object ) { patterns += a; } - } - } - } - } - return patterns; -} - - - -AutomationPattern * AutomationPattern::globalAutomationPattern( - AutomatableModel * _m ) -{ - AutomationTrack * t = Engine::getSong()->globalAutomationTrack(); - Track::clipVector v = t->getClips(); - for( Track::clipVector::const_iterator j = v.begin(); j != v.end(); ++j ) - { - AutomationPattern * a = dynamic_cast( *j ); - if( a ) - { - for( objectVector::const_iterator k = a->m_objects.begin(); - k != a->m_objects.end(); ++k ) - { - if( *k == _m ) - { - return a; - } - } - } - } - - AutomationPattern * a = new AutomationPattern( t ); - a->addObject( _m, false ); - return a; -} - - - - -void AutomationPattern::resolveAllIDs() -{ - TrackContainer::TrackList l = Engine::getSong()->tracks() + - Engine::getBBTrackContainer()->tracks(); - l += Engine::getSong()->globalAutomationTrack(); - for( TrackContainer::TrackList::iterator it = l.begin(); - it != l.end(); ++it ) - { - if( ( *it )->type() == Track::AutomationTrack || - ( *it )->type() == Track::HiddenAutomationTrack ) - { - Track::clipVector v = ( *it )->getClips(); - for( Track::clipVector::iterator j = v.begin(); - j != v.end(); ++j ) - { - AutomationPattern * a = dynamic_cast( *j ); - if( a ) - { - for( QVector::Iterator k = a->m_idsToResolve.begin(); - k != a->m_idsToResolve.end(); ++k ) - { - JournallingObject * o = Engine::projectJournal()-> - journallingObject( *k ); - if( o && dynamic_cast( o ) ) - { - a->addObject( dynamic_cast( o ), false ); - } - else - { - // FIXME: Remove this block once the automation system gets fixed - // This is a temporary fix for https://github.com/LMMS/lmms/issues/3781 - o = Engine::projectJournal()->journallingObject(ProjectJournal::idFromSave(*k)); - if( o && dynamic_cast( o ) ) - { - a->addObject( dynamic_cast( o ), false ); - } - else - { - // FIXME: Remove this block once the automation system gets fixed - // This is a temporary fix for https://github.com/LMMS/lmms/issues/4781 - o = Engine::projectJournal()->journallingObject(ProjectJournal::idToSave(*k)); - if( o && dynamic_cast( o ) ) - { - a->addObject( dynamic_cast( o ), false ); - } - } - } - } - a->m_idsToResolve.clear(); - a->dataChanged(); - } - } - } - } -} - - - - -void AutomationPattern::clear() -{ - QMutexLocker m(&m_patternMutex); - - m_timeMap.clear(); - - emit dataChanged(); -} - - - - -void AutomationPattern::objectDestroyed( jo_id_t _id ) -{ - QMutexLocker m(&m_patternMutex); - - // TODO: distict between temporary removal (e.g. LADSPA controls - // when switching samplerate) and real deletions because in the latter - // case we had to remove ourselves if we're the global automation - // pattern of the destroyed object - m_idsToResolve += _id; - - for( objectVector::Iterator objIt = m_objects.begin(); - objIt != m_objects.end(); objIt++ ) - { - Q_ASSERT( !(*objIt).isNull() ); - if( (*objIt)->id() == _id ) - { - //Assign to objIt so that this loop work even break; is removed. - objIt = m_objects.erase( objIt ); - break; - } - } - - emit dataChanged(); -} - - - - -void AutomationPattern::cleanObjects() -{ - QMutexLocker m(&m_patternMutex); - - for( objectVector::iterator it = m_objects.begin(); it != m_objects.end(); ) - { - if( *it ) - { - ++it; - } - else - { - it = m_objects.erase( it ); - } - } -} - - - - -void AutomationPattern::generateTangents() -{ - generateTangents(m_timeMap.begin(), m_timeMap.size()); -} - - - - -// We have two tangents, one for the left side of the node and one for the right side -// of the node (in case we have discrete value jumps in the middle of a curve). -// If the inValue and outValue of a node are the same, consequently the inTangent and -// outTangent values of the node will be the same too. -void AutomationPattern::generateTangents(timeMap::iterator it, int numToGenerate) -{ - QMutexLocker m(&m_patternMutex); - - if( m_timeMap.size() < 2 && numToGenerate > 0 ) - { - it.value().setInTangent(0); - it.value().setOutTangent(0); - return; - } - - for( int i = 0; i < numToGenerate; i++ ) - { - if( it == m_timeMap.begin() ) - { - // On the first node there's no curve behind it, so we will only calculate the outTangent - // and inTangent will be set to 0. - float tangent = (INVAL(it + 1) - OUTVAL(it)) / (POS(it + 1) - POS(it)); - it.value().setInTangent(0); - it.value().setOutTangent(tangent); - } - else if( it+1 == m_timeMap.end() ) - { - // Previously, the last value's tangent was always set to 0. That logic was kept for both tangents - // of the last node - it.value().setInTangent(0); - it.value().setOutTangent(0); - return; - } - else - { - // When we are in a node that is in the middle of two other nodes, we need to check if we - // have a discrete jump at this node. If we do not, then we can calculate the tangents normally. - // If we do have a discrete jump, then we have to calculate the tangents differently for each side - // of the curve. - // TODO: This behavior means that a very small difference between the inValue and outValue can - // result in a big change in the curve. In the future, allowing the user to manually adjust - // the tangents would be better. - float inTangent; - float outTangent; - if (OFFSET(it) == 0) - { - inTangent = (INVAL(it + 1) - OUTVAL(it - 1)) / (POS(it + 1) - POS(it - 1)); - it.value().setInTangent(inTangent); - // inTangent == outTangent in this case - it.value().setOutTangent(inTangent); - } - else - { - // Calculate the left side of the curve - inTangent = (INVAL(it) - OUTVAL(it - 1)) / (POS(it) - POS(it - 1)); - // Calculate the right side of the curve - outTangent = (INVAL(it + 1) - OUTVAL(it)) / (POS(it + 1) - POS(it)); - it.value().setInTangent(inTangent); - it.value().setOutTangent(outTangent); - } - } - it++; - } -} diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e41cd830369..b481d2a5b7b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2,7 +2,7 @@ set(LMMS_SRCS ${LMMS_SRCS} core/AutomatableModel.cpp - core/AutomationPattern.cpp + core/AutomationClip.cpp core/AutomationNode.cpp core/BandLimitedWave.cpp core/base64.cpp diff --git a/src/core/Clip.cpp b/src/core/Clip.cpp index ec7a8bfc891..c81cd66330f 100644 --- a/src/core/Clip.cpp +++ b/src/core/Clip.cpp @@ -27,7 +27,7 @@ #include #include "AutomationEditor.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "Engine.h" #include "GuiApplication.h" #include "Song.h" @@ -144,8 +144,8 @@ void Clip::copyStateTo( Clip *src, Clip *dst ) dst->restoreState( parent.firstChild().toElement() ); dst->movePosition( pos ); - AutomationPattern::resolveAllIDs(); - GuiApplication::instance()->automationEditor()->m_editor->updateAfterPatternChange(); + AutomationClip::resolveAllIDs(); + GuiApplication::instance()->automationEditor()->m_editor->updateAfterClipChange(); } } diff --git a/src/core/InlineAutomation.cpp b/src/core/InlineAutomation.cpp index 4ee596dbcca..8f122baff99 100644 --- a/src/core/InlineAutomation.cpp +++ b/src/core/InlineAutomation.cpp @@ -33,7 +33,7 @@ void InlineAutomation::saveSettings( QDomDocument & _doc, if( hasAutomation() ) { QDomElement ap = _doc.createElement( - AutomationPattern::classNodeName() ); + AutomationClip::classNodeName() ); QDomElement v = _doc.createElement( nodeName() ); automationPattern()->saveSettings( _doc, v ); ap.appendChild( v ); @@ -46,7 +46,7 @@ void InlineAutomation::saveSettings( QDomDocument & _doc, void InlineAutomation::loadSettings( const QDomElement & _this ) { - QDomNode node = _this.namedItem( AutomationPattern::classNodeName() ); + QDomNode node = _this.namedItem( AutomationClip::classNodeName() ); if( node.isElement() ) { node = node.namedItem( nodeName() ); diff --git a/src/core/MeterModel.cpp b/src/core/MeterModel.cpp index 30db26d9b71..7bf61958dcb 100644 --- a/src/core/MeterModel.cpp +++ b/src/core/MeterModel.cpp @@ -24,7 +24,7 @@ #include "MeterModel.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" MeterModel::MeterModel( ::Model * _parent ) : @@ -53,8 +53,8 @@ void MeterModel::reset() m_numeratorModel.setValue( 4 ); m_denominatorModel.setValue( 4 ); - AutomationPattern::globalAutomationPattern( &m_numeratorModel )->clear(); - AutomationPattern::globalAutomationPattern( &m_denominatorModel )->clear(); + AutomationClip::globalAutomationClip( &m_numeratorModel )->clear(); + AutomationClip::globalAutomationClip( &m_denominatorModel )->clear(); } diff --git a/src/core/Note.cpp b/src/core/Note.cpp index 080a555b5d0..e6876087a81 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -213,7 +213,7 @@ void Note::createDetuning() m_detuning = new DetuningHelper; (void) m_detuning->automationPattern(); m_detuning->setRange( -MaxDetuning, MaxDetuning, 0.5f ); - m_detuning->automationPattern()->setProgressionType( AutomationPattern::LinearProgression ); + m_detuning->automationPattern()->setProgressionType( AutomationClip::LinearProgression ); } } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 0b8f17cd43c..293b52c0696 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -394,7 +394,7 @@ void Song::processAutomations(const TrackList &tracklist, TimePos timeStart, fpp // Process recording for (Clip* clip : clips) { - auto p = dynamic_cast(clip); + auto p = dynamic_cast(clip); TimePos relTime = timeStart - p->startPosition(); if (p->isRecording() && relTime >= 0 && relTime < p->length()) { @@ -833,9 +833,9 @@ bpm_t Song::getTempo() -AutomationPattern * Song::tempoAutomationPattern() +AutomationClip * Song::tempoAutomationClip() { - return AutomationPattern::globalAutomationPattern( &m_tempoModel ); + return AutomationClip::globalAutomationClip( &m_tempoModel ); } @@ -884,7 +884,7 @@ void Song::clearProject() if( gui && gui->automationEditor() ) { - gui->automationEditor()->setCurrentPattern( NULL ); + gui->automationEditor()->setCurrentClip( NULL ); } if( gui && gui->pianoRoll() ) @@ -900,10 +900,10 @@ void Song::clearProject() // Clear the m_oldAutomatedValues AutomatedValueMap m_oldAutomatedValues.clear(); - AutomationPattern::globalAutomationPattern( &m_tempoModel )->clear(); - AutomationPattern::globalAutomationPattern( &m_masterVolumeModel )-> + AutomationClip::globalAutomationClip( &m_tempoModel )->clear(); + AutomationClip::globalAutomationClip( &m_masterVolumeModel )-> clear(); - AutomationPattern::globalAutomationPattern( &m_masterPitchModel )-> + AutomationClip::globalAutomationClip( &m_masterPitchModel )-> clear(); Engine::mixer()->doneChangeInModel(); @@ -1173,7 +1173,7 @@ void Song::loadProject( const QString & fileName ) m_controllers.end()); // resolve all IDs so that autoModels are automated - AutomationPattern::resolveAllIDs(); + AutomationClip::resolveAllIDs(); Engine::mixer()->doneChangeInModel(); diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 7b621f727bb..fc0ae97acda 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -31,7 +31,7 @@ #include -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "AutomationTrack.h" #include "BBTrack.h" #include "BBTrackContainer.h" @@ -173,7 +173,7 @@ Track* Track::clone() saveState(doc, parent); Track* t = create(parent.firstChild().toElement(), m_trackContainer); - AutomationPattern::resolveAllIDs(); + AutomationClip::resolveAllIDs(); return t; } diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index 906f1cf8457..d7d9cc9fe60 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -29,7 +29,7 @@ #include #include -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "AutomationTrack.h" #include "BBTrack.h" #include "BBTrackContainer.h" @@ -290,7 +290,7 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra continue; } - if (auto* p = dynamic_cast(clip)) + if (auto* p = dynamic_cast(clip)) { if (! p->hasAutomation()) { continue; diff --git a/src/gui/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 8cf3a4ab04d..32ac6103918 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -27,7 +27,7 @@ #include #include "AutomatableModelView.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "ControllerConnectionDialog.h" #include "ControllerConnection.h" #include "embed.h" @@ -261,7 +261,7 @@ void AutomatableModelViewSlots::removeConnection() void AutomatableModelViewSlots::editSongGlobalAutomation() { gui->automationEditor()->open( - AutomationPattern::globalAutomationPattern(m_amv->modelUntyped()) + AutomationClip::globalAutomationClip(m_amv->modelUntyped()) ); } @@ -269,7 +269,7 @@ void AutomatableModelViewSlots::editSongGlobalAutomation() void AutomatableModelViewSlots::removeSongGlobalAutomation() { - delete AutomationPattern::globalAutomationPattern( m_amv->modelUntyped() ); + delete AutomationClip::globalAutomationClip( m_amv->modelUntyped() ); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp deleted file mode 100644 index c113062406e..00000000000 --- a/src/gui/AutomationPatternView.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* - * AutomationPatternView.cpp - implementation of view for AutomationPattern - * - * Copyright (c) 2008-2010 Tobias Doerffel - * - * This file is part of LMMS - https://lmms.io - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program (see COPYING); if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ -#include "AutomationPatternView.h" - -#include -#include -#include -#include - -#include "AutomationEditor.h" -#include "embed.h" -#include "GuiApplication.h" -#include "gui_templates.h" -#include "ProjectJournal.h" -#include "RenameDialog.h" -#include "StringPairDrag.h" -#include "TextFloat.h" -#include "ToolTip.h" - -#include "Engine.h" - - -QPixmap * AutomationPatternView::s_pat_rec = NULL; - -AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern, - TrackView * _parent ) : - ClipView( _pattern, _parent ), - m_pat( _pattern ), - m_paintPixmap() -{ - connect( m_pat, SIGNAL( dataChanged() ), - this, SLOT( update() ) ); - connect( gui->automationEditor(), SIGNAL( currentPatternChanged() ), - this, SLOT( update() ) ); - - setAttribute( Qt::WA_OpaquePaintEvent, true ); - - ToolTip::add(this, m_pat->name()); - setStyle( QApplication::style() ); - - if( s_pat_rec == NULL ) { s_pat_rec = new QPixmap( embed::getIconPixmap( - "pat_rec" ) ); } - - update(); -} - - - - -AutomationPatternView::~AutomationPatternView() -{ -} - - - - -void AutomationPatternView::openInAutomationEditor() -{ - if(gui) gui->automationEditor()->open(m_pat); -} - - -void AutomationPatternView::update() -{ - ToolTip::add(this, m_pat->name()); - - ClipView::update(); -} - - - -void AutomationPatternView::resetName() -{ - m_pat->setName( QString() ); -} - - - - -void AutomationPatternView::changeName() -{ - QString s = m_pat->name(); - RenameDialog rename_dlg( s ); - rename_dlg.exec(); - m_pat->setName( s ); - update(); -} - - - - -void AutomationPatternView::disconnectObject( QAction * _a ) -{ - JournallingObject * j = Engine::projectJournal()-> - journallingObject( _a->data().toInt() ); - if( j && dynamic_cast( j ) ) - { - float oldMin = m_pat->getMin(); - float oldMax = m_pat->getMax(); - - m_pat->m_objects.erase( std::find( m_pat->m_objects.begin(), - m_pat->m_objects.end(), - dynamic_cast( j ) ) ); - update(); - - //If automation editor is opened, update its display after disconnection - if( gui->automationEditor() ) - { - gui->automationEditor()->m_editor->updateAfterPatternChange(); - } - - //if there is no more connection connected to the AutomationPattern - if( m_pat->m_objects.size() == 0 ) - { - //scale the points to fit the new min. and max. value - this->scaleTimemapToFit( oldMin, oldMax ); - } - } -} - - -void AutomationPatternView::toggleRecording() -{ - m_pat->setRecording( ! m_pat->isRecording() ); - update(); -} - - - - -void AutomationPatternView::flipY() -{ - m_pat->flipY( m_pat->getMin(), m_pat->getMax() ); - update(); -} - - - - -void AutomationPatternView::flipX() -{ - m_pat->flipX( m_pat->length() ); - update(); -} - - - - -void AutomationPatternView::constructContextMenu( QMenu * _cm ) -{ - QAction * a = new QAction( embed::getIconPixmap( "automation" ), - tr( "Open in Automation editor" ), _cm ); - _cm->insertAction( _cm->actions()[0], a ); - connect(a, SIGNAL(triggered()), this, SLOT(openInAutomationEditor())); - _cm->insertSeparator( _cm->actions()[1] ); - - _cm->addSeparator(); - - _cm->addAction( embed::getIconPixmap( "edit_erase" ), - tr( "Clear" ), m_pat, SLOT( clear() ) ); - _cm->addSeparator(); - - _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), - this, SLOT( resetName() ) ); - _cm->addAction( embed::getIconPixmap( "edit_rename" ), - tr( "Change name" ), - this, SLOT( changeName() ) ); - _cm->addAction( embed::getIconPixmap( "record" ), - tr( "Set/clear record" ), - this, SLOT( toggleRecording() ) ); - _cm->addAction( embed::getIconPixmap( "flip_y" ), - tr( "Flip Vertically (Visible)" ), - this, SLOT( flipY() ) ); - _cm->addAction( embed::getIconPixmap( "flip_x" ), - tr( "Flip Horizontally (Visible)" ), - this, SLOT( flipX() ) ); - if( !m_pat->m_objects.isEmpty() ) - { - _cm->addSeparator(); - QMenu * m = new QMenu( tr( "%1 Connections" ). - arg( m_pat->m_objects.count() ), _cm ); - for( AutomationPattern::objectVector::iterator it = - m_pat->m_objects.begin(); - it != m_pat->m_objects.end(); ++it ) - { - if( *it ) - { - a = new QAction( tr( "Disconnect \"%1\"" ). - arg( ( *it )->fullDisplayName() ), m ); - a->setData( ( *it )->id() ); - m->addAction( a ); - } - } - connect( m, SIGNAL( triggered( QAction * ) ), - this, SLOT( disconnectObject( QAction * ) ) ); - _cm->addMenu( m ); - } -} - - - - -void AutomationPatternView::mouseDoubleClickEvent( QMouseEvent * me ) -{ - if(me->button() != Qt::LeftButton) - { - me->ignore(); - return; - } - openInAutomationEditor(); -} - - - - -void AutomationPatternView::paintEvent( QPaintEvent * ) -{ - QPainter painter( this ); - - if( !needsUpdate() ) - { - painter.drawPixmap( 0, 0, m_paintPixmap ); - return; - } - - setNeedsUpdate( false ); - - if (m_paintPixmap.isNull() || m_paintPixmap.size() != size()) - { - m_paintPixmap = QPixmap(size()); - } - - QPainter p( &m_paintPixmap ); - - QLinearGradient lingrad( 0, 0, 0, height() ); - QColor c = getColorForDisplay( painter.background().color() ); - bool muted = m_pat->getTrack()->isMuted() || m_pat->isMuted(); - bool current = gui->automationEditor()->currentPattern() == m_pat; - - lingrad.setColorAt( 1, c.darker( 300 ) ); - lingrad.setColorAt( 0, c ); - - // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds - p.fillRect( rect(), QColor( 0, 0, 0 ) ); - - if( gradient() ) - { - p.fillRect( rect(), lingrad ); - } - else - { - p.fillRect( rect(), c ); - } - - const float ppb = fixedClips() ? - ( parentWidget()->width() - 2 * CLIP_BORDER_WIDTH ) - / (float) m_pat->timeMapLength().getBar() : - pixelsPerBar(); - - const int x_base = CLIP_BORDER_WIDTH; - - const float min = m_pat->firstObject()->minValue(); - const float max = m_pat->firstObject()->maxValue(); - - const float y_scale = max - min; - const float h = ( height() - 2 * CLIP_BORDER_WIDTH ) / y_scale; - const float ppTick = ppb / TimePos::ticksPerBar(); - - p.translate( 0.0f, max * height() / y_scale - CLIP_BORDER_WIDTH ); - p.scale( 1.0f, -h ); - - QLinearGradient lin2grad( 0, min, 0, max ); - QColor col; - - col = !muted ? painter.pen().brush().color() : mutedColor(); - - lin2grad.setColorAt( 1, col.lighter( 150 ) ); - lin2grad.setColorAt( 0.5, col ); - lin2grad.setColorAt( 0, col.darker( 150 ) ); - - p.setRenderHints( QPainter::Antialiasing, true ); - for( AutomationPattern::timeMap::const_iterator it = - m_pat->getTimeMap().begin(); - it != m_pat->getTimeMap().end(); ++it ) - { - if( it+1 == m_pat->getTimeMap().end() ) - { - const float x1 = x_base + POS(it) * ppTick; - const float x2 = (float)( width() - CLIP_BORDER_WIDTH ); - if( x1 > ( width() - CLIP_BORDER_WIDTH ) ) break; - // We are drawing the space after the last node, so we use the outValue - if( gradient() ) - { - p.fillRect(QRectF(x1, 0.0f, x2 - x1, OUTVAL(it)), lin2grad); - } - else - { - p.fillRect(QRectF(x1, 0.0f, x2 - x1, OUTVAL(it)), col); - } - break; - } - - float *values = m_pat->valuesAfter(POS(it)); - - // We are creating a path to draw a polygon representing the values between two - // nodes. When we have two nodes with discrete progression, we will basically have - // a rectangle with the outValue of the first node (that's why nextValue will match - // the outValue of the current node). When we have nodes with linear or cubic progression - // the value of the end of the shape between the two nodes will be the inValue of - // the next node. - float nextValue; - if( m_pat->progressionType() == AutomationPattern::DiscreteProgression ) - { - nextValue = OUTVAL(it); - } - else - { - nextValue = INVAL(it + 1); - } - - QPainterPath path; - QPointF origin = QPointF(x_base + POS(it) * ppTick, 0.0f); - path.moveTo( origin ); - path.moveTo(QPointF(x_base + POS(it) * ppTick,values[0])); - float x; - for (int i = POS(it) + 1; i < POS(it + 1); i++) - { - x = x_base + i * ppTick; - if( x > ( width() - CLIP_BORDER_WIDTH ) ) break; - float value = values[i - POS(it)]; - path.lineTo( QPointF( x, value ) ); - - } - path.lineTo(x_base + (POS(it + 1)) * ppTick, nextValue); - path.lineTo(x_base + (POS(it + 1)) * ppTick, 0.0f); - path.lineTo( origin ); - - if( gradient() ) - { - p.fillPath( path, lin2grad ); - } - else - { - p.fillPath( path, col ); - } - delete [] values; - } - - p.setRenderHints( QPainter::Antialiasing, false ); - p.resetTransform(); - - // bar lines - const int lineSize = 3; - p.setPen( c.darker( 300 ) ); - - for( bar_t t = 1; t < width() - CLIP_BORDER_WIDTH; ++t ) - { - const int tx = x_base + static_cast( ppb * t ) - 2; - p.drawLine( tx, CLIP_BORDER_WIDTH, tx, CLIP_BORDER_WIDTH + lineSize ); - p.drawLine( tx, rect().bottom() - ( lineSize + CLIP_BORDER_WIDTH ), - tx, rect().bottom() - CLIP_BORDER_WIDTH ); - } - - // recording icon for when recording automation - if( m_pat->isRecording() ) - { - p.drawPixmap( 1, rect().bottom() - s_pat_rec->height(), - *s_pat_rec ); - } - - // pattern name - paintTextLabel(m_pat->name(), p); - - // inner border - p.setPen( c.lighter( current ? 160 : 130 ) ); - p.drawRect( 1, 1, rect().right() - CLIP_BORDER_WIDTH, - rect().bottom() - CLIP_BORDER_WIDTH ); - - // outer border - p.setPen( current? c.lighter( 130 ) : c.darker( 300 ) ); - p.drawRect( 0, 0, rect().right(), rect().bottom() ); - - // draw the 'muted' pixmap only if the pattern was manualy muted - if( m_pat->isMuted() ) - { - const int spacing = CLIP_BORDER_WIDTH; - const int size = 14; - p.drawPixmap( spacing, height() - ( size + spacing ), - embed::getIconPixmap( "muted", size, size ) ); - } - - p.end(); - - painter.drawPixmap( 0, 0, m_paintPixmap ); -} - - - - -void AutomationPatternView::dragEnterEvent( QDragEnterEvent * _dee ) -{ - StringPairDrag::processDragEnterEvent( _dee, "automatable_model" ); - if( !_dee->isAccepted() ) - { - ClipView::dragEnterEvent( _dee ); - } -} - - - - -void AutomationPatternView::dropEvent( QDropEvent * _de ) -{ - QString type = StringPairDrag::decodeKey( _de ); - QString val = StringPairDrag::decodeValue( _de ); - if( type == "automatable_model" ) - { - AutomatableModel * mod = dynamic_cast( - Engine::projectJournal()-> - journallingObject( val.toInt() ) ); - if( mod != NULL ) - { - bool added = m_pat->addObject( mod ); - if ( !added ) - { - TextFloat::displayMessage( mod->displayName(), - tr( "Model is already connected " - "to this pattern." ), - embed::getIconPixmap( "automation" ), - 2000 ); - } - } - update(); - - if( gui->automationEditor() && - gui->automationEditor()->currentPattern() == m_pat ) - { - gui->automationEditor()->setCurrentPattern( m_pat ); - } - } - else - { - ClipView::dropEvent( _de ); - } -} - - - - -/** - * @brief Preserves the auto points over different scale - */ -void AutomationPatternView::scaleTimemapToFit( float oldMin, float oldMax ) -{ - float newMin = m_pat->getMin(); - float newMax = m_pat->getMax(); - - if( oldMin == newMin && oldMax == newMax ) - { - return; - } - - // TODO: Currently when rescaling the timeMap values to fit the new range of values (newMin and newMax) - // only the inValue is being considered and the outValue is being reset to the inValue (so discrete jumps - // are discarded). Possibly later we will want discrete jumps to be maintained so we will need to upgrade - // the logic to account for them. - for( AutomationPattern::timeMap::iterator it = m_pat->m_timeMap.begin(); - it != m_pat->m_timeMap.end(); ++it ) - { - // If the values are out of the previous range, fix them so they are - // between oldMin and oldMax. - if (INVAL(it) < oldMin) - { - it.value().setInValue(oldMin); - } - else if (INVAL(it) > oldMax) - { - it.value().setInValue(oldMax); - } - // Calculate what the value would be proportionally in the new range - it.value().setInValue((INVAL(it) - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin); - // Read earlier TODO comment: For now I'm discarding the discrete jumps during the rescaling - it.value().setOutValue(INVAL(it)); - } - - m_pat->generateTangents(); -} diff --git a/src/gui/AutomationTrackView.cpp b/src/gui/AutomationTrackView.cpp index c1c4d0042c5..2c91f112530 100644 --- a/src/gui/AutomationTrackView.cpp +++ b/src/gui/AutomationTrackView.cpp @@ -25,7 +25,7 @@ #include "AutomationTrackView.h" - #include "AutomationPattern.h" + #include "AutomationClip.h" #include "embed.h" #include "Engine.h" #include "ProjectJournal.h" @@ -79,7 +79,7 @@ void AutomationTrackView::dropEvent( QDropEvent * _de ) } Clip * clip = getTrack()->createClip( pos ); - AutomationPattern * pat = dynamic_cast( clip ); + AutomationClip * pat = dynamic_cast( clip ); pat->addObject( mod ); } } diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 86df67d8f7e..72d0e6cf2f3 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -5,7 +5,7 @@ SET(LMMS_SRCS gui/AudioAlsaSetupWidget.cpp gui/AudioDeviceSetupWidget.cpp gui/AutomatableModelView.cpp - gui/AutomationPatternView.cpp + gui/AutomationClipView.cpp gui/AutomationTrackView.cpp gui/ControllerConnectionDialog.cpp gui/ControllerDialog.cpp diff --git a/src/gui/ClipView.cpp b/src/gui/ClipView.cpp index 6ff16050817..065302ca94d 100644 --- a/src/gui/ClipView.cpp +++ b/src/gui/ClipView.cpp @@ -30,7 +30,7 @@ #include #include -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "Clipboard.h" #include "ColorChooser.h" #include "ComboBoxModel.h" @@ -432,7 +432,7 @@ void ClipView::dropEvent( QDropEvent * de ) QDomElement clips = dataFile.content().firstChildElement( "clips" ); m_clip->restoreState( clips.firstChildElement().firstChildElement() ); m_clip->movePosition( pos ); - AutomationPattern::resolveAllIDs(); + AutomationClip::resolveAllIDs(); de->accept(); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 659a66652f9..02ae9c2ad07 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1267,7 +1267,7 @@ void MainWindow::updatePlayPauseIcons() gui->songEditor()->setPauseIcon( true ); break; - case Song::Mode_PlayAutomationPattern: + case Song::Mode_PlayAutomationClip: gui->automationEditor()->setPauseIcon( true ); break; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index ea880529c34..67c490a8627 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -81,7 +81,7 @@ AutomationEditor::AutomationEditor() : m_zoomingXModel(), m_zoomingYModel(), m_quantizeModel(), - m_pattern(nullptr), + m_clip(nullptr), m_minLevel( 0 ), m_maxLevel( 0 ), m_step( 1 ), @@ -109,8 +109,8 @@ AutomationEditor::AutomationEditor() : m_crossColor(0, 0, 0), m_backgroundShade(0, 0, 0) { - connect( this, SIGNAL( currentPatternChanged() ), - this, SLOT( updateAfterPatternChange() ), + connect( this, SIGNAL( currentClipChanged() ), + this, SLOT( updateAfterClipChange() ), Qt::QueuedConnection ); connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), this, SLOT( update() ) ); @@ -146,9 +146,9 @@ AutomationEditor::AutomationEditor() : // add time-line m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb, Engine::getSong()->getPlayPos( - Song::Mode_PlayAutomationPattern ), + Song::Mode_PlayAutomationClip ), m_currentPosition, - Song::Mode_PlayAutomationPattern, this ); + Song::Mode_PlayAutomationClip, this ); connect( this, SIGNAL( positionChanged( const TimePos & ) ), m_timeLine, SLOT( updatePosition( const TimePos & ) ) ); connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), @@ -184,7 +184,7 @@ AutomationEditor::AutomationEditor() : s_toolMove = new QPixmap(embed::getIconPixmap("edit_move")); } - setCurrentPattern(nullptr); + setCurrentClip(nullptr); setMouseTracking( true ); setFocusPolicy( Qt::StrongFocus ); @@ -207,21 +207,21 @@ AutomationEditor::~AutomationEditor() -void AutomationEditor::setCurrentPattern(AutomationPattern * new_pattern ) +void AutomationEditor::setCurrentClip(AutomationClip * new_clip ) { - if (m_pattern) + if (m_clip) { - m_pattern->disconnect(this); + m_clip->disconnect(this); } - m_pattern = new_pattern; + m_clip = new_clip; - if (m_pattern != nullptr) + if (m_clip != nullptr) { - connect(m_pattern, SIGNAL(dataChanged()), this, SLOT(update())); + connect(m_clip, SIGNAL(dataChanged()), this, SLOT(update())); } - emit currentPatternChanged(); + emit currentClipChanged(); } @@ -243,11 +243,11 @@ void AutomationEditor::loadSettings( const QDomElement & dom_parent) -void AutomationEditor::updateAfterPatternChange() +void AutomationEditor::updateAfterClipChange() { m_currentPosition = 0; - if( !validPattern() ) + if( !validClip() ) { m_minLevel = m_maxLevel = m_scrollLevel = 0; m_step = 1; @@ -255,12 +255,12 @@ void AutomationEditor::updateAfterPatternChange() return; } - m_minLevel = m_pattern->firstObject()->minValue(); - m_maxLevel = m_pattern->firstObject()->maxValue(); - m_step = m_pattern->firstObject()->step(); + m_minLevel = m_clip->firstObject()->minValue(); + m_maxLevel = m_clip->firstObject()->maxValue(); + m_step = m_clip->firstObject()->step(); centerTopBottomScroll(); - m_tensionModel->setValue( m_pattern->getTension() ); + m_tensionModel->setValue( m_clip->getTension() ); // resizeEvent() does the rest for us (scrolling, range-checking // of levels and so on...) @@ -277,7 +277,7 @@ void AutomationEditor::update() QWidget::update(); // Note detuning? - if( m_pattern && !m_pattern->getTrack() ) + if( m_clip && !m_clip->getTrack() ) { gui->pianoRoll()->update(); } @@ -344,8 +344,8 @@ void AutomationEditor::leaveEvent(QEvent * e ) void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) { - int x0 = Note::quantized( x0In, AutomationPattern::quantization() ); - int x1 = Note::quantized( x1In, AutomationPattern::quantization() ); + int x0 = Note::quantized( x0In, AutomationClip::quantization() ); + int x1 = Note::quantized( x1In, AutomationClip::quantization() ); int deltax = qAbs( x1 - x0 ); float deltay = qAbs( y1 - y0 ); int x = x0; @@ -353,22 +353,22 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) int xstep; int ystep; - if( deltax < AutomationPattern::quantization() ) + if( deltax < AutomationClip::quantization() ) { return; } - deltax /= AutomationPattern::quantization(); + deltax /= AutomationClip::quantization(); float yscale = deltay / ( deltax ); if( x0 < x1 ) { - xstep = AutomationPattern::quantization(); + xstep = AutomationClip::quantization(); } else { - xstep = -( AutomationPattern::quantization() ); + xstep = -( AutomationClip::quantization() ); } float lineAdjust; @@ -390,8 +390,8 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) x += xstep; i += 1; - m_pattern->removeNode(TimePos(x)); - m_pattern->putValue( TimePos( x ), y ); + m_clip->removeNode(TimePos(x)); + m_clip->putValue( TimePos( x ), y ); } } @@ -400,7 +400,7 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) bool AutomationEditor::fineTuneValue(timeMap::iterator node, bool editingOutValue) { - if (node == m_pattern->getTimeMap().end()) { return false; } + if (node == m_clip->getTimeMap().end()) { return false; } // Display dialog to edit the value bool ok; @@ -413,8 +413,8 @@ bool AutomationEditor::fineTuneValue(timeMap::iterator node, bool editingOutValu editingOutValue ? OUTVAL(node) : INVAL(node), - m_pattern->firstObject()->minValue(), - m_pattern->firstObject()->maxValue(), + m_clip->firstObject()->minValue(), + m_clip->firstObject()->maxValue(), 3, &ok ); @@ -447,7 +447,7 @@ bool AutomationEditor::fineTuneValue(timeMap::iterator node, bool editingOutValu void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) { - if( !validPattern() ) + if( !validClip() ) { return; } @@ -455,15 +455,15 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // Some helper lambda functions to avoid repetition of code auto eraseNode = [this](timeMap::iterator node) { - if (node != m_pattern->getTimeMap().end()) + if (node != m_clip->getTimeMap().end()) { - m_pattern->removeNode(POS(node)); + m_clip->removeNode(POS(node)); Engine::getSong()->setModified(); } }; auto resetNode = [this](timeMap::iterator node) { - if (node != m_pattern->getTimeMap().end()) + if (node != m_clip->getTimeMap().end()) { node.value().resetOutValue(); Engine::getSong()->setModified(); @@ -481,8 +481,8 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // Get tick in which the user clicked int posTicks = (x * TimePos::ticksPerBar() / m_ppb) + m_currentPosition; - // Get the time map of current pattern - timeMap & tm = m_pattern->getTimeMap(); + // Get the time map of current clip + timeMap & tm = m_clip->getTimeMap(); m_mouseDownLeft = (mouseEvent->button() == Qt::LeftButton); m_mouseDownRight = (mouseEvent->button() == Qt::RightButton); @@ -501,7 +501,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) { case DRAW: { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); if (m_mouseDownLeft) { @@ -522,7 +522,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) else // No shift, we are just creating/moving nodes { // Starts actually moving/draging the node - TimePos newTime = m_pattern->setDragValue( + TimePos newTime = m_clip->setDragValue( // The TimePos of either the clicked node or a new one TimePos( clickedNode == tm.end() @@ -573,7 +573,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) } case ERASE: { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); // On erase mode, left click removes nodes if (m_mouseDownLeft) @@ -602,7 +602,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) } case DRAW_OUTVALUES: { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); // On this mode, left click sets the outValue if (m_mouseDownLeft) @@ -624,7 +624,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // node and set its outValue TimePos quantizedPos = Note::quantized( TimePos(posTicks), - m_pattern->quantization() + m_clip->quantization() ); clickedNode = tm.find(quantizedPos); @@ -664,7 +664,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) { - if (!validPattern()) { return; } + if (!validClip()) { return; } // If we double clicked outside the AutomationEditor viewport return if (mouseEvent->y() <= TOP_MARGIN || mouseEvent->x() < VALUES_WIDTH) { return; } @@ -707,7 +707,7 @@ void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) if (m_action == MOVE_VALUE) { // Actually apply the value of the node being dragged - m_pattern->applyDragValue(); + m_clip->applyDragValue(); } QApplication::restoreOverrideCursor(); @@ -723,7 +723,7 @@ void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) { - if( !validPattern() ) + if( !validClip() ) { update(); return; @@ -760,7 +760,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) m_drawLastLevel = level; // Updates the drag value of the moved node - m_pattern->setDragValue( + m_clip->setDragValue( TimePos(posTicks), level, true, @@ -786,7 +786,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // Removing automation nodes // Removes all values from the last clicked tick up to the current position tick - m_pattern->removeNodes(m_drawLastTick, posTicks); + m_clip->removeNodes(m_drawLastTick, posTicks); Engine::getSong()->setModified(); } @@ -806,7 +806,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // Removing automation nodes // Removes all values from the last clicked tick up to the current position tick - m_pattern->removeNodes(m_drawLastTick, posTicks); + m_clip->removeNodes(m_drawLastTick, posTicks); Engine::getSong()->setModified(); } @@ -818,7 +818,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // Reseting outValues // Resets all values from the last clicked tick up to the current position tick - m_pattern->resetNodes(m_drawLastTick, posTicks); + m_clip->resetNodes(m_drawLastTick, posTicks); Engine::getSong()->setModified(); } @@ -836,7 +836,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) if (m_action == MOVE_OUTVALUE) { // We are moving the outValue of the node - timeMap & tm = m_pattern->getTimeMap(); + timeMap & tm = m_clip->getTimeMap(); timeMap::iterator it = tm.find(m_draggedOutValueKey); // Safety check @@ -854,7 +854,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // Reseting outValues // Resets all values from the last clicked tick up to the current position tick - m_pattern->resetNodes(m_drawLastTick, posTicks); + m_clip->resetNodes(m_drawLastTick, posTicks); Engine::getSong()->setModified(); } @@ -894,7 +894,7 @@ inline void AutomationEditor::drawCross( QPainter & p ) tt_pos.ry() -= 51; tt_pos.rx() += 26; - float scaledLevel = m_pattern->firstObject()->scaledValue( level ); + float scaledLevel = m_clip->firstObject()->scaledValue( level ); // Limit the scaled-level tooltip to the grid if( mouse_pos.x() >= 0 && @@ -913,12 +913,12 @@ inline void AutomationEditor::drawAutomationPoint(QPainter & p, timeMap::iterato { int x = xCoordOfTick(POS(it)); int y; - // Below (m_ppb * AutomationPattern::quantization() / 576) is used because: + // Below (m_ppb * AutomationClip::quantization() / 576) is used because: // 1 bar equals to 192/quantization() notes. Hence, to calculate the number of pixels // per note we would have (m_ppb * 1 bar / (192/quantization()) notes per bar), or // (m_ppb * quantization / 192). If we want 1/3 of the number of pixels per note we // get (m_ppb * quantization() / 192*3) or (m_ppb * quantization() / 576) - const int outerRadius = qBound(3, (m_ppb * AutomationPattern::quantization()) / 576, 5); + const int outerRadius = qBound(3, (m_ppb * AutomationClip::quantization()) / 576, 5); // Draw a circle for the outValue y = yCoordOfLevel(OUTVAL(it)); @@ -964,7 +964,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) Qt::Alignment text_flags = (Qt::Alignment)( Qt::AlignRight | Qt::AlignVCenter ); - if( validPattern() ) + if( validClip() ) { if( m_y_auto ) { @@ -972,7 +972,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) float level[] = { m_minLevel, m_maxLevel }; for( int i = 0; i < 2; ++i ) { - const QString & label = m_pattern->firstObject() + const QString & label = m_clip->firstObject() ->displayValue( level[i] ); p.setPen( QApplication::palette().color( QPalette::Active, QPalette::Shadow ) ); @@ -1000,7 +1000,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) } for( ; level <= m_topLevel; level += printable ) { - const QString & label = m_pattern->firstObject() + const QString & label = m_clip->firstObject() ->displayValue( level ); y = yCoordOfLevel( level ); p.setPen( QApplication::palette().color( QPalette::Active, @@ -1023,7 +1023,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // draw vertical raster - if( m_pattern ) + if( m_clip ) { int tick, x, q; int x_line_end = (int)( m_y_auto || m_topLevel < m_maxLevel ? @@ -1033,17 +1033,17 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) if( m_zoomingXModel.value() > 3 ) { // If we're over 100% zoom, we allow all quantization level grids - q = AutomationPattern::quantization(); + q = AutomationClip::quantization(); } - else if( AutomationPattern::quantization() % 3 != 0 ) + else if( AutomationClip::quantization() % 3 != 0 ) { // If we're under 100% zoom, we allow quantization grid up to 1/24 for triplets // to ensure a dense doesn't fill out the background - q = AutomationPattern::quantization() < 8 ? 8 : AutomationPattern::quantization(); + q = AutomationClip::quantization() < 8 ? 8 : AutomationClip::quantization(); } else { // If we're under 100% zoom, we allow quantization grid up to 1/32 for normal notes - q = AutomationPattern::quantization() < 6 ? 6 : AutomationPattern::quantization(); + q = AutomationClip::quantization() < 6 ? 6 : AutomationClip::quantization(); } // 3 independent loops, because quantization might not divide evenly into @@ -1136,11 +1136,11 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // following code draws all visible values - if( validPattern() ) + if( validClip() ) { //NEEDS Change in CSS //int len_ticks = 4; - timeMap & time_map = m_pattern->getTimeMap(); + timeMap & time_map = m_clip->getTimeMap(); //Don't bother doing/rendering anything if there is no automation points if( time_map.size() > 0 ) @@ -1163,7 +1163,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) break; } - float *values = m_pattern->valuesAfter(POS(it)); + float *values = m_clip->valuesAfter(POS(it)); // We are creating a path to draw a polygon representing the values between two // nodes. When we have two nodes with discrete progression, we will basically have @@ -1172,7 +1172,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // the value of the end of the shape between the two nodes will be the inValue of // the next node. float nextValue; - if( m_pattern->progressionType() == AutomationPattern::DiscreteProgression ) + if( m_clip->progressionType() == AutomationClip::DiscreteProgression ) { nextValue = OUTVAL(it); } @@ -1225,12 +1225,12 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) p.drawText( VALUES_WIDTH + 20, TOP_MARGIN + 40, width() - VALUES_WIDTH - 20 - SCROLLBAR_SIZE, grid_height - 40, Qt::TextWordWrap, - tr( "Please open an automation pattern with " + tr( "Please open an automation clip with " "the context menu of a control!" ) ); } // TODO: Get this out of paint event - int l = validPattern() ? (int) m_pattern->length() : 0; + int l = validClip() ? (int) m_clip->length() : 0; // reset scroll-range if( m_leftRightScroll->maximum() != l ) @@ -1239,7 +1239,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) m_leftRightScroll->setPageStep( l ); } - if(validPattern() && GuiApplication::instance()->automationEditor()->m_editor->hasFocus()) + if(validClip() && GuiApplication::instance()->automationEditor()->m_editor->hasFocus()) { drawCross( p ); } @@ -1351,17 +1351,17 @@ void AutomationEditor::centerTopBottomScroll() { // default to the m_scrollLevel position int pos = static_cast(m_scrollLevel); - // If a pattern exists... - if (m_pattern) + // If a clip exists... + if (m_clip) { - // get time map of current pattern - timeMap & time_map = m_pattern->getTimeMap(); + // get time map of current clip + timeMap & time_map = m_clip->getTimeMap(); // If time_map is not empty... if (!time_map.empty()) { // set the position to the inverted value ((max + min) - value) - // If we set just (max - value), we're off by m_pattern's minimum - pos = m_pattern->getMax() + m_pattern->getMin() - static_cast(INVAL(time_map.begin())); + // If we set just (max - value), we're off by m_clip's minimum + pos = m_clip->getMax() + m_clip->getMin() - static_cast(INVAL(time_map.begin())); } } m_topBottomScroll->setValue(pos); @@ -1400,7 +1400,7 @@ void AutomationEditor::resizeEvent(QResizeEvent * re) if( Engine::getSong() ) { - Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationPattern + Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationClip ).m_timeLine->setFixedWidth( width() ); } @@ -1510,8 +1510,8 @@ float AutomationEditor::getLevel(int y ) inline bool AutomationEditor::inBBEditor() { - return( validPattern() && - m_pattern->getTrack()->trackContainer() == Engine::getBBTrackContainer() ); + return( validClip() && + m_clip->getTrack()->trackContainer() == Engine::getBBTrackContainer() ); } @@ -1519,12 +1519,12 @@ inline bool AutomationEditor::inBBEditor() void AutomationEditor::play() { - if( !validPattern() ) + if( !validClip() ) { return; } - if( !m_pattern->getTrack() ) + if( !m_clip->getTrack() ) { if( Engine::getSong()->playMode() != Song::Mode_PlayPattern ) { @@ -1562,11 +1562,11 @@ void AutomationEditor::play() void AutomationEditor::stop() { - if( !validPattern() ) + if( !validClip() ) { return; } - if( m_pattern->getTrack() && inBBEditor() ) + if( m_clip->getTrack() && inBBEditor() ) { Engine::getBBTrackContainer()->stop(); } @@ -1621,12 +1621,12 @@ void AutomationEditor::setEditMode(int mode) -void AutomationEditor::setProgressionType(AutomationPattern::ProgressionTypes type) +void AutomationEditor::setProgressionType(AutomationClip::ProgressionTypes type) { - if (validPattern()) + if (validClip()) { - m_pattern->addJournalCheckPoint(); - m_pattern->setProgressionType(type); + m_clip->addJournalCheckPoint(); + m_clip->setProgressionType(type); Engine::getSong()->setModified(); update(); } @@ -1634,7 +1634,7 @@ void AutomationEditor::setProgressionType(AutomationPattern::ProgressionTypes ty void AutomationEditor::setProgressionType(int type) { - setProgressionType((AutomationPattern::ProgressionTypes) type); + setProgressionType((AutomationClip::ProgressionTypes) type); } @@ -1642,9 +1642,9 @@ void AutomationEditor::setProgressionType(int type) void AutomationEditor::setTension() { - if ( m_pattern ) + if ( m_clip ) { - m_pattern->setTension( QString::number( m_tensionModel->value() ) ); + m_clip->setTension( QString::number( m_tensionModel->value() ) ); update(); } } @@ -1656,7 +1656,7 @@ void AutomationEditor::updatePosition(const TimePos & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == - Song::Mode_PlayAutomationPattern ) || + Song::Mode_PlayAutomationClip ) || m_scrollBack == true ) { const int w = width() - VALUES_WIDTH; @@ -1712,7 +1712,7 @@ void AutomationEditor::zoomingYChanged() void AutomationEditor::setQuantization() { - AutomationPattern::setQuantization(DefaultTicksPerBar / Quantizations[m_quantizeModel.value()]); + AutomationClip::setQuantization(DefaultTicksPerBar / Quantizations[m_quantizeModel.value()]); update(); } @@ -1786,8 +1786,8 @@ AutomationEditor::timeMap::iterator AutomationEditor::getNodeAt(int x, int y, bo // Convert the x position to the position in ticks int posTicks = (x * TimePos::ticksPerBar() / m_ppb) + m_currentPosition; - // Get our pattern timeMap and create a iterator so we can check the nodes - timeMap & tm = m_pattern->getTimeMap(); + // Get our clip timeMap and create a iterator so we can check the nodes + timeMap & tm = m_clip->getTimeMap(); timeMap::iterator it = tm.begin(); // ticksOffset is the number of ticks that match "r" pixels @@ -1832,9 +1832,9 @@ AutomationEditorWindow::AutomationEditorWindow() : // Play/stop buttons - m_playAction->setToolTip(tr( "Play/pause current pattern (Space)" )); + m_playAction->setToolTip(tr( "Play/pause current clip (Space)" )); - m_stopAction->setToolTip(tr("Stop playing of current pattern (Space)")); + m_stopAction->setToolTip(tr("Stop playing of current clip (Space)")); // Edit mode buttons DropToolBar *editActionsToolBar = addDropToolBarToTop(tr("Edit actions")); @@ -1972,62 +1972,62 @@ AutomationEditorWindow::~AutomationEditorWindow() } -void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) +void AutomationEditorWindow::setCurrentClip(AutomationClip* clip) { - // Disconnect our old pattern - if (currentPattern() != nullptr) + // Disconnect our old clip + if (currentClip() != nullptr) { - m_editor->m_pattern->disconnect(this); + m_editor->m_clip->disconnect(this); m_flipXAction->disconnect(); m_flipYAction->disconnect(); } - m_editor->setCurrentPattern(pattern); + m_editor->setCurrentClip(clip); // Set our window's title - if (pattern == nullptr) + if (clip == nullptr) { - setWindowTitle( tr( "Automation Editor - no pattern" ) ); + setWindowTitle( tr( "Automation Editor - no clip" ) ); return; } - setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_pattern->name() ) ); + setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_clip->name() ) ); - switch(m_editor->m_pattern->progressionType()) + switch(m_editor->m_clip->progressionType()) { - case AutomationPattern::DiscreteProgression: + case AutomationClip::DiscreteProgression: m_discreteAction->setChecked(true); m_tensionKnob->setEnabled(false); break; - case AutomationPattern::LinearProgression: + case AutomationClip::LinearProgression: m_linearAction->setChecked(true); m_tensionKnob->setEnabled(false); break; - case AutomationPattern::CubicHermiteProgression: + case AutomationClip::CubicHermiteProgression: m_cubicHermiteAction->setChecked(true); m_tensionKnob->setEnabled(true); break; } - // Connect new pattern - if (pattern) + // Connect new clip + if (clip) { - connect(pattern, SIGNAL(dataChanged()), this, SLOT(update())); - connect( pattern, SIGNAL( dataChanged() ), this, SLOT( updateWindowTitle() ) ); - connect(pattern, SIGNAL(destroyed()), this, SLOT(clearCurrentPattern())); + connect(clip, SIGNAL(dataChanged()), this, SLOT(update())); + connect( clip, SIGNAL( dataChanged() ), this, SLOT( updateWindowTitle() ) ); + connect(clip, SIGNAL(destroyed()), this, SLOT(clearCurrentClip())); - connect(m_flipXAction, SIGNAL(triggered()), pattern, SLOT(flipX())); - connect(m_flipYAction, SIGNAL(triggered()), pattern, SLOT(flipY())); + connect(m_flipXAction, SIGNAL(triggered()), clip, SLOT(flipX())); + connect(m_flipYAction, SIGNAL(triggered()), clip, SLOT(flipY())); } - emit currentPatternChanged(); + emit currentClipChanged(); } -const AutomationPattern* AutomationEditorWindow::currentPattern() +const AutomationClip* AutomationEditorWindow::currentClip() { - return m_editor->currentPattern(); + return m_editor->currentClip(); } void AutomationEditorWindow::dropEvent( QDropEvent *_de ) @@ -2041,16 +2041,16 @@ void AutomationEditorWindow::dropEvent( QDropEvent *_de ) journallingObject( val.toInt() ) ); if (mod != nullptr) { - bool added = m_editor->m_pattern->addObject( mod ); + bool added = m_editor->m_clip->addObject( mod ); if ( !added ) { TextFloat::displayMessage( mod->displayName(), tr( "Model is already connected " - "to this pattern." ), + "to this clip." ), embed::getIconPixmap( "automation" ), 2000 ); } - setCurrentPattern( m_editor->m_pattern ); + setCurrentClip( m_editor->m_clip ); } } @@ -2059,15 +2059,15 @@ void AutomationEditorWindow::dropEvent( QDropEvent *_de ) void AutomationEditorWindow::dragEnterEvent( QDragEnterEvent *_dee ) { - if (! m_editor->validPattern() ) { + if (! m_editor->validClip() ) { return; } StringPairDrag::processDragEnterEvent( _dee, "automatable_model" ); } -void AutomationEditorWindow::open(AutomationPattern* pattern) +void AutomationEditorWindow::open(AutomationClip* clip) { - setCurrentPattern(pattern); + setCurrentClip(clip); parentWidget()->show(); show(); setFocus(); @@ -2078,10 +2078,10 @@ QSize AutomationEditorWindow::sizeHint() const return {INITIAL_WIDTH, INITIAL_HEIGHT}; } -void AutomationEditorWindow::clearCurrentPattern() +void AutomationEditorWindow::clearCurrentClip() { - m_editor->m_pattern = nullptr; - setCurrentPattern(nullptr); + m_editor->m_clip = nullptr; + setCurrentClip(nullptr); } void AutomationEditorWindow::focusInEvent(QFocusEvent * event) @@ -2102,11 +2102,11 @@ void AutomationEditorWindow::stop() void AutomationEditorWindow::updateWindowTitle() { - if (m_editor->m_pattern == nullptr) + if (m_editor->m_clip == nullptr) { - setWindowTitle( tr( "Automation Editor - no pattern" ) ); + setWindowTitle( tr( "Automation Editor - no clip" ) ); return; } - setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_pattern->name() ) ); + setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_clip->name() ) ); } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 920504819a6..9196290634f 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -73,7 +73,7 @@ using std::move; -typedef AutomationPattern::timeMap timeMap; +typedef AutomationClip::timeMap timeMap; // some constants... @@ -1120,12 +1120,12 @@ void PianoRoll::drawDetuningInfo( QPainter & _p, const Note * _n, int _x, // node to the other switch (_n->detuning()->automationPattern()->progressionType()) { - case AutomationPattern::DiscreteProgression: + case AutomationClip::DiscreteProgression: _p.drawLine(old_x, pre_y, cur_x, pre_y); _p.drawLine(cur_x, pre_y, cur_x, cur_y); break; - case AutomationPattern::CubicHermiteProgression: /* TODO */ - case AutomationPattern::LinearProgression: + case AutomationClip::CubicHermiteProgression: /* TODO */ + case AutomationClip::LinearProgression: _p.drawLine(old_x, pre_y, cur_x, cur_y); break; } @@ -1618,7 +1618,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) if( m_editMode == ModeEditDetuning && noteUnderMouse() ) { - static QPointer detuningPattern = nullptr; + static QPointer detuningPattern = nullptr; if (detuningPattern.data() != nullptr) { detuningPattern->disconnect(this); diff --git a/src/gui/widgets/TrackContentWidget.cpp b/src/gui/widgets/TrackContentWidget.cpp index 6d26d2d0339..4d9ff738361 100644 --- a/src/gui/widgets/TrackContentWidget.cpp +++ b/src/gui/widgets/TrackContentWidget.cpp @@ -29,7 +29,7 @@ #include #include -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "BBEditor.h" #include "BBTrackContainer.h" #include "Clipboard.h" @@ -519,7 +519,7 @@ bool TrackContentWidget::pasteSelection( TimePos clipPos, const QMimeData * md, } } - AutomationPattern::resolveAllIDs(); + AutomationClip::resolveAllIDs(); return true; } diff --git a/src/gui/widgets/TrackOperationsWidget.cpp b/src/gui/widgets/TrackOperationsWidget.cpp index cd2df2f832b..8845a490d13 100644 --- a/src/gui/widgets/TrackOperationsWidget.cpp +++ b/src/gui/widgets/TrackOperationsWidget.cpp @@ -31,7 +31,7 @@ #include #include -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "AutomationTrackView.h" #include "ColorChooser.h" #include "ConfigManager.h" @@ -371,7 +371,7 @@ void TrackOperationsWidget::toggleRecording( bool on ) { for( Clip * clip : atv->getTrack()->getClips() ) { - AutomationPattern * ap = dynamic_cast( clip ); + AutomationClip * ap = dynamic_cast( clip ); if( ap ) { ap->setRecording( on ); } } atv->update(); diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index 21d10cb24ea..dfdbb32eec8 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -25,7 +25,7 @@ */ #include "AutomationTrackView.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : @@ -53,7 +53,7 @@ TrackView * AutomationTrack::createView( TrackContainerView* tcv ) Clip* AutomationTrack::createClip(const TimePos & pos) { - AutomationPattern* p = new AutomationPattern(this); + AutomationClip* p = new AutomationClip(this); p->movePosition(pos); return p; } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index dab835acfce..6f08c0c16e0 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -37,7 +37,7 @@ #include #include "FileDialog.h" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "BBTrack.h" #include "CaptionMenu.h" #include "ComboBox.h" @@ -918,7 +918,7 @@ void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement // compat code - if node-name doesn't match any known // one, we assume that it is an instrument-plugin // which we'll try to load - else if(AutomationPattern::classNodeName() != node.nodeName() && + else if(AutomationClip::classNodeName() != node.nodeName() && ControllerConnection::classNodeName() != node.nodeName() && !node.toElement().hasAttribute( "id" )) { diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index 920ccabf045..024abe35cd8 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -26,7 +26,7 @@ #include "QCoreApplication" -#include "AutomationPattern.h" +#include "AutomationClip.h" #include "AutomationTrack.h" #include "BBTrack.h" #include "BBTrackContainer.h" @@ -48,8 +48,8 @@ private slots: void testPatternLinear() { - AutomationPattern p(nullptr); - p.setProgressionType(AutomationPattern::LinearProgression); + AutomationClip p(nullptr); + p.setProgressionType(AutomationClip::LinearProgression); p.putValue(0, 0.0, false); p.putValue(100, 1.0, false); @@ -63,8 +63,8 @@ private slots: void testPatternDiscrete() { - AutomationPattern p(nullptr); - p.setProgressionType(AutomationPattern::DiscreteProgression); + AutomationClip p(nullptr); + p.setProgressionType(AutomationClip::DiscreteProgression); p.putValue(0, 0.0, false); p.putValue(100, 1.0, false); @@ -81,21 +81,21 @@ private slots: auto song = Engine::getSong(); AutomationTrack track(song); - AutomationPattern p1(&track); - p1.setProgressionType(AutomationPattern::LinearProgression); + AutomationClip p1(&track); + p1.setProgressionType(AutomationClip::LinearProgression); p1.putValue(0, 0.0, false); p1.putValue(10, 1.0, false); p1.movePosition(0); p1.addObject(&model); - AutomationPattern p2(&track); - p2.setProgressionType(AutomationPattern::LinearProgression); + AutomationClip p2(&track); + p2.setProgressionType(AutomationClip::LinearProgression); p2.putValue(0, 0.0, false); p2.putValue(100, 1.0, false); p2.movePosition(100); p2.addObject(&model); - AutomationPattern p3(&track); + AutomationClip p3(&track); p3.addObject(&model); //XXX: Why is this even necessary? p3.clear(); @@ -115,8 +115,8 @@ private slots: auto song = Engine::getSong(); AutomationTrack track(song); - AutomationPattern p(&track); - p.setProgressionType(AutomationPattern::LinearProgression); + AutomationClip p(&track); + p.setProgressionType(AutomationClip::LinearProgression); p.addObject(&model); p.putValue(0, 0.0, false); @@ -147,7 +147,7 @@ private slots: DetuningHelper* dh = note->detuning(); auto pattern = dh->automationPattern(); - pattern->setProgressionType( AutomationPattern::LinearProgression ); + pattern->setProgressionType( AutomationClip::LinearProgression ); pattern->putValue(TimePos(0, 0), 0.0); pattern->putValue(TimePos(4, 0), 1.0); @@ -165,12 +165,12 @@ private slots: Track* automationTrack = Track::create(Track::AutomationTrack, bbContainer); QVERIFY(automationTrack->numOfClips()); - AutomationPattern* p1 = dynamic_cast(automationTrack->getClip(0)); + AutomationClip* p1 = dynamic_cast(automationTrack->getClip(0)); QVERIFY(p1); FloatModel model; - p1->setProgressionType(AutomationPattern::LinearProgression); + p1->setProgressionType(AutomationClip::LinearProgression); p1->putValue(0, 0.0, false); p1->putValue(10, 1.0, false); p1->addObject(&model); @@ -201,14 +201,14 @@ private slots: auto song = Engine::getSong(); auto globalTrack = song->globalAutomationTrack(); - AutomationPattern globalPattern(globalTrack); + AutomationClip globalPattern(globalTrack); AutomationTrack localTrack(song); - AutomationPattern localPattern(&localTrack); + AutomationClip localPattern(&localTrack); FloatModel model; - globalPattern.setProgressionType(AutomationPattern::DiscreteProgression); - localPattern.setProgressionType(AutomationPattern::DiscreteProgression); + globalPattern.setProgressionType(AutomationClip::DiscreteProgression); + localPattern.setProgressionType(AutomationClip::DiscreteProgression); globalPattern.addObject(&model); localPattern.addObject(&model); globalPattern.putValue(0, 100.0f, false); From b60bf8c0fdb847e2657369b9bddb002e72bd4ce3 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 8 Jun 2021 14:33:55 +0530 Subject: [PATCH 5/6] Partial rename of Pattern -> MidiClip --- data/themes/classic/style.css | 8 +- data/themes/default/style.css | 8 +- include/AutomationClip.h | 211 +++ include/AutomationClipView.h | 79 ++ include/ClipView.h | 8 +- include/{Pattern.h => MidiClip.h} | 44 +- include/{PatternView.h => MidiClipView.h} | 18 +- include/PianoRoll.h | 38 +- include/Song.h | 6 +- include/StepRecorder.h | 6 +- plugins/HydrogenImport/HydrogenImport.cpp | 6 +- plugins/MidiImport/MidiImport.cpp | 22 +- src/core/AutomationClip.cpp | 1184 +++++++++++++++++ src/core/Song.cpp | 18 +- src/core/StepRecorder.cpp | 18 +- src/gui/AutomationClipView.cpp | 508 +++++++ src/gui/CMakeLists.txt | 2 +- src/gui/ClipView.cpp | 44 +- src/gui/{PatternView.cpp => MidiClipView.cpp} | 154 +-- src/gui/editors/AutomationEditor.cpp | 4 +- src/gui/editors/BBEditor.cpp | 6 +- src/gui/editors/PianoRoll.cpp | 370 +++--- src/tracks/CMakeLists.txt | 2 +- src/tracks/InstrumentTrack.cpp | 6 +- src/tracks/{Pattern.cpp => MidiClip.cpp} | 114 +- tests/src/tracks/AutomationTrackTest.cpp | 8 +- 26 files changed, 2437 insertions(+), 455 deletions(-) create mode 100644 include/AutomationClip.h create mode 100644 include/AutomationClipView.h rename include/{Pattern.h => MidiClip.h} (76%) rename include/{PatternView.h => MidiClipView.h} (92%) create mode 100644 src/core/AutomationClip.cpp create mode 100644 src/gui/AutomationClipView.cpp rename src/gui/{PatternView.cpp => MidiClipView.cpp} (77%) rename src/tracks/{Pattern.cpp => MidiClip.cpp} (79%) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 949a6d7d029..87af7b611e9 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -663,14 +663,14 @@ TrackContainerView QLabel background: none; } -/* Patterns */ +/* Clips */ /* common pattern colors */ ClipView { qproperty-mutedColor: rgb( 128, 128, 128 ); qproperty-mutedBackgroundColor: rgb( 80, 80, 80 ); qproperty-selectedColor: rgb( 0, 125, 255 ); - qproperty-BBPatternBackground: rgb( 80, 80, 80 ); + qproperty-BBClipBackground: rgb( 80, 80, 80 ); qproperty-textColor: rgb( 255, 255, 255 ); qproperty-textBackgroundColor: rgba(0, 0, 0, 75); qproperty-textShadowColor: rgb( 0, 0, 0 ); @@ -683,7 +683,7 @@ ClipView { } /* instrument pattern */ -PatternView { +MidiClipView { background-color: rgb( 119, 199, 216 ); color: rgb( 187, 227, 236 ); @@ -700,7 +700,7 @@ SampleClipView { } /* automation pattern */ -AutomationPatternView { +AutomationClipView { background-color: #99afff; color: rgb( 204, 215, 255 ); } diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 1b7a2c2ea67..e1ae510fc53 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -709,14 +709,14 @@ TrackContainerView QLabel background: none; } -/* Patterns */ +/* Clips */ /* common pattern colors */ ClipView { qproperty-mutedColor: rgba(255,255,255,100); qproperty-mutedBackgroundColor: #373d48; qproperty-selectedColor: #006B65; - qproperty-BBPatternBackground: #373d48; + qproperty-BBClipBackground: #373d48; qproperty-textColor: #fff; qproperty-textBackgroundColor: rgba(0, 0, 0, 75); qproperty-textShadowColor: rgba(0,0,0,200); @@ -729,7 +729,7 @@ ClipView { } /* instrument pattern */ -PatternView { +MidiClipView { background-color: #21A14F; color: rgba(255,255,255,220); @@ -746,7 +746,7 @@ SampleClipView { } /* automation pattern */ -AutomationPatternView { +AutomationClipView { background-color: #663DE1; color: rgba(255,255,255,90); } diff --git a/include/AutomationClip.h b/include/AutomationClip.h new file mode 100644 index 00000000000..80befb1db75 --- /dev/null +++ b/include/AutomationClip.h @@ -0,0 +1,211 @@ +/* + * AutomationClip.h - declaration of class AutomationClip, which contains + * all information about an automation clip + * + * Copyright (c) 2008-2014 Tobias Doerffel + * Copyright (c) 2006-2008 Javier Serrano Polo + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef AUTOMATION_CLIP_H +#define AUTOMATION_CLIP_H + +#include +#include + +#include "AutomationNode.h" +#include "Clip.h" + + +class AutomationTrack; +class TimePos; + + + +class LMMS_EXPORT AutomationClip : public Clip +{ + Q_OBJECT +public: + enum ProgressionTypes + { + DiscreteProgression, + LinearProgression, + CubicHermiteProgression + } ; + + typedef QMap timeMap; + typedef QVector> objectVector; + + AutomationClip( AutomationTrack * _auto_track ); + AutomationClip( const AutomationClip & _pat_to_copy ); + virtual ~AutomationClip() = default; + + bool addObject( AutomatableModel * _obj, bool _search_dup = true ); + + const AutomatableModel * firstObject() const; + const objectVector& objects() const; + + // progression-type stuff + inline ProgressionTypes progressionType() const + { + return m_progressionType; + } + void setProgressionType( ProgressionTypes _new_progression_type ); + + inline float getTension() const + { + return m_tension; + } + void setTension( QString _new_tension ); + + TimePos timeMapLength() const; + void updateLength(); + + TimePos putValue( + const TimePos & time, + const float value, + const bool quantPos = true, + const bool ignoreSurroundingPoints = true + ); + + TimePos putValues( + const TimePos & time, + const float inValue, + const float outValue, + const bool quantPos = true, + const bool ignoreSurroundingPoints = true + ); + + void removeNode(const TimePos & time); + void removeNodes(const int tick0, const int tick1); + + void resetNodes(const int tick0, const int tick1); + + void recordValue(TimePos time, float value); + + TimePos setDragValue( const TimePos & time, + const float value, + const bool quantPos = true, + const bool controlKey = false ); + + void applyDragValue(); + + + bool isDragging() const + { + return m_dragging; + } + + inline const timeMap & getTimeMap() const + { + return m_timeMap; + } + + inline timeMap & getTimeMap() + { + return m_timeMap; + } + + inline float getMin() const + { + return firstObject()->minValue(); + } + + inline float getMax() const + { + return firstObject()->maxValue(); + } + + inline bool hasAutomation() const + { + return m_timeMap.isEmpty() == false; + } + + float valueAt( const TimePos & _time ) const; + float *valuesAfter( const TimePos & _time ) const; + + const QString name() const; + + // settings-management + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + + static const QString classNodeName() { return "automationclip"; } + QString nodeName() const override { return classNodeName(); } + + ClipView * createView( TrackView * _tv ) override; + + + static bool isAutomated( const AutomatableModel * _m ); + static QVector clipsForModel( const AutomatableModel * _m ); + static AutomationClip * globalAutomationClip( AutomatableModel * _m ); + static void resolveAllIDs(); + + bool isRecording() const { return m_isRecording; } + void setRecording( const bool b ) { m_isRecording = b; } + + static int quantization() { return s_quantization; } + static void setQuantization(int q) { s_quantization = q; } + +public slots: + void clear(); + void objectDestroyed( jo_id_t ); + void flipY( int min, int max ); + void flipY(); + void flipX( int length = -1 ); + +private: + void cleanObjects(); + void generateTangents(); + void generateTangents(timeMap::iterator it, int numToGenerate); + float valueAt( timeMap::const_iterator v, int offset ) const; + + // Mutex to make methods involving automation clips thread safe + // Mutable so we can lock it from const objects + mutable QMutex m_clipMutex; + + AutomationTrack * m_autoTrack; + QVector m_idsToResolve; + objectVector m_objects; + timeMap m_timeMap; // actual values + timeMap m_oldTimeMap; // old values for storing the values before setDragValue() is called. + float m_tension; + bool m_hasAutomation; + ProgressionTypes m_progressionType; + + bool m_dragging; + bool m_dragKeepOutValue; // Should we keep the current dragged node's outValue? + float m_dragOutValue; // The outValue of the dragged node's + + bool m_isRecording; + float m_lastRecordedValue; + + static int s_quantization; + + static const float DEFAULT_MIN_VALUE; + static const float DEFAULT_MAX_VALUE; + + friend class AutomationClipView; + friend class AutomationNode; + +} ; + + +#endif diff --git a/include/AutomationClipView.h b/include/AutomationClipView.h new file mode 100644 index 00000000000..2fd54a29ba6 --- /dev/null +++ b/include/AutomationClipView.h @@ -0,0 +1,79 @@ +/* + * AutomationClipView.h - declaration of class AutomationClipView + * + * Copyright (c) 2008-2010 Tobias Doerffel + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef AUTOMATION_CLIP_VIEW_H +#define AUTOMATION_CLIP_VIEW_H + +#include + +#include "AutomationClip.h" +#include "Song.h" +#include "SongEditor.h" +#include "ClipView.h" + + +class AutomationClipView : public ClipView +{ + Q_OBJECT + + +public: + AutomationClipView( AutomationClip * _pat, TrackView * _parent ); + virtual ~AutomationClipView(); + +public slots: + /// Opens this view's clip in the global automation editor + void openInAutomationEditor(); + void update() override; + + +protected slots: + void resetName(); + void changeName(); + void disconnectObject( QAction * _a ); + void toggleRecording(); + void flipY(); + void flipX(); + +protected: + void constructContextMenu( QMenu * ) override; + void mouseDoubleClickEvent(QMouseEvent * me ) override; + void paintEvent( QPaintEvent * pe ) override; + void dragEnterEvent( QDragEnterEvent * _dee ) override; + void dropEvent( QDropEvent * _de ) override; + + +private: + AutomationClip * m_clip; + QPixmap m_paintPixmap; + + QStaticText m_staticTextName; + + static QPixmap * s_pat_rec; + + void scaleTimemapToFit( float oldMin, float oldMax ); +} ; + + +#endif diff --git a/include/ClipView.h b/include/ClipView.h index 14ad930f42b..03321aac780 100644 --- a/include/ClipView.h +++ b/include/ClipView.h @@ -53,7 +53,7 @@ class ClipView : public selectableObject, public ModelView Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) Q_PROPERTY( QColor textBackgroundColor READ textBackgroundColor WRITE setTextBackgroundColor ) Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor ) - Q_PROPERTY( QColor BBPatternBackground READ BBPatternBackground WRITE setBBPatternBackground ) + Q_PROPERTY( QColor BBClipBackground READ BBClipBackground WRITE setBBClipBackground ) Q_PROPERTY( bool gradient READ gradient WRITE setGradient ) // We have to use a QSize here because using QPoint isn't supported. // width -> x, height -> y @@ -83,7 +83,7 @@ class ClipView : public selectableObject, public ModelView QColor textColor() const; QColor textBackgroundColor() const; QColor textShadowColor() const; - QColor BBPatternBackground() const; + QColor BBClipBackground() const; bool gradient() const; void setMutedColor( const QColor & c ); void setMutedBackgroundColor( const QColor & c ); @@ -91,7 +91,7 @@ class ClipView : public selectableObject, public ModelView void setTextColor( const QColor & c ); void setTextBackgroundColor( const QColor & c ); void setTextShadowColor( const QColor & c ); - void setBBPatternBackground( const QColor & c ); + void setBBClipBackground( const QColor & c ); void setGradient( const bool & b ); // access needsUpdate member variable @@ -210,7 +210,7 @@ protected slots: QColor m_textColor; QColor m_textBackgroundColor; QColor m_textShadowColor; - QColor m_BBPatternBackground; + QColor m_BBClipBackground; bool m_gradient; QSize m_mouseHotspotHand; // QSize must be used because QPoint QSize m_mouseHotspotKnife; // isn't supported by property system diff --git a/include/Pattern.h b/include/MidiClip.h similarity index 76% rename from include/Pattern.h rename to include/MidiClip.h index bb07e25817a..a3c734b0e5c 100644 --- a/include/Pattern.h +++ b/include/MidiClip.h @@ -1,6 +1,6 @@ /* - * Pattern.h - declaration of class Pattern, which contains all information - * about a pattern + * MidiClip.h - declaration of class MidiClip, which contains all information + * about a clip * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -29,26 +29,26 @@ #include #include "Note.h" -#include "PatternView.h" +#include "MidiClipView.h" #include "ClipView.h" class InstrumentTrack; -class LMMS_EXPORT Pattern : public Clip +class LMMS_EXPORT MidiClip : public Clip { Q_OBJECT public: - enum PatternTypes + enum MidiClipTypes { - BeatPattern, - MelodyPattern + BeatClip, + MelodyClip } ; - Pattern( InstrumentTrack* instrumentTrack ); - Pattern( const Pattern& other ); - virtual ~Pattern(); + MidiClip( InstrumentTrack* instrumentTrack ); + MidiClip( const MidiClip& other ); + virtual ~MidiClip(); void init(); @@ -75,23 +75,23 @@ class LMMS_EXPORT Pattern : public Clip // Split the list of notes on the given position void splitNotes(NoteVector notes, TimePos pos); - // pattern-type stuff - inline PatternTypes type() const + // clip-type stuff + inline MidiClipTypes type() const { - return m_patternType; + return m_clipType; } // next/previous track based on position in the containing track - Pattern * previousPattern() const; - Pattern * nextPattern() const; + MidiClip * previousMidiClip() const; + MidiClip * nextMidiClip() const; // settings-management void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; inline QString nodeName() const override { - return "pattern"; + return "clip"; } inline InstrumentTrack * instrumentTrack() const @@ -121,29 +121,29 @@ protected slots: private: - TimePos beatPatternLength() const; + TimePos beatClipLength() const; - void setType( PatternTypes _new_pattern_type ); + void setType( MidiClipTypes _new_clip_type ); void checkType(); void resizeToFirstTrack(); InstrumentTrack * m_instrumentTrack; - PatternTypes m_patternType; + MidiClipTypes m_clipType; // data-stuff NoteVector m_notes; int m_steps; - Pattern * adjacentPatternByOffset(int offset) const; + MidiClip * adjacentMidiClipByOffset(int offset) const; - friend class PatternView; + friend class MidiClipView; friend class BBTrackContainerView; signals: - void destroyedPattern( Pattern* ); + void destroyedMidiClip( MidiClip* ); } ; diff --git a/include/PatternView.h b/include/MidiClipView.h similarity index 92% rename from include/PatternView.h rename to include/MidiClipView.h index 252ac3a4d00..dce3c7f93e6 100644 --- a/include/PatternView.h +++ b/include/MidiClipView.h @@ -1,5 +1,5 @@ /* - * PatternView.h + * MidiClipView.h * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -25,19 +25,19 @@ #ifndef PATTERN_VIEW_H #define PATTERN_VIEW_H -#include "Pattern.h" +#include "MidiClip.h" #include "ClipView.h" -class Pattern; +class MidiClip; -class PatternView : public ClipView +class MidiClipView : public ClipView { Q_OBJECT public: - PatternView( Pattern* pattern, TrackView* parent ); - virtual ~PatternView() = default; + MidiClipView( MidiClip* clip, TrackView* parent ); + virtual ~MidiClipView() = default; Q_PROPERTY(QColor noteFillColor READ getNoteFillColor WRITE setNoteFillColor) Q_PROPERTY(QColor noteBorderColor READ getNoteBorderColor WRITE setNoteBorderColor) @@ -57,7 +57,7 @@ class PatternView : public ClipView void setMutedNoteBorderColor(QColor const & color) { m_mutedNoteBorderColor = color; } public slots: - Pattern* getPattern(); + MidiClip* getMidiClip(); void update() override; @@ -83,7 +83,7 @@ protected slots: static QPixmap * s_stepBtnOff; static QPixmap * s_stepBtnOffLight; - Pattern* m_pat; + MidiClip* m_clp; QPixmap m_paintPixmap; QColor m_noteFillColor; @@ -98,4 +98,4 @@ protected slots: - #endif \ No newline at end of file + #endif diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 50da9418975..185152a530a 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -51,7 +51,7 @@ class QToolButton; class ComboBox; class NotePlayHandle; -class Pattern; +class MidiClip; class TimeLineWidget; class PianoRoll : public QWidget @@ -110,8 +110,8 @@ class PianoRoll : public QWidget void showVolTextFloat(volume_t vol, const QPoint &pos, int timeout=-1); void showPanTextFloat(panning_t pan, const QPoint &pos, int timeout=-1); - void setCurrentPattern( Pattern* newPattern ); - void setGhostPattern( Pattern* newPattern ); + void setCurrentMidiClip( MidiClip* newMidiClip ); + void setGhostClip( MidiClip* newMidiClip ); void loadGhostNotes( const QDomElement & de ); void loadMarkedSemiTones(const QDomElement & de); @@ -130,14 +130,14 @@ class PianoRoll : public QWidget return m_stepRecorder.isRecording(); } - const Pattern* currentPattern() const + const MidiClip* currentMidiClip() const { - return m_pattern; + return m_clip; } - bool hasValidPattern() const + bool hasValidMidiClip() const { - return m_pattern != NULL; + return m_clip != NULL; } Song::PlayModes desiredPlayModeForAccompany() const; @@ -215,11 +215,11 @@ protected slots: void changeNoteEditMode( int i ); void markSemiTone(int i, bool fromMenu = true); - void hidePattern( Pattern* pattern ); + void hideMidiClip( MidiClip* pattern ); void selectRegionFromPixels( int xStart, int xEnd ); - void clearGhostPattern(); + void clearGhostClip(); void glueNotes(); void fitNoteLengths(bool fill); void constrainNoteLengths(bool constrainMax); @@ -228,8 +228,8 @@ protected slots: signals: - void currentPatternChanged(); - void ghostPatternSet(bool); + void currentMidiClipChanged(); + void ghostClipSet(bool); void semiToneMarkerMenuScaleSetEnabled(bool); void semiToneMarkerMenuChordSetEnabled(bool); @@ -349,7 +349,7 @@ protected slots: static const QVector m_zoomLevels; static const QVector m_zoomYLevels; - Pattern* m_pattern; + MidiClip* m_clip; NoteVector m_ghostNotes; inline const NoteVector & ghostNotes() const @@ -496,9 +496,9 @@ class PianoRollWindow : public Editor, SerializingObject public: PianoRollWindow(); - const Pattern* currentPattern() const; - void setCurrentPattern( Pattern* pattern ); - void setGhostPattern( Pattern* pattern ); + const MidiClip* currentMidiClip() const; + void setCurrentMidiClip( MidiClip* pattern ); + void setGhostClip( MidiClip* pattern ); int quantization() const; @@ -528,14 +528,14 @@ class PianoRollWindow : public Editor, SerializingObject bool hasFocus() const; signals: - void currentPatternChanged(); + void currentMidiClipChanged(); private slots: void updateAfterPatternChange(); - void ghostPatternSet( bool state ); - void exportPattern(); - void importPattern(); + void ghostClipSet( bool state ); + void exportMidiClip(); + void importMidiClip(); private: void patternRenamed(); diff --git a/include/Song.h b/include/Song.h index 0171d3c526d..81309ffe650 100644 --- a/include/Song.h +++ b/include/Song.h @@ -40,7 +40,7 @@ class AutomationTrack; -class Pattern; +class MidiClip; class TimeLineWidget; @@ -355,7 +355,7 @@ public slots: void record(); void playAndRecord(); void playBB(); - void playPattern( const Pattern * patternToPlay, bool loop = true ); + void playPattern( const MidiClip * patternToPlay, bool loop = true ); void togglePause(); void stop(); @@ -458,7 +458,7 @@ private slots: PlayPos m_playPos[Mode_Count]; bar_t m_length; - const Pattern* m_patternToPlay; + const MidiClip* m_clipToPlay; bool m_loopPattern; double m_elapsedMilliSeconds[Mode_Count]; diff --git a/include/StepRecorder.h b/include/StepRecorder.h index 13b3577a86c..0c1b0f9c8bf 100644 --- a/include/StepRecorder.h +++ b/include/StepRecorder.h @@ -28,7 +28,7 @@ #include "Note.h" #include "lmms_basics.h" -#include "Pattern.h" +#include "MidiClip.h" class PianoRoll; class StepRecorderWidget; @@ -47,7 +47,7 @@ class StepRecorder : public QObject void noteReleased(const Note & n); bool keyPressEvent(QKeyEvent* ke); bool mousePressEvent(QMouseEvent* ke); - void setCurrentPattern(Pattern* newPattern); + void setCurrentMidiClip(MidiClip* newMidiClip); void setStepsLength(const TimePos& newLength); QVector getCurStepNotes(); @@ -93,7 +93,7 @@ class StepRecorder : public QObject QTimer m_updateReleasedTimer; - Pattern* m_pattern; + MidiClip* m_clip; class StepNote { diff --git a/plugins/HydrogenImport/HydrogenImport.cpp b/plugins/HydrogenImport/HydrogenImport.cpp index 0bb07289f8f..cf528d4b512 100644 --- a/plugins/HydrogenImport/HydrogenImport.cpp +++ b/plugins/HydrogenImport/HydrogenImport.cpp @@ -13,7 +13,7 @@ #include "Instrument.h" #include "InstrumentTrack.h" #include "Note.h" -#include "Pattern.h" +#include "MidiClip.h" #include "Track.h" #include "BBTrack.h" #include "BBTrackContainer.h" @@ -280,7 +280,7 @@ bool HydrogenImport::readSong() QString instrId = LocalFileMng::readXmlString( noteNode, "instrument", 0,false, false ); int i = pattern_count - 1 + nbb; pattern_id[sName] = pattern_count - 1; - Pattern*p = dynamic_cast( drum_track[instrId]->getClip( i ) ); + MidiClip*p = dynamic_cast( drum_track[instrId]->getClip( i ) ); Note n; n.setPos( nPosition ); if ( (nPosition + 48) <= nSize ) @@ -301,7 +301,7 @@ bool HydrogenImport::readSong() } patternNode = ( QDomNode ) patternNode.nextSiblingElement( "pattern" ); } - // Pattern sequence + // MidiClip sequence QDomNode patternSequenceNode = songNode.firstChildElement( "patternSequence" ); QDomNode groupNode = patternSequenceNode.firstChildElement( "group" ); int pos = 0; diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 2c8352a9379..ebdf9a47526 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -39,7 +39,7 @@ #include "AutomationTrack.h" #include "AutomationClip.h" #include "ConfigManager.h" -#include "Pattern.h" +#include "MidiClip.h" #include "Instrument.h" #include "GuiApplication.h" #include "MainWindow.h" @@ -221,7 +221,7 @@ class smfMidiChannel { } InstrumentTrack * it; - Pattern* p; + MidiClip* p; Instrument * it_inst; bool isSF2; bool hasNotes; @@ -259,7 +259,7 @@ class smfMidiChannel it->pitchRangeModel()->setInitValue( 2 ); // Create a default pattern - p = dynamic_cast(it->createClip(0)); + p = dynamic_cast(it->createClip(0)); } return this; } @@ -269,30 +269,30 @@ class smfMidiChannel { if (!p) { - p = dynamic_cast(it->createClip(0)); + p = dynamic_cast(it->createClip(0)); } p->addNote(n, false); hasNotes = true; } - void splitPatterns() + void splitMidiClips() { - Pattern * newPattern = nullptr; + MidiClip * newMidiClip = nullptr; TimePos lastEnd(0); p->rearrangeAllNotes(); for (auto n : p->notes()) { - if (!newPattern || n->pos() > lastEnd + DefaultTicksPerBar) + if (!newMidiClip || n->pos() > lastEnd + DefaultTicksPerBar) { TimePos pPos = TimePos(n->pos().getBar(), 0); - newPattern = dynamic_cast(it->createClip(pPos)); + newMidiClip = dynamic_cast(it->createClip(pPos)); } lastEnd = n->pos() + n->length(); Note newNote(*n); - newNote.setPos(n->pos(newPattern->startPosition())); - newPattern->addNote(newNote, false); + newNote.setPos(n->pos(newMidiClip->startPosition())); + newMidiClip->addNote(newNote, false); } delete p; @@ -565,7 +565,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) { if (c.second.hasNotes) { - c.second.splitPatterns(); + c.second.splitMidiClips(); } else if (c.second.it) { diff --git a/src/core/AutomationClip.cpp b/src/core/AutomationClip.cpp new file mode 100644 index 00000000000..8d519053549 --- /dev/null +++ b/src/core/AutomationClip.cpp @@ -0,0 +1,1184 @@ +/* + * AutomationClip.cpp - implementation of class AutomationClip which + * holds dynamic values + * + * Copyright (c) 2008-2014 Tobias Doerffel + * Copyright (c) 2006-2008 Javier Serrano Polo + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include "AutomationClip.h" + +#include "AutomationNode.h" +#include "AutomationClipView.h" +#include "AutomationTrack.h" +#include "BBTrackContainer.h" +#include "LocaleHelper.h" +#include "ProjectJournal.h" +#include "Song.h" + +#include + +int AutomationClip::s_quantization = 1; +const float AutomationClip::DEFAULT_MIN_VALUE = 0; +const float AutomationClip::DEFAULT_MAX_VALUE = 1; + + +AutomationClip::AutomationClip( AutomationTrack * _auto_track ) : + Clip( _auto_track ), + m_clipMutex(QMutex::Recursive), + m_autoTrack( _auto_track ), + m_objects(), + m_tension( 1.0 ), + m_progressionType( DiscreteProgression ), + m_dragging( false ), + m_isRecording( false ), + m_lastRecordedValue( 0 ) +{ + changeLength( TimePos( 1, 0 ) ); + if( getTrack() ) + { + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + // move down + default: + setAutoResize( false ); + break; + } + } +} + + + + +AutomationClip::AutomationClip( const AutomationClip & _pat_to_copy ) : + Clip( _pat_to_copy.m_autoTrack ), + m_clipMutex(QMutex::Recursive), + m_autoTrack( _pat_to_copy.m_autoTrack ), + m_objects( _pat_to_copy.m_objects ), + m_tension( _pat_to_copy.m_tension ), + m_progressionType( _pat_to_copy.m_progressionType ) +{ + // Locks the mutex of the copied AutomationClip to make sure it + // doesn't change while it's being copied + QMutexLocker m(&_pat_to_copy.m_clipMutex); + + for( timeMap::const_iterator it = _pat_to_copy.m_timeMap.begin(); + it != _pat_to_copy.m_timeMap.end(); ++it ) + { + // Copies the automation node (in/out values and in/out tangents) + m_timeMap[POS(it)] = it.value(); + // Sets the node's clip to this one + m_timeMap[POS(it)].setClip(this); + } + if (!getTrack()){ return; } + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + // move down + default: + setAutoResize( false ); + break; + } +} + +bool AutomationClip::addObject( AutomatableModel * _obj, bool _search_dup ) +{ + QMutexLocker m(&m_clipMutex); + + if( _search_dup && m_objects.contains(_obj) ) + { + return false; + } + + // the automation track is unconnected and there is nothing in the track + if( m_objects.isEmpty() && hasAutomation() == false ) + { + // then initialize first value + putValue( TimePos(0), _obj->inverseScaledValue( _obj->value() ), false ); + } + + m_objects += _obj; + + connect( _obj, SIGNAL( destroyed( jo_id_t ) ), + this, SLOT( objectDestroyed( jo_id_t ) ), + Qt::DirectConnection ); + + emit dataChanged(); + + return true; +} + + + + +void AutomationClip::setProgressionType( + ProgressionTypes _new_progression_type ) +{ + QMutexLocker m(&m_clipMutex); + + if ( _new_progression_type == DiscreteProgression || + _new_progression_type == LinearProgression || + _new_progression_type == CubicHermiteProgression ) + { + m_progressionType = _new_progression_type; + emit dataChanged(); + } +} + + + + +void AutomationClip::setTension( QString _new_tension ) +{ + QMutexLocker m(&m_clipMutex); + + bool ok; + float nt = LocaleHelper::toFloat(_new_tension, & ok); + + if( ok && nt > -0.01 && nt < 1.01 ) + { + m_tension = nt; + } +} + + + + +const AutomatableModel * AutomationClip::firstObject() const +{ + QMutexLocker m(&m_clipMutex); + + AutomatableModel* model; + if (!m_objects.isEmpty() && (model = m_objects.first()) != nullptr) + { + return model; + } + + static FloatModel fm(0, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, 0.001); + return &fm; +} + +const AutomationClip::objectVector& AutomationClip::objects() const +{ + QMutexLocker m(&m_clipMutex); + + return m_objects; +} + + + + +TimePos AutomationClip::timeMapLength() const +{ + QMutexLocker m(&m_clipMutex); + + TimePos one_bar = TimePos(1, 0); + if (m_timeMap.isEmpty()) { return one_bar; } + + timeMap::const_iterator it = m_timeMap.end(); + tick_t last_tick = static_cast(POS(it - 1)); + // if last_tick is 0 (single item at tick 0) + // return length as a whole bar to prevent disappearing Clip + if (last_tick == 0) { return one_bar; } + + return TimePos(last_tick); +} + + + + +void AutomationClip::updateLength() +{ + // Do not resize down in case user manually extended up + changeLength(qMax(length(), timeMapLength())); +} + + + + +/** + * @brief Puts an automation node on the timeMap with the given value. + * The inValue and outValue of the created node will be the same. + * @param TimePos time to add the node to + * @param Float inValue and outValue of the node + * @param Boolean True to quantize the position (defaults to true) + * @param Boolean True to ignore unquantized surrounding nodes (defaults to true) + * @return TimePos of the recently added automation node + */ +TimePos AutomationClip::putValue( + const TimePos & time, + const float value, + const bool quantPos, + const bool ignoreSurroundingPoints +) +{ + QMutexLocker m(&m_clipMutex); + + cleanObjects(); + + TimePos newTime = quantPos ? Note::quantized(time, quantization()) : time; + + // Create a node or replace the existing one on newTime + m_timeMap[newTime] = AutomationNode(this, value, newTime); + + timeMap::iterator it = m_timeMap.find(newTime); + + // Remove control points that are covered by the new points + // quantization value. Control Key to override + if (!ignoreSurroundingPoints) + { + // We need to check that to avoid removing nodes from + // newTime + 1 to newTime (removing the node we are adding) + if (quantization() > 1) + { + // Remove nodes between the quantization points, them not + // being included + removeNodes(newTime + 1, newTime + quantization() - 1); + } + } + if (it != m_timeMap.begin()) { --it; } + generateTangents(it, 3); + + updateLength(); + + emit dataChanged(); + + return newTime; +} + + + + +/** + * @brief Puts an automation node on the timeMap with the given inValue + * and outValue. + * @param TimePos time to add the node to + * @param Float inValue of the node + * @param Float outValue of the node + * @param Boolean True to quantize the position (defaults to true) + * @param Boolean True to ignore unquantized surrounding nodes (defaults to true) + * @return TimePos of the recently added automation node + */ +TimePos AutomationClip::putValues( + const TimePos & time, + const float inValue, + const float outValue, + const bool quantPos, + const bool ignoreSurroundingPoints +) +{ + QMutexLocker m(&m_clipMutex); + + cleanObjects(); + + TimePos newTime = quantPos ? Note::quantized(time, quantization()) : time; + + // Create a node or replace the existing one on newTime + m_timeMap[newTime] = AutomationNode(this, inValue, outValue, newTime); + + timeMap::iterator it = m_timeMap.find(newTime); + + // Remove control points that are covered by the new points + // quantization value. Control Key to override + if (!ignoreSurroundingPoints) + { + // We need to check that to avoid removing nodes from + // newTime + 1 to newTime (removing the node we are adding) + if (quantization() > 1) + { + // Remove nodes between the quantization points, them not + // being included + removeNodes(newTime + 1, newTime + quantization() - 1); + } + } + if (it != m_timeMap.begin()) { --it; } + generateTangents(it, 3); + + updateLength(); + + emit dataChanged(); + + return newTime; +} + + + + +void AutomationClip::removeNode(const TimePos & time) +{ + QMutexLocker m(&m_clipMutex); + + cleanObjects(); + + m_timeMap.remove( time ); + timeMap::iterator it = m_timeMap.lowerBound(time); + if( it != m_timeMap.begin() ) + { + --it; + } + generateTangents(it, 3); + + updateLength(); + + emit dataChanged(); +} + + + + +/** + * @brief Removes all automation nodes between the given ticks + * @param Int first tick of the range + * @param Int second tick of the range + */ +void AutomationClip::removeNodes(const int tick0, const int tick1) +{ + if (tick0 == tick1) + { + removeNode(TimePos(tick0)); + return; + } + + TimePos start = TimePos(qMin(tick0, tick1)); + TimePos end = TimePos(qMax(tick0, tick1)); + + // Make a list of TimePos with nodes to be removed + // because we can't simply remove the nodes from + // the timeMap while we are iterating it. + QVector nodesToRemove; + + for (auto it = m_timeMap.lowerBound(start), endIt = m_timeMap.upperBound(end); it != endIt; ++it) + { + nodesToRemove.append(POS(it)); + } + + for (auto node: nodesToRemove) + { + removeNode(node); + } +} + + + + +/** + * @brief Resets the outValues of all automation nodes between the given ticks + * @param Int first tick of the range + * @param Int second tick of the range + */ +void AutomationClip::resetNodes(const int tick0, const int tick1) +{ + if (tick0 == tick1) + { + auto it = m_timeMap.find(TimePos(tick0)); + if (it != m_timeMap.end()) { it.value().resetOutValue(); } + return; + } + + TimePos start = TimePos(qMin(tick0, tick1)); + TimePos end = TimePos(qMax(tick0, tick1)); + + for (auto it = m_timeMap.lowerBound(start), endIt = m_timeMap.upperBound(end); it != endIt; ++it) + { + it.value().resetOutValue(); + } +} + + + + +void AutomationClip::recordValue(TimePos time, float value) +{ + QMutexLocker m(&m_clipMutex); + + if( value != m_lastRecordedValue ) + { + putValue( time, value, true ); + m_lastRecordedValue = value; + } + else if( valueAt( time ) != value ) + { + removeNode(time); + } +} + + + + +/** + * @brief Set the position of the point that is being dragged. + * Calling this function will also automatically set m_dragging to true. + * When applyDragValue() is called, m_dragging is set back to false. + * @param TimePos of the node being dragged + * @param Float with the value to assign to the point being dragged + * @param Boolean. True to snip x position + * @param Boolean. True to ignore unquantized surrounding nodes + * @return TimePos with current time of the dragged value + */ +TimePos AutomationClip::setDragValue( + const TimePos & time, + const float value, + const bool quantPos, + const bool controlKey +) +{ + QMutexLocker m(&m_clipMutex); + + if (m_dragging == false) + { + TimePos newTime = quantPos ? Note::quantized(time, quantization()) : time; + + // We will keep the same outValue only if it's different from the + // inValue + m_dragKeepOutValue = false; + + // Check if we already have a node on the position we are dragging + // and if we do, store the outValue so the discrete jump can be kept + timeMap::iterator it = m_timeMap.find(newTime); + if (it != m_timeMap.end()) + { + if (OFFSET(it) != 0) + { + m_dragKeepOutValue = true; + m_dragOutValue = OUTVAL(it); + } + } + + this->removeNode(newTime); + m_oldTimeMap = m_timeMap; + m_dragging = true; + } + + //Restore to the state before it the point were being dragged + m_timeMap = m_oldTimeMap; + + generateTangents(); + + if (m_dragKeepOutValue) + { + return this->putValues(time, value, m_dragOutValue, quantPos, controlKey); + } + + return this->putValue(time, value, quantPos, controlKey); +} + + + + +/** + * @brief After the point is dragged, this function is called to apply the change. + */ +void AutomationClip::applyDragValue() +{ + QMutexLocker m(&m_clipMutex); + + m_dragging = false; +} + + + + +float AutomationClip::valueAt( const TimePos & _time ) const +{ + QMutexLocker m(&m_clipMutex); + + if( m_timeMap.isEmpty() ) + { + return 0; + } + + // If we have a node at that time, just return its value + if (m_timeMap.contains(_time)) + { + // When the time is exactly the node's time, we want the inValue + return m_timeMap[_time].getInValue(); + } + + // lowerBound returns next value with equal or greater key. Since we already + // checked if the key contains a node, we know the returned node has a greater + // key than _time. Therefore we take the previous element to calculate the current value + timeMap::const_iterator v = m_timeMap.lowerBound(_time); + + if( v == m_timeMap.begin() ) + { + return 0; + } + if( v == m_timeMap.end() ) + { + // When the time is after the last node, we want the outValue of it + return OUTVAL(v - 1); + } + + return valueAt(v - 1, _time - POS(v - 1)); +} + + + + +// This method will get the value at an offset from a node, so we use the outValue of +// that node and the inValue of the next node for the calculations. +float AutomationClip::valueAt( timeMap::const_iterator v, int offset ) const +{ + QMutexLocker m(&m_clipMutex); + + // We never use it with offset 0, but doesn't hurt to return a correct + // value if we do + if (offset == 0) { return INVAL(v); } + + if (m_progressionType == DiscreteProgression) + { + return OUTVAL(v); + } + else if( m_progressionType == LinearProgression ) + { + float slope = + (INVAL(v + 1) - OUTVAL(v)) + / (POS(v + 1) - POS(v)); + + return OUTVAL(v) + offset * slope; + } + else /* CubicHermiteProgression */ + { + // Implements a Cubic Hermite spline as explained at: + // http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Unit_interval_.280.2C_1.29 + // + // Note that we are not interpolating a 2 dimensional point over + // time as the article describes. We are interpolating a single + // value: y. To make this work we map the values of x that this + // segment spans to values of t for t = 0.0 -> 1.0 and scale the + // tangents _m1 and _m2 + int numValues = (POS(v + 1) - POS(v)); + float t = (float) offset / (float) numValues; + float m1 = OUTTAN(v) * numValues * m_tension; + float m2 = INTAN(v + 1) * numValues * m_tension; + + auto t2 = pow(t, 2); + auto t3 = pow(t, 3); + return (2 * t3 - 3 * t2 + 1) * OUTVAL(v) + + (t3 - 2 * t2 + t) * m1 + + (-2 * t3 + 3 * t2) * INVAL(v + 1) + + (t3 - t2) * m2; + } +} + + + + +float *AutomationClip::valuesAfter( const TimePos & _time ) const +{ + QMutexLocker m(&m_clipMutex); + + timeMap::const_iterator v = m_timeMap.lowerBound(_time); + if( v == m_timeMap.end() || (v+1) == m_timeMap.end() ) + { + return NULL; + } + + int numValues = POS(v + 1) - POS(v); + float *ret = new float[numValues]; + + for( int i = 0; i < numValues; i++ ) + { + ret[i] = valueAt( v, i ); + } + + return ret; +} + + + + +void AutomationClip::flipY(int min, int max) +{ + QMutexLocker m(&m_clipMutex); + + bool changedTimeMap = false; + + for (auto it = m_timeMap.begin(); it != m_timeMap.end(); ++it) + { + // Get distance from IN/OUT values to max value + float inValDist = max - INVAL(it); + float outValDist = max - OUTVAL(it); + + // To flip, that will be the new distance between + // the IN/OUT values and the min value + it.value().setInValue(min + inValDist); + it.value().setOutValue(min + outValDist); + + changedTimeMap = true; + } + + if (changedTimeMap) + { + generateTangents(); + emit dataChanged(); + } +} + + + + +void AutomationClip::flipY() +{ + flipY(getMin(), getMax()); +} + + + + +void AutomationClip::flipX(int length) +{ + QMutexLocker m(&m_clipMutex); + + timeMap::const_iterator it = m_timeMap.lowerBound(0); + + if (it == m_timeMap.end()) { return; } + + // Temporary map where we will store the flipped version + // of our clip + timeMap tempMap; + + float tempValue = 0; + float tempOutValue = 0; + + // We know the QMap isn't empty, making this safe: + float realLength = m_timeMap.lastKey(); + + // If we have a positive length, we want to flip the area covered by that + // length, even if it goes beyond the clip. A negative length means that + // we just want to flip the nodes we have + if (length >= 0 && length != realLength) + { + // If length to be flipped is bigger than the real length + if (realLength < length) + { + // We are flipping an area that goes beyond the last node. So we add a node to the + // beginning of the flipped timeMap representing the value of the end of the area + tempValue = valueAt(length); + tempMap[0] = AutomationNode(this, tempValue, 0); + + // Now flip the nodes we have in relation to the length + do + { + // We swap the inValue and outValue when flipping horizontally + tempValue = OUTVAL(it); + tempOutValue = INVAL(it); + TimePos newTime = TimePos(length - POS(it)); + + tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); + + ++it; + } while (it != m_timeMap.end()); + } + else // If the length to be flipped is smaller than the real length + { + do + { + TimePos newTime; + + // Only flips the length to be flipped and keep the remaining values in place + // We also only swap the inValue and outValue if we are flipping the node + if (POS(it) <= length) + { + newTime = length - POS(it); + tempValue = OUTVAL(it); + tempOutValue = INVAL(it); + } + else + { + newTime = POS(it); + tempValue = INVAL(it); + tempOutValue = OUTVAL(it); + } + + tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); + + ++it; + } while (it != m_timeMap.end()); + } + } + else // Length to be flipped is the same as the real length + { + do + { + // Swap the inValue and outValue + tempValue = OUTVAL(it); + tempOutValue = INVAL(it); + + TimePos newTime = TimePos(realLength - POS(it)); + tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); + + ++it; + } while (it != m_timeMap.end()); + } + + m_timeMap.clear(); + + m_timeMap = tempMap; + + cleanObjects(); + + generateTangents(); + emit dataChanged(); +} + + + + +void AutomationClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) +{ + QMutexLocker m(&m_clipMutex); + + _this.setAttribute( "pos", startPosition() ); + _this.setAttribute( "len", length() ); + _this.setAttribute( "name", name() ); + _this.setAttribute( "prog", QString::number( progressionType() ) ); + _this.setAttribute( "tens", QString::number( getTension() ) ); + _this.setAttribute( "mute", QString::number( isMuted() ) ); + + if( usesCustomClipColor() ) + { + _this.setAttribute( "color", color().name() ); + } + + for( timeMap::const_iterator it = m_timeMap.begin(); + it != m_timeMap.end(); ++it ) + { + QDomElement element = _doc.createElement( "time" ); + element.setAttribute("pos", POS(it)); + element.setAttribute("value", INVAL(it)); + element.setAttribute("outValue", OUTVAL(it)); + _this.appendChild( element ); + } + + for( objectVector::const_iterator it = m_objects.begin(); + it != m_objects.end(); ++it ) + { + if( *it ) + { + QDomElement element = _doc.createElement( "object" ); + element.setAttribute( "id", + ProjectJournal::idToSave( ( *it )->id() ) ); + _this.appendChild( element ); + } + } +} + + + + +void AutomationClip::loadSettings( const QDomElement & _this ) +{ + QMutexLocker m(&m_clipMutex); + + clear(); + + movePosition( _this.attribute( "pos" ).toInt() ); + setName( _this.attribute( "name" ) ); + setProgressionType( static_cast( _this.attribute( + "prog" ).toInt() ) ); + setTension( _this.attribute( "tens" ) ); + setMuted(_this.attribute( "mute", QString::number( false ) ).toInt() ); + + for( QDomNode node = _this.firstChild(); !node.isNull(); + node = node.nextSibling() ) + { + QDomElement element = node.toElement(); + if( element.isNull() ) + { + continue; + } + if( element.tagName() == "time" ) + { + int timeMapPos = element.attribute("pos").toInt(); + float timeMapInValue = LocaleHelper::toFloat(element.attribute("value")); + float timeMapOutValue = LocaleHelper::toFloat(element.attribute("outValue")); + + m_timeMap[timeMapPos] = AutomationNode(this, timeMapInValue, timeMapOutValue, timeMapPos); + } + else if( element.tagName() == "object" ) + { + m_idsToResolve << element.attribute( "id" ).toInt(); + } + } + + if( _this.hasAttribute( "color" ) ) + { + useCustomClipColor( true ); + setColor( _this.attribute( "color" ) ); + } + + int len = _this.attribute( "len" ).toInt(); + if( len <= 0 ) + { + // TODO: Handle with an upgrade method + updateLength(); + } + else + { + changeLength( len ); + } + generateTangents(); +} + + + + +const QString AutomationClip::name() const +{ + QMutexLocker m(&m_clipMutex); + + if( !Clip::name().isEmpty() ) + { + return Clip::name(); + } + if( !m_objects.isEmpty() && m_objects.first() != NULL ) + { + return m_objects.first()->fullDisplayName(); + } + return tr( "Drag a control while pressing <%1>" ).arg(UI_CTRL_KEY); +} + + + + +ClipView * AutomationClip::createView( TrackView * _tv ) +{ + QMutexLocker m(&m_clipMutex); + + return new AutomationClipView( this, _tv ); +} + + + + + +bool AutomationClip::isAutomated( const AutomatableModel * _m ) +{ + TrackContainer::TrackList l; + l += Engine::getSong()->tracks(); + l += Engine::getBBTrackContainer()->tracks(); + l += Engine::getSong()->globalAutomationTrack(); + + for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) + { + if( ( *it )->type() == Track::AutomationTrack || + ( *it )->type() == Track::HiddenAutomationTrack ) + { + const Track::clipVector & v = ( *it )->getClips(); + for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) + { + const AutomationClip * a = dynamic_cast( *j ); + if( a && a->hasAutomation() ) + { + for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k ) + { + if( *k == _m ) + { + return true; + } + } + } + } + } + } + return false; +} + + +/** + * @brief returns a list of all the automation clips that are connected to a specific model + * @param _m the model we want to look for + */ +QVector AutomationClip::clipsForModel( const AutomatableModel * _m ) +{ + QVector clips; + TrackContainer::TrackList l; + l += Engine::getSong()->tracks(); + l += Engine::getBBTrackContainer()->tracks(); + l += Engine::getSong()->globalAutomationTrack(); + + // go through all tracks... + for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) + { + // we want only automation tracks... + if( ( *it )->type() == Track::AutomationTrack || + ( *it )->type() == Track::HiddenAutomationTrack ) + { + // get clips in those tracks.... + const Track::clipVector & v = ( *it )->getClips(); + // go through all the clips... + for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) + { + AutomationClip * a = dynamic_cast( *j ); + // check that the clip has automation + if( a && a->hasAutomation() ) + { + // now check is the clip is connected to the model we want by going through all the connections + // of the clip + bool has_object = false; + for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k ) + { + if( *k == _m ) + { + has_object = true; + } + } + // if the clips is connected to the model, add it to the list + if( has_object ) { clips += a; } + } + } + } + } + return clips; +} + + + +AutomationClip * AutomationClip::globalAutomationClip( + AutomatableModel * _m ) +{ + AutomationTrack * t = Engine::getSong()->globalAutomationTrack(); + Track::clipVector v = t->getClips(); + for( Track::clipVector::const_iterator j = v.begin(); j != v.end(); ++j ) + { + AutomationClip * a = dynamic_cast( *j ); + if( a ) + { + for( objectVector::const_iterator k = a->m_objects.begin(); + k != a->m_objects.end(); ++k ) + { + if( *k == _m ) + { + return a; + } + } + } + } + + AutomationClip * a = new AutomationClip( t ); + a->addObject( _m, false ); + return a; +} + + + + +void AutomationClip::resolveAllIDs() +{ + TrackContainer::TrackList l = Engine::getSong()->tracks() + + Engine::getBBTrackContainer()->tracks(); + l += Engine::getSong()->globalAutomationTrack(); + for( TrackContainer::TrackList::iterator it = l.begin(); + it != l.end(); ++it ) + { + if( ( *it )->type() == Track::AutomationTrack || + ( *it )->type() == Track::HiddenAutomationTrack ) + { + Track::clipVector v = ( *it )->getClips(); + for( Track::clipVector::iterator j = v.begin(); + j != v.end(); ++j ) + { + AutomationClip * a = dynamic_cast( *j ); + if( a ) + { + for( QVector::Iterator k = a->m_idsToResolve.begin(); + k != a->m_idsToResolve.end(); ++k ) + { + JournallingObject * o = Engine::projectJournal()-> + journallingObject( *k ); + if( o && dynamic_cast( o ) ) + { + a->addObject( dynamic_cast( o ), false ); + } + else + { + // FIXME: Remove this block once the automation system gets fixed + // This is a temporary fix for https://github.com/LMMS/lmms/issues/3781 + o = Engine::projectJournal()->journallingObject(ProjectJournal::idFromSave(*k)); + if( o && dynamic_cast( o ) ) + { + a->addObject( dynamic_cast( o ), false ); + } + else + { + // FIXME: Remove this block once the automation system gets fixed + // This is a temporary fix for https://github.com/LMMS/lmms/issues/4781 + o = Engine::projectJournal()->journallingObject(ProjectJournal::idToSave(*k)); + if( o && dynamic_cast( o ) ) + { + a->addObject( dynamic_cast( o ), false ); + } + } + } + } + a->m_idsToResolve.clear(); + a->dataChanged(); + } + } + } + } +} + + + + +void AutomationClip::clear() +{ + QMutexLocker m(&m_clipMutex); + + m_timeMap.clear(); + + emit dataChanged(); +} + + + + +void AutomationClip::objectDestroyed( jo_id_t _id ) +{ + QMutexLocker m(&m_clipMutex); + + // TODO: distict between temporary removal (e.g. LADSPA controls + // when switching samplerate) and real deletions because in the latter + // case we had to remove ourselves if we're the global automation + // clip of the destroyed object + m_idsToResolve += _id; + + for( objectVector::Iterator objIt = m_objects.begin(); + objIt != m_objects.end(); objIt++ ) + { + Q_ASSERT( !(*objIt).isNull() ); + if( (*objIt)->id() == _id ) + { + //Assign to objIt so that this loop work even break; is removed. + objIt = m_objects.erase( objIt ); + break; + } + } + + emit dataChanged(); +} + + + + +void AutomationClip::cleanObjects() +{ + QMutexLocker m(&m_clipMutex); + + for( objectVector::iterator it = m_objects.begin(); it != m_objects.end(); ) + { + if( *it ) + { + ++it; + } + else + { + it = m_objects.erase( it ); + } + } +} + + + + +void AutomationClip::generateTangents() +{ + generateTangents(m_timeMap.begin(), m_timeMap.size()); +} + + + + +// We have two tangents, one for the left side of the node and one for the right side +// of the node (in case we have discrete value jumps in the middle of a curve). +// If the inValue and outValue of a node are the same, consequently the inTangent and +// outTangent values of the node will be the same too. +void AutomationClip::generateTangents(timeMap::iterator it, int numToGenerate) +{ + QMutexLocker m(&m_clipMutex); + + if( m_timeMap.size() < 2 && numToGenerate > 0 ) + { + it.value().setInTangent(0); + it.value().setOutTangent(0); + return; + } + + for( int i = 0; i < numToGenerate; i++ ) + { + if( it == m_timeMap.begin() ) + { + // On the first node there's no curve behind it, so we will only calculate the outTangent + // and inTangent will be set to 0. + float tangent = (INVAL(it + 1) - OUTVAL(it)) / (POS(it + 1) - POS(it)); + it.value().setInTangent(0); + it.value().setOutTangent(tangent); + } + else if( it+1 == m_timeMap.end() ) + { + // Previously, the last value's tangent was always set to 0. That logic was kept for both tangents + // of the last node + it.value().setInTangent(0); + it.value().setOutTangent(0); + return; + } + else + { + // When we are in a node that is in the middle of two other nodes, we need to check if we + // have a discrete jump at this node. If we do not, then we can calculate the tangents normally. + // If we do have a discrete jump, then we have to calculate the tangents differently for each side + // of the curve. + // TODO: This behavior means that a very small difference between the inValue and outValue can + // result in a big change in the curve. In the future, allowing the user to manually adjust + // the tangents would be better. + float inTangent; + float outTangent; + if (OFFSET(it) == 0) + { + inTangent = (INVAL(it + 1) - OUTVAL(it - 1)) / (POS(it + 1) - POS(it - 1)); + it.value().setInTangent(inTangent); + // inTangent == outTangent in this case + it.value().setOutTangent(inTangent); + } + else + { + // Calculate the left side of the curve + inTangent = (INVAL(it) - OUTVAL(it - 1)) / (POS(it) - POS(it - 1)); + // Calculate the right side of the curve + outTangent = (INVAL(it + 1) - OUTVAL(it)) / (POS(it + 1) - POS(it)); + it.value().setInTangent(inTangent); + it.value().setOutTangent(outTangent); + } + } + it++; + } +} diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 293b52c0696..a59c682112c 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -50,7 +50,7 @@ #include "ExportFilter.h" #include "InstrumentTrack.h" #include "NotePlayHandle.h" -#include "Pattern.h" +#include "MidiClip.h" #include "PianoRoll.h" #include "ProjectJournal.h" #include "ProjectNotes.h" @@ -89,7 +89,7 @@ Song::Song() : m_isCancelled( false ), m_playMode( Mode_None ), m_length( 0 ), - m_patternToPlay( NULL ), + m_clipToPlay( NULL ), m_loopPattern( false ), m_elapsedTicks( 0 ), m_elapsedBars( 0 ), @@ -226,10 +226,10 @@ void Song::processNextBuffer() break; case Mode_PlayPattern: - if (m_patternToPlay) + if (m_clipToPlay) { - clipNum = m_patternToPlay->getTrack()->getClipNum(m_patternToPlay); - trackList.push_back(m_patternToPlay->getTrack()); + clipNum = m_clipToPlay->getTrack()->getClipNum(m_clipToPlay); + trackList.push_back(m_clipToPlay->getTrack()); } break; @@ -294,7 +294,7 @@ void Song::processNextBuffer() } else if (m_playMode == Mode_PlayPattern && m_loopPattern && !loopEnabled) { - enforceLoop(TimePos{0}, m_patternToPlay->length()); + enforceLoop(TimePos{0}, m_clipToPlay->length()); } // Handle loop points, and inform VST plugins of the loop status @@ -537,17 +537,17 @@ void Song::playBB() -void Song::playPattern( const Pattern* patternToPlay, bool loop ) +void Song::playPattern( const MidiClip* patternToPlay, bool loop ) { if( isStopped() == false ) { stop(); } - m_patternToPlay = patternToPlay; + m_clipToPlay = patternToPlay; m_loopPattern = loop; - if( m_patternToPlay != NULL ) + if( m_clipToPlay != NULL ) { m_playMode = Mode_PlayPattern; m_playing = true; diff --git a/src/core/StepRecorder.cpp b/src/core/StepRecorder.cpp index 1413d505014..d45a0985a19 100644 --- a/src/core/StepRecorder.cpp +++ b/src/core/StepRecorder.cpp @@ -33,7 +33,7 @@ const int REMOVE_RELEASED_NOTE_TIME_THRESHOLD_MS = 70; StepRecorder::StepRecorder(PianoRoll& pianoRoll, StepRecorderWidget& stepRecorderWidget): m_pianoRoll(pianoRoll), m_stepRecorderWidget(stepRecorderWidget), - m_pattern(nullptr) + m_clip(nullptr) { m_stepRecorderWidget.hide(); } @@ -226,16 +226,16 @@ void StepRecorder::stepBackwards() void StepRecorder::applyStep() { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); for (const StepNote* stepNote : m_curStepNotes) { - m_pattern->addNote(stepNote->m_note, false); + m_clip->addNote(stepNote->m_note, false); } - m_pattern->rearrangeAllNotes(); - m_pattern->updateLength(); - m_pattern->dataChanged(); + m_clip->rearrangeAllNotes(); + m_clip->updateLength(); + m_clip->dataChanged(); Engine::getSong()->setModified(); prepareNewStep(); @@ -267,14 +267,14 @@ void StepRecorder::prepareNewStep() updateWidget(); } -void StepRecorder::setCurrentPattern( Pattern* newPattern ) +void StepRecorder::setCurrentMidiClip( MidiClip* newMidiClip ) { - if(m_pattern != NULL && m_pattern != newPattern) + if(m_clip != NULL && m_clip != newMidiClip) { dismissStep(); } - m_pattern = newPattern; + m_clip = newMidiClip; } void StepRecorder::removeNotesReleasedForTooLong() diff --git a/src/gui/AutomationClipView.cpp b/src/gui/AutomationClipView.cpp new file mode 100644 index 00000000000..b02d51c264e --- /dev/null +++ b/src/gui/AutomationClipView.cpp @@ -0,0 +1,508 @@ +/* + * AutomationClipView.cpp - implementation of view for AutomationClip + * + * Copyright (c) 2008-2010 Tobias Doerffel + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ +#include "AutomationClipView.h" + +#include +#include +#include +#include + +#include "AutomationEditor.h" +#include "embed.h" +#include "GuiApplication.h" +#include "gui_templates.h" +#include "ProjectJournal.h" +#include "RenameDialog.h" +#include "StringPairDrag.h" +#include "TextFloat.h" +#include "ToolTip.h" + +#include "Engine.h" + + +QPixmap * AutomationClipView::s_pat_rec = NULL; + +AutomationClipView::AutomationClipView( AutomationClip * _clip, + TrackView * _parent ) : + ClipView( _clip, _parent ), + m_clip( _clip ), + m_paintPixmap() +{ + connect( m_clip, SIGNAL( dataChanged() ), + this, SLOT( update() ) ); + connect( gui->automationEditor(), SIGNAL( currentClipChanged() ), + this, SLOT( update() ) ); + + setAttribute( Qt::WA_OpaquePaintEvent, true ); + + ToolTip::add(this, m_clip->name()); + setStyle( QApplication::style() ); + + if( s_pat_rec == NULL ) { s_pat_rec = new QPixmap( embed::getIconPixmap( + "pat_rec" ) ); } + + update(); +} + + + + +AutomationClipView::~AutomationClipView() +{ +} + + + + +void AutomationClipView::openInAutomationEditor() +{ + if(gui) gui->automationEditor()->open(m_clip); +} + + +void AutomationClipView::update() +{ + ToolTip::add(this, m_clip->name()); + + ClipView::update(); +} + + + +void AutomationClipView::resetName() +{ + m_clip->setName( QString() ); +} + + + + +void AutomationClipView::changeName() +{ + QString s = m_clip->name(); + RenameDialog rename_dlg( s ); + rename_dlg.exec(); + m_clip->setName( s ); + update(); +} + + + + +void AutomationClipView::disconnectObject( QAction * _a ) +{ + JournallingObject * j = Engine::projectJournal()-> + journallingObject( _a->data().toInt() ); + if( j && dynamic_cast( j ) ) + { + float oldMin = m_clip->getMin(); + float oldMax = m_clip->getMax(); + + m_clip->m_objects.erase( std::find( m_clip->m_objects.begin(), + m_clip->m_objects.end(), + dynamic_cast( j ) ) ); + update(); + + //If automation editor is opened, update its display after disconnection + if( gui->automationEditor() ) + { + gui->automationEditor()->m_editor->updateAfterClipChange(); + } + + //if there is no more connection connected to the AutomationClip + if( m_clip->m_objects.size() == 0 ) + { + //scale the points to fit the new min. and max. value + this->scaleTimemapToFit( oldMin, oldMax ); + } + } +} + + +void AutomationClipView::toggleRecording() +{ + m_clip->setRecording( ! m_clip->isRecording() ); + update(); +} + + + + +void AutomationClipView::flipY() +{ + m_clip->flipY( m_clip->getMin(), m_clip->getMax() ); + update(); +} + + + + +void AutomationClipView::flipX() +{ + m_clip->flipX( m_clip->length() ); + update(); +} + + + + +void AutomationClipView::constructContextMenu( QMenu * _cm ) +{ + QAction * a = new QAction( embed::getIconPixmap( "automation" ), + tr( "Open in Automation editor" ), _cm ); + _cm->insertAction( _cm->actions()[0], a ); + connect(a, SIGNAL(triggered()), this, SLOT(openInAutomationEditor())); + _cm->insertSeparator( _cm->actions()[1] ); + + _cm->addSeparator(); + + _cm->addAction( embed::getIconPixmap( "edit_erase" ), + tr( "Clear" ), m_clip, SLOT( clear() ) ); + _cm->addSeparator(); + + _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), + this, SLOT( resetName() ) ); + _cm->addAction( embed::getIconPixmap( "edit_rename" ), + tr( "Change name" ), + this, SLOT( changeName() ) ); + _cm->addAction( embed::getIconPixmap( "record" ), + tr( "Set/clear record" ), + this, SLOT( toggleRecording() ) ); + _cm->addAction( embed::getIconPixmap( "flip_y" ), + tr( "Flip Vertically (Visible)" ), + this, SLOT( flipY() ) ); + _cm->addAction( embed::getIconPixmap( "flip_x" ), + tr( "Flip Horizontally (Visible)" ), + this, SLOT( flipX() ) ); + if( !m_clip->m_objects.isEmpty() ) + { + _cm->addSeparator(); + QMenu * m = new QMenu( tr( "%1 Connections" ). + arg( m_clip->m_objects.count() ), _cm ); + for( AutomationClip::objectVector::iterator it = + m_clip->m_objects.begin(); + it != m_clip->m_objects.end(); ++it ) + { + if( *it ) + { + a = new QAction( tr( "Disconnect \"%1\"" ). + arg( ( *it )->fullDisplayName() ), m ); + a->setData( ( *it )->id() ); + m->addAction( a ); + } + } + connect( m, SIGNAL( triggered( QAction * ) ), + this, SLOT( disconnectObject( QAction * ) ) ); + _cm->addMenu( m ); + } +} + + + + +void AutomationClipView::mouseDoubleClickEvent( QMouseEvent * me ) +{ + if(me->button() != Qt::LeftButton) + { + me->ignore(); + return; + } + openInAutomationEditor(); +} + + + + +void AutomationClipView::paintEvent( QPaintEvent * ) +{ + QPainter painter( this ); + + if( !needsUpdate() ) + { + painter.drawPixmap( 0, 0, m_paintPixmap ); + return; + } + + setNeedsUpdate( false ); + + if (m_paintPixmap.isNull() || m_paintPixmap.size() != size()) + { + m_paintPixmap = QPixmap(size()); + } + + QPainter p( &m_paintPixmap ); + + QLinearGradient lingrad( 0, 0, 0, height() ); + QColor c = getColorForDisplay( painter.background().color() ); + bool muted = m_clip->getTrack()->isMuted() || m_clip->isMuted(); + bool current = gui->automationEditor()->currentClip() == m_clip; + + lingrad.setColorAt( 1, c.darker( 300 ) ); + lingrad.setColorAt( 0, c ); + + // paint a black rectangle under the clip to prevent glitches with transparent backgrounds + p.fillRect( rect(), QColor( 0, 0, 0 ) ); + + if( gradient() ) + { + p.fillRect( rect(), lingrad ); + } + else + { + p.fillRect( rect(), c ); + } + + const float ppb = fixedClips() ? + ( parentWidget()->width() - 2 * CLIP_BORDER_WIDTH ) + / (float) m_clip->timeMapLength().getBar() : + pixelsPerBar(); + + const int x_base = CLIP_BORDER_WIDTH; + + const float min = m_clip->firstObject()->minValue(); + const float max = m_clip->firstObject()->maxValue(); + + const float y_scale = max - min; + const float h = ( height() - 2 * CLIP_BORDER_WIDTH ) / y_scale; + const float ppTick = ppb / TimePos::ticksPerBar(); + + p.translate( 0.0f, max * height() / y_scale - CLIP_BORDER_WIDTH ); + p.scale( 1.0f, -h ); + + QLinearGradient lin2grad( 0, min, 0, max ); + QColor col; + + col = !muted ? painter.pen().brush().color() : mutedColor(); + + lin2grad.setColorAt( 1, col.lighter( 150 ) ); + lin2grad.setColorAt( 0.5, col ); + lin2grad.setColorAt( 0, col.darker( 150 ) ); + + p.setRenderHints( QPainter::Antialiasing, true ); + for( AutomationClip::timeMap::const_iterator it = + m_clip->getTimeMap().begin(); + it != m_clip->getTimeMap().end(); ++it ) + { + if( it+1 == m_clip->getTimeMap().end() ) + { + const float x1 = x_base + POS(it) * ppTick; + const float x2 = (float)( width() - CLIP_BORDER_WIDTH ); + if( x1 > ( width() - CLIP_BORDER_WIDTH ) ) break; + // We are drawing the space after the last node, so we use the outValue + if( gradient() ) + { + p.fillRect(QRectF(x1, 0.0f, x2 - x1, OUTVAL(it)), lin2grad); + } + else + { + p.fillRect(QRectF(x1, 0.0f, x2 - x1, OUTVAL(it)), col); + } + break; + } + + float *values = m_clip->valuesAfter(POS(it)); + + // We are creating a path to draw a polygon representing the values between two + // nodes. When we have two nodes with discrete progression, we will basically have + // a rectangle with the outValue of the first node (that's why nextValue will match + // the outValue of the current node). When we have nodes with linear or cubic progression + // the value of the end of the shape between the two nodes will be the inValue of + // the next node. + float nextValue; + if( m_clip->progressionType() == AutomationClip::DiscreteProgression ) + { + nextValue = OUTVAL(it); + } + else + { + nextValue = INVAL(it + 1); + } + + QPainterPath path; + QPointF origin = QPointF(x_base + POS(it) * ppTick, 0.0f); + path.moveTo( origin ); + path.moveTo(QPointF(x_base + POS(it) * ppTick,values[0])); + float x; + for (int i = POS(it) + 1; i < POS(it + 1); i++) + { + x = x_base + i * ppTick; + if( x > ( width() - CLIP_BORDER_WIDTH ) ) break; + float value = values[i - POS(it)]; + path.lineTo( QPointF( x, value ) ); + + } + path.lineTo(x_base + (POS(it + 1)) * ppTick, nextValue); + path.lineTo(x_base + (POS(it + 1)) * ppTick, 0.0f); + path.lineTo( origin ); + + if( gradient() ) + { + p.fillPath( path, lin2grad ); + } + else + { + p.fillPath( path, col ); + } + delete [] values; + } + + p.setRenderHints( QPainter::Antialiasing, false ); + p.resetTransform(); + + // bar lines + const int lineSize = 3; + p.setPen( c.darker( 300 ) ); + + for( bar_t t = 1; t < width() - CLIP_BORDER_WIDTH; ++t ) + { + const int tx = x_base + static_cast( ppb * t ) - 2; + p.drawLine( tx, CLIP_BORDER_WIDTH, tx, CLIP_BORDER_WIDTH + lineSize ); + p.drawLine( tx, rect().bottom() - ( lineSize + CLIP_BORDER_WIDTH ), + tx, rect().bottom() - CLIP_BORDER_WIDTH ); + } + + // recording icon for when recording automation + if( m_clip->isRecording() ) + { + p.drawPixmap( 1, rect().bottom() - s_pat_rec->height(), + *s_pat_rec ); + } + + // clip name + paintTextLabel(m_clip->name(), p); + + // inner border + p.setPen( c.lighter( current ? 160 : 130 ) ); + p.drawRect( 1, 1, rect().right() - CLIP_BORDER_WIDTH, + rect().bottom() - CLIP_BORDER_WIDTH ); + + // outer border + p.setPen( current? c.lighter( 130 ) : c.darker( 300 ) ); + p.drawRect( 0, 0, rect().right(), rect().bottom() ); + + // draw the 'muted' pixmap only if the clip was manualy muted + if( m_clip->isMuted() ) + { + const int spacing = CLIP_BORDER_WIDTH; + const int size = 14; + p.drawPixmap( spacing, height() - ( size + spacing ), + embed::getIconPixmap( "muted", size, size ) ); + } + + p.end(); + + painter.drawPixmap( 0, 0, m_paintPixmap ); +} + + + + +void AutomationClipView::dragEnterEvent( QDragEnterEvent * _dee ) +{ + StringPairDrag::processDragEnterEvent( _dee, "automatable_model" ); + if( !_dee->isAccepted() ) + { + ClipView::dragEnterEvent( _dee ); + } +} + + + + +void AutomationClipView::dropEvent( QDropEvent * _de ) +{ + QString type = StringPairDrag::decodeKey( _de ); + QString val = StringPairDrag::decodeValue( _de ); + if( type == "automatable_model" ) + { + AutomatableModel * mod = dynamic_cast( + Engine::projectJournal()-> + journallingObject( val.toInt() ) ); + if( mod != NULL ) + { + bool added = m_clip->addObject( mod ); + if ( !added ) + { + TextFloat::displayMessage( mod->displayName(), + tr( "Model is already connected " + "to this clip." ), + embed::getIconPixmap( "automation" ), + 2000 ); + } + } + update(); + + if( gui->automationEditor() && + gui->automationEditor()->currentClip() == m_clip ) + { + gui->automationEditor()->setCurrentClip( m_clip ); + } + } + else + { + ClipView::dropEvent( _de ); + } +} + + + + +/** + * @brief Preserves the auto points over different scale + */ +void AutomationClipView::scaleTimemapToFit( float oldMin, float oldMax ) +{ + float newMin = m_clip->getMin(); + float newMax = m_clip->getMax(); + + if( oldMin == newMin && oldMax == newMax ) + { + return; + } + + // TODO: Currently when rescaling the timeMap values to fit the new range of values (newMin and newMax) + // only the inValue is being considered and the outValue is being reset to the inValue (so discrete jumps + // are discarded). Possibly later we will want discrete jumps to be maintained so we will need to upgrade + // the logic to account for them. + for( AutomationClip::timeMap::iterator it = m_clip->m_timeMap.begin(); + it != m_clip->m_timeMap.end(); ++it ) + { + // If the values are out of the previous range, fix them so they are + // between oldMin and oldMax. + if (INVAL(it) < oldMin) + { + it.value().setInValue(oldMin); + } + else if (INVAL(it) > oldMax) + { + it.value().setInValue(oldMax); + } + // Calculate what the value would be proportionally in the new range + it.value().setInValue((INVAL(it) - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin); + // Read earlier TODO comment: For now I'm discarding the discrete jumps during the rescaling + it.value().setOutValue(INVAL(it)); + } + + m_clip->generateTangents(); +} diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 72d0e6cf2f3..fc03ed24141 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -26,9 +26,9 @@ SET(LMMS_SRCS gui/MainApplication.cpp gui/MainWindow.cpp gui/MidiCCRackView.cpp + gui/MidiClipView.cpp gui/MidiSetupWidget.cpp gui/ModelView.cpp - gui/PatternView.cpp gui/PeakControllerDialog.cpp gui/PianoView.cpp gui/PluginBrowser.cpp diff --git a/src/gui/ClipView.cpp b/src/gui/ClipView.cpp index 065302ca94d..d26c0329151 100644 --- a/src/gui/ClipView.cpp +++ b/src/gui/ClipView.cpp @@ -39,8 +39,8 @@ #include "embed.h" #include "GuiApplication.h" #include "InstrumentTrack.h" +#include "MidiClip.h" #include "Note.h" -#include "Pattern.h" #include "SampleTrack.h" #include "Song.h" #include "SongEditor.h" @@ -91,7 +91,7 @@ ClipView::ClipView( Clip * clip, m_selectedColor( 0, 0, 0 ), m_textColor( 0, 0, 0 ), m_textShadowColor( 0, 0, 0 ), - m_BBPatternBackground( 0, 0, 0 ), + m_BBClipBackground( 0, 0, 0 ), m_gradient( true ), m_mouseHotspotHand( 0, 0 ), m_mouseHotspotKnife( 0, 0 ), @@ -215,8 +215,8 @@ QColor ClipView::textBackgroundColor() const QColor ClipView::textShadowColor() const { return m_textShadowColor; } -QColor ClipView::BBPatternBackground() const -{ return m_BBPatternBackground; } +QColor ClipView::BBClipBackground() const +{ return m_BBClipBackground; } bool ClipView::gradient() const { return m_gradient; } @@ -242,8 +242,8 @@ void ClipView::setTextBackgroundColor( const QColor & c ) void ClipView::setTextShadowColor( const QColor & c ) { m_textShadowColor = QColor( c ); } -void ClipView::setBBPatternBackground( const QColor & c ) -{ m_BBPatternBackground = QColor( c ); } +void ClipView::setBBClipBackground( const QColor & c ) +{ m_BBClipBackground = QColor( c ); } void ClipView::setGradient( const bool & b ) { m_gradient = b; } @@ -1213,35 +1213,35 @@ void ClipView::mergeClips(QVector clipvs) const TimePos earliestPos = (*earliestClipV)->getClip()->startPosition(); // Create a pattern where all notes will be added - Pattern* newPattern = dynamic_cast(track->createClip(earliestPos)); - if (!newPattern) + MidiClip* newMidiClip = dynamic_cast(track->createClip(earliestPos)); + if (!newMidiClip) { - qWarning("Warning: Failed to convert Clip to Pattern on mergeClips"); + qWarning("Warning: Failed to convert Clip to MidiClip on mergeClips"); return; } - newPattern->saveJournallingState(false); + newMidiClip->saveJournallingState(false); // Add the notes and remove the Clips that are being merged for (auto clipv: clipvs) { - // Convert ClipV to PatternView - PatternView* pView = dynamic_cast(clipv); + // Convert ClipV to MidiClipView + MidiClipView* mcView = dynamic_cast(clipv); - if (!pView) + if (!mcView) { - qWarning("Warning: Non-pattern Clip on InstrumentTrack"); + qWarning("Warning: Non-MidiClip Clip on InstrumentTrack"); continue; } - NoteVector currentClipNotes = pView->getPattern()->notes(); - TimePos pViewPos = pView->getPattern()->startPosition(); + NoteVector currentClipNotes = mcView->getMidiClip()->notes(); + TimePos mcViewPos = mcView->getMidiClip()->startPosition(); for (Note* note: currentClipNotes) { - Note* newNote = newPattern->addNote(*note, false); + Note* newNote = newMidiClip->addNote(*note, false); TimePos originalNotePos = newNote->pos(); - newNote->setPos(originalNotePos + (pViewPos - earliestPos)); + newNote->setPos(originalNotePos + (mcViewPos - earliestPos)); } // We disable the journalling system before removing, so the @@ -1251,12 +1251,12 @@ void ClipView::mergeClips(QVector clipvs) clipv->remove(); } - // Update length since we might have moved notes beyond the end of the pattern length - newPattern->updateLength(); + // Update length since we might have moved notes beyond the end of the MidiClip length + newMidiClip->updateLength(); // Rearrange notes because we might have moved them - newPattern->rearrangeAllNotes(); + newMidiClip->rearrangeAllNotes(); // Restore journalling states now that the operation is finished - newPattern->restoreJournallingState(); + newMidiClip->restoreJournallingState(); track->restoreJournallingState(); // Update song Engine::getSong()->setModified(); diff --git a/src/gui/PatternView.cpp b/src/gui/MidiClipView.cpp similarity index 77% rename from src/gui/PatternView.cpp rename to src/gui/MidiClipView.cpp index 4953ff44a2c..7f0b8bc7012 100644 --- a/src/gui/PatternView.cpp +++ b/src/gui/MidiClipView.cpp @@ -1,5 +1,5 @@ /* - * Pattern.cpp - implementation of class pattern which holds notes + * MidiClipView.cpp - implementation of class clip which holds notes * * Copyright (c) 2004-2014 Tobias Doerffel * Copyright (c) 2005-2007 Danny McRae @@ -23,7 +23,7 @@ * */ -#include "PatternView.h" +#include "MidiClipView.h" #include #include @@ -35,9 +35,9 @@ #include "PianoRoll.h" #include "RenameDialog.h" -PatternView::PatternView( Pattern* pattern, TrackView* parent ) : - ClipView( pattern, parent ), - m_pat( pattern ), +MidiClipView::MidiClipView( MidiClip* clip, TrackView* parent ) : + ClipView( clip, parent ), + m_clp( clip ), m_paintPixmap(), m_noteFillColor(255, 255, 255, 220), m_noteBorderColor(255, 255, 255, 220), @@ -45,7 +45,7 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) : m_mutedNoteBorderColor(100, 100, 100, 220), m_legacySEBB(ConfigManager::inst()->value("ui","legacysebb","0").toInt()) { - connect( gui->pianoRoll(), SIGNAL( currentPatternChanged() ), + connect( gui->pianoRoll(), SIGNAL( currentMidiClipChanged() ), this, SLOT( update() ) ); if( s_stepBtnOn0 == NULL ) @@ -80,17 +80,17 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) : -Pattern* PatternView::getPattern() +MidiClip* MidiClipView::getMidiClip() { - return m_pat; + return m_clp; } -void PatternView::update() +void MidiClipView::update() { - ToolTip::add(this, m_pat->name()); + ToolTip::add(this, m_clp->name()); ClipView::update(); } @@ -98,9 +98,9 @@ void PatternView::update() -void PatternView::openInPianoRoll() +void MidiClipView::openInPianoRoll() { - gui->pianoRoll()->setCurrentPattern( m_pat ); + gui->pianoRoll()->setCurrentMidiClip( m_clp ); gui->pianoRoll()->parentWidget()->show(); gui->pianoRoll()->show(); gui->pianoRoll()->setFocus(); @@ -110,9 +110,9 @@ void PatternView::openInPianoRoll() -void PatternView::setGhostInPianoRoll() +void MidiClipView::setGhostInPianoRoll() { - gui->pianoRoll()->setGhostPattern( m_pat ); + gui->pianoRoll()->setGhostClip( m_clp ); gui->pianoRoll()->parentWidget()->show(); gui->pianoRoll()->show(); gui->pianoRoll()->setFocus(); @@ -121,23 +121,23 @@ void PatternView::setGhostInPianoRoll() -void PatternView::resetName() { m_pat->setName(""); } +void MidiClipView::resetName() { m_clp->setName(""); } -void PatternView::changeName() +void MidiClipView::changeName() { - QString s = m_pat->name(); + QString s = m_clp->name(); RenameDialog rename_dlg( s ); rename_dlg.exec(); - m_pat->setName( s ); + m_clp->setName( s ); } -void PatternView::constructContextMenu( QMenu * _cm ) +void MidiClipView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "piano" ), tr( "Open in piano-roll" ), _cm ); @@ -147,7 +147,7 @@ void PatternView::constructContextMenu( QMenu * _cm ) QAction * b = new QAction( embed::getIconPixmap( "ghost_note" ), tr( "Set as ghost in piano-roll" ), _cm ); - if( m_pat->empty() ) { b->setEnabled( false ); } + if( m_clp->empty() ) { b->setEnabled( false ); } _cm->insertAction( _cm->actions()[1], b ); connect( b, SIGNAL( triggered( bool ) ), this, SLOT( setGhostInPianoRoll() ) ); @@ -155,7 +155,7 @@ void PatternView::constructContextMenu( QMenu * _cm ) _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "edit_erase" ), - tr( "Clear all notes" ), m_pat, SLOT( clear() ) ); + tr( "Clear all notes" ), m_clp, SLOT( clear() ) ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), @@ -164,27 +164,27 @@ void PatternView::constructContextMenu( QMenu * _cm ) tr( "Change name" ), this, SLOT( changeName() ) ); - if ( m_pat->type() == Pattern::BeatPattern ) + if ( m_clp->type() == MidiClip::BeatClip ) { _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "step_btn_add" ), - tr( "Add steps" ), m_pat, SLOT( addSteps() ) ); + tr( "Add steps" ), m_clp, SLOT( addSteps() ) ); _cm->addAction( embed::getIconPixmap( "step_btn_remove" ), - tr( "Remove steps" ), m_pat, SLOT( removeSteps() ) ); + tr( "Remove steps" ), m_clp, SLOT( removeSteps() ) ); _cm->addAction( embed::getIconPixmap( "step_btn_duplicate" ), - tr( "Clone Steps" ), m_pat, SLOT( cloneSteps() ) ); + tr( "Clone Steps" ), m_clp, SLOT( cloneSteps() ) ); } } -void PatternView::mousePressEvent( QMouseEvent * _me ) +void MidiClipView::mousePressEvent( QMouseEvent * _me ) { bool displayBB = fixedClips() || (pixelsPerBar() >= 96 && m_legacySEBB); if( _me->button() == Qt::LeftButton && - m_pat->m_patternType == Pattern::BeatPattern && + m_clp->m_clipType == MidiClip::BeatClip && displayBB && _me->y() > height() - s_stepBtnOff->height() ) @@ -194,35 +194,35 @@ void PatternView::mousePressEvent( QMouseEvent * _me ) // get the step number that was clicked on and // do calculations in floats to prevent rounding errors... float tmp = ( ( float(_me->x()) - CLIP_BORDER_WIDTH ) * - float( m_pat -> m_steps ) ) / float(width() - CLIP_BORDER_WIDTH*2); + float( m_clp -> m_steps ) ) / float(width() - CLIP_BORDER_WIDTH*2); int step = int( tmp ); // debugging to ensure we get the correct step... // qDebug( "Step (%f) %d", tmp, step ); - if( step >= m_pat->m_steps ) + if( step >= m_clp->m_steps ) { - qDebug( "Something went wrong in pattern.cpp: step %d doesn't exist in pattern!", step ); + qDebug( "Something went wrong in clip.cpp: step %d doesn't exist in clip!", step ); return; } - Note * n = m_pat->noteAtStep( step ); + Note * n = m_clp->noteAtStep( step ); if( n == NULL ) { - m_pat->addStepNote( step ); + m_clp->addStepNote( step ); } else // note at step found { - m_pat->addJournalCheckPoint(); - m_pat->setStep( step, false ); + m_clp->addJournalCheckPoint(); + m_clp->setStep( step, false ); } Engine::getSong()->setModified(); update(); - if( gui->pianoRoll()->currentPattern() == m_pat ) + if( gui->pianoRoll()->currentMidiClip() == m_clp ) { gui->pianoRoll()->update(); } @@ -236,14 +236,14 @@ void PatternView::mousePressEvent( QMouseEvent * _me ) } } -void PatternView::mouseDoubleClickEvent(QMouseEvent *_me) +void MidiClipView::mouseDoubleClickEvent(QMouseEvent *_me) { if( _me->button() != Qt::LeftButton ) { _me->ignore(); return; } - if( m_pat->m_patternType == Pattern::MelodyPattern || !fixedClips() ) + if( m_clp->m_clipType == MidiClip::MelodyClip || !fixedClips() ) { openInPianoRoll(); } @@ -252,28 +252,28 @@ void PatternView::mouseDoubleClickEvent(QMouseEvent *_me) -void PatternView::wheelEvent(QWheelEvent * we) +void MidiClipView::wheelEvent(QWheelEvent * we) { - if(m_pat->m_patternType == Pattern::BeatPattern && + if(m_clp->m_clipType == MidiClip::BeatClip && (fixedClips() || pixelsPerBar() >= 96) && position(we).y() > height() - s_stepBtnOff->height()) { // get the step number that was wheeled on and // do calculations in floats to prevent rounding errors... float tmp = ((float(position(we).x()) - CLIP_BORDER_WIDTH) * - float(m_pat -> m_steps)) / float(width() - CLIP_BORDER_WIDTH*2); + float(m_clp -> m_steps)) / float(width() - CLIP_BORDER_WIDTH*2); int step = int( tmp ); - if( step >= m_pat->m_steps ) + if( step >= m_clp->m_steps ) { return; } - Note * n = m_pat->noteAtStep( step ); + Note * n = m_clp->noteAtStep( step ); if(!n && we->angleDelta().y() > 0) { - n = m_pat->addStepNote( step ); + n = m_clp->addStepNote( step ); n->setVolume( 0 ); } if( n != NULL ) @@ -291,7 +291,7 @@ void PatternView::wheelEvent(QWheelEvent * we) Engine::getSong()->setModified(); update(); - if( gui->pianoRoll()->currentPattern() == m_pat ) + if( gui->pianoRoll()->currentMidiClip() == m_clp ) { gui->pianoRoll()->update(); } @@ -310,7 +310,7 @@ static int computeNoteRange(int minKey, int maxKey) return (maxKey - minKey) + 1; } -void PatternView::paintEvent( QPaintEvent * ) +void MidiClipView::paintEvent( QPaintEvent * ) { QPainter painter( this ); @@ -330,14 +330,14 @@ void PatternView::paintEvent( QPaintEvent * ) QPainter p( &m_paintPixmap ); QColor c; - bool const muted = m_pat->getTrack()->isMuted() || m_pat->isMuted(); - bool current = gui->pianoRoll()->currentPattern() == m_pat; - bool beatPattern = m_pat->m_patternType == Pattern::BeatPattern; + bool const muted = m_clp->getTrack()->isMuted() || m_clp->isMuted(); + bool current = gui->pianoRoll()->currentMidiClip() == m_clp; + bool beatClip = m_clp->m_clipType == MidiClip::BeatClip; - if( beatPattern ) + if( beatClip ) { - // Do not paint BBClips how we paint pattern Clips - c = BBPatternBackground(); + // Do not paint BBClips how we paint MidiClips + c = BBClipBackground(); } else { @@ -346,10 +346,10 @@ void PatternView::paintEvent( QPaintEvent * ) // invert the gradient for the background in the B&B editor QLinearGradient lingrad( 0, 0, 0, height() ); - lingrad.setColorAt( beatPattern ? 0 : 1, c.darker( 300 ) ); - lingrad.setColorAt( beatPattern ? 1 : 0, c ); + lingrad.setColorAt( beatClip ? 0 : 1, c.darker( 300 ) ); + lingrad.setColorAt( beatClip ? 1 : 0, c ); - // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds + // paint a black rectangle under the clip to prevent glitches with transparent backgrounds p.fillRect( rect(), QColor( 0, 0, 0 ) ); if( gradient() ) @@ -363,8 +363,8 @@ void PatternView::paintEvent( QPaintEvent * ) // Check whether we will paint a text box and compute its potential height // This is needed so we can paint the notes underneath it. - bool const drawName = !m_pat->name().isEmpty(); - bool const drawTextBox = !beatPattern && drawName; + bool const drawName = !m_clp->name().isEmpty(); + bool const drawTextBox = !beatClip && drawName; // TODO Warning! This might cause problems if ClipView::paintTextLabel changes int textBoxHeight = 0; @@ -381,20 +381,20 @@ void PatternView::paintEvent( QPaintEvent * ) // Compute pixels per bar const int baseWidth = fixedClips() ? parentWidget()->width() - 2 * CLIP_BORDER_WIDTH : width() - CLIP_BORDER_WIDTH; - const float pixelsPerBar = baseWidth / (float) m_pat->length().getBar(); + const float pixelsPerBar = baseWidth / (float) m_clp->length().getBar(); // Length of one bar/beat in the [0,1] x [0,1] coordinate system - const float barLength = 1. / m_pat->length().getBar(); + const float barLength = 1. / m_clp->length().getBar(); const float tickLength = barLength / TimePos::ticksPerBar(); const int x_base = CLIP_BORDER_WIDTH; bool displayBB = fixedClips() || (pixelsPerBar >= 96 && m_legacySEBB); - // melody pattern paint event - NoteVector const & noteCollection = m_pat->m_notes; - if( m_pat->m_patternType == Pattern::MelodyPattern && !noteCollection.empty() ) + // melody clip paint event + NoteVector const & noteCollection = m_clp->m_notes; + if( m_clp->m_clipType == MidiClip::MelodyClip && !noteCollection.empty() ) { - // Compute the minimum and maximum key in the pattern + // Compute the minimum and maximum key in the clip // so that we know how much there is to draw. int maxKey = std::numeric_limits::min(); int minKey = std::numeric_limits::max(); @@ -457,7 +457,7 @@ void PatternView::paintEvent( QPaintEvent * ) // set colour based on mute status QColor noteFillColor = muted ? getMutedNoteFillColor() : getNoteFillColor(); QColor noteBorderColor = muted ? getMutedNoteBorderColor() - : ( m_pat->hasColor() ? c.lighter( 200 ) : getNoteBorderColor() ); + : ( m_clp->hasColor() ? c.lighter( 200 ) : getNoteBorderColor() ); bool const drawAsLines = height() < 64; if (drawAsLines) @@ -478,7 +478,7 @@ void PatternView::paintEvent( QPaintEvent * ) float const noteHeight = 1. / adjustedNoteRange; - // scan through all the notes and draw them on the pattern + // scan through all the notes and draw them on the clip for (Note const * currentNote : noteCollection) { // Map to 0, 1, 2, ... @@ -505,18 +505,18 @@ void PatternView::paintEvent( QPaintEvent * ) p.restore(); } - // beat pattern paint event - else if( beatPattern && displayBB ) + // beat clip paint event + else if( beatClip && displayBB ) { QPixmap stepon0; QPixmap stepon200; QPixmap stepoff; QPixmap stepoffl; const int steps = qMax( 1, - m_pat->m_steps ); + m_clp->m_steps ); const int w = width() - 2 * CLIP_BORDER_WIDTH; - // scale step graphics to fit the beat pattern length + // scale step graphics to fit the beat clip length stepon0 = s_stepBtnOn0->scaled( w / steps, s_stepBtnOn0->height(), Qt::IgnoreAspectRatio, @@ -534,9 +534,9 @@ void PatternView::paintEvent( QPaintEvent * ) Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); - for( int it = 0; it < steps; it++ ) // go through all the steps in the beat pattern + for( int it = 0; it < steps; it++ ) // go through all the steps in the beat clip { - Note * n = m_pat->noteAtStep( it ); + Note * n = m_clp->noteAtStep( it ); // figure out x and y coordinates for step graphic const int x = CLIP_BORDER_WIDTH + static_cast( it * w / steps ); @@ -561,7 +561,7 @@ void PatternView::paintEvent( QPaintEvent * ) } } // end for loop - // draw a transparent rectangle over muted patterns + // draw a transparent rectangle over muted clips if ( muted ) { p.setBrush( mutedBackgroundColor() ); @@ -574,7 +574,7 @@ void PatternView::paintEvent( QPaintEvent * ) const int lineSize = 3; p.setPen( c.darker( 200 ) ); - for( bar_t t = 1; t < m_pat->length().getBar(); ++t ) + for( bar_t t = 1; t < m_clp->length().getBar(); ++t ) { p.drawLine( x_base + static_cast( pixelsPerBar * t ) - 1, CLIP_BORDER_WIDTH, x_base + static_cast( @@ -585,13 +585,13 @@ void PatternView::paintEvent( QPaintEvent * ) rect().bottom() - CLIP_BORDER_WIDTH ); } - // pattern name + // clip name if (drawTextBox) { - paintTextLabel(m_pat->name(), p); + paintTextLabel(m_clp->name(), p); } - if( !( fixedClips() && beatPattern ) ) + if( !( fixedClips() && beatClip ) ) { // inner border p.setPen( c.lighter( current ? 160 : 130 ) ); @@ -603,8 +603,8 @@ void PatternView::paintEvent( QPaintEvent * ) p.drawRect( 0, 0, rect().right(), rect().bottom() ); } - // draw the 'muted' pixmap only if the pattern was manually muted - if( m_pat->isMuted() ) + // draw the 'muted' pixmap only if the clip was manually muted + if( m_clp->isMuted() ) { const int spacing = CLIP_BORDER_WIDTH; const int size = 14; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 67c490a8627..c9b80d27d3c 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1529,7 +1529,7 @@ void AutomationEditor::play() if( Engine::getSong()->playMode() != Song::Mode_PlayPattern ) { Engine::getSong()->stop(); - Engine::getSong()->playPattern( gui->pianoRoll()->currentPattern() ); + Engine::getSong()->playPattern( gui->pianoRoll()->currentMidiClip() ); } else if( Engine::getSong()->isStopped() == false ) { @@ -1537,7 +1537,7 @@ void AutomationEditor::play() } else { - Engine::getSong()->playPattern( gui->pianoRoll()->currentPattern() ); + Engine::getSong()->playPattern( gui->pianoRoll()->currentMidiClip() ); } } else if( inBBEditor() ) diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index c4b76dc1948..3b0066c1f06 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -37,7 +37,7 @@ #include "Song.h" #include "StringPairDrag.h" -#include "Pattern.h" +#include "MidiClip.h" @@ -196,7 +196,7 @@ void BBTrackContainerView::removeSteps() { if( ( *it )->type() == Track::InstrumentTrack ) { - Pattern* p = static_cast( ( *it )->getClip( m_bbtc->currentBB() ) ); + MidiClip* p = static_cast( ( *it )->getClip( m_bbtc->currentBB() ) ); p->removeSteps(); } } @@ -304,7 +304,7 @@ void BBTrackContainerView::makeSteps( bool clone ) { if( ( *it )->type() == Track::InstrumentTrack ) { - Pattern* p = static_cast( ( *it )->getClip( m_bbtc->currentBB() ) ); + MidiClip* p = static_cast( ( *it )->getClip( m_bbtc->currentBB() ) ); if( clone ) { p->cloneSteps(); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 9196290634f..93ba41bd4d4 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -63,7 +63,7 @@ #include "gui_templates.h" #include "InstrumentTrack.h" #include "MainWindow.h" -#include "Pattern.h" +#include "MidiClip.h" #include "SongEditor.h" #include "StepRecorderWidget.h" #include "TextFloat.h" @@ -157,7 +157,7 @@ PianoRoll::PianoRoll() : m_noteLenModel(), m_scaleModel(), m_chordModel(), - m_pattern( NULL ), + m_clip( NULL ), m_currentPosition(), m_recording( false ), m_currentNote( NULL ), @@ -457,7 +457,7 @@ void PianoRoll::reset() { m_lastNoteVolume = DefaultVolume; m_lastNotePanning = DefaultPanning; - clearGhostPattern(); + clearGhostClip(); } void PianoRoll::showTextFloat(const QString &text, const QPoint &pos, int timeout) @@ -620,18 +620,18 @@ PianoRoll::~PianoRoll() } -void PianoRoll::setGhostPattern( Pattern* newPattern ) +void PianoRoll::setGhostClip( MidiClip* newMidiClip ) { // Expects a pointer to a pattern or nullptr. m_ghostNotes.clear(); - if( newPattern != nullptr ) + if( newMidiClip != nullptr ) { - for( Note *note : newPattern->notes() ) + for( Note *note : newMidiClip->notes() ) { Note * new_note = new Note( note->length(), note->pos(), note->key() ); m_ghostNotes.push_back( new_note ); } - emit ghostPatternSet( true ); + emit ghostClipSet( true ); } } @@ -650,22 +650,22 @@ void PianoRoll::loadGhostNotes( const QDomElement & de ) m_ghostNotes.push_back( n ); node = node.nextSibling(); } - emit ghostPatternSet( true ); + emit ghostClipSet( true ); } } -void PianoRoll::clearGhostPattern() +void PianoRoll::clearGhostClip() { - setGhostPattern( nullptr ); - emit ghostPatternSet( false ); + setGhostClip( nullptr ); + emit ghostClipSet( false ); update(); } void PianoRoll::glueNotes() { - if (hasValidPattern()) + if (hasValidMidiClip()) { NoteVector selectedNotes = getSelectedNotes(); if (selectedNotes.empty()) @@ -678,7 +678,7 @@ void PianoRoll::glueNotes() } // Make undo possible - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); // Sort notes on key and then pos. std::sort(selectedNotes.begin(), selectedNotes.end(), @@ -722,7 +722,7 @@ void PianoRoll::glueNotes() // Remove old notes for (int i = 0; i < noteToRemove.count(); ++i) { - m_pattern->removeNote(noteToRemove[i]); + m_clip->removeNote(noteToRemove[i]); } update(); @@ -731,11 +731,11 @@ void PianoRoll::glueNotes() void PianoRoll::fitNoteLengths(bool fill) { - if (!hasValidPattern()) { return; } - m_pattern->addJournalCheckPoint(); + if (!hasValidMidiClip()) { return; } + m_clip->addJournalCheckPoint(); // Reference notes - NoteVector refNotes = m_pattern->notes(); + NoteVector refNotes = m_clip->notes(); std::sort(refNotes.begin(), refNotes.end(), Note::lessThan); // Notes to edit @@ -786,13 +786,13 @@ void PianoRoll::fitNoteLengths(bool fill) void PianoRoll::constrainNoteLengths(bool constrainMax) { - if (!hasValidPattern()) { return; } - m_pattern->addJournalCheckPoint(); + if (!hasValidMidiClip()) { return; } + m_clip->addJournalCheckPoint(); NoteVector notes = getSelectedNotes(); if (notes.empty()) { - notes = m_pattern->notes(); + notes = m_clip->notes(); } TimePos bound = m_lenOfNewNotes; // will be length of last note @@ -836,11 +836,11 @@ void PianoRoll::loadMarkedSemiTones(const QDomElement & de) } -void PianoRoll::setCurrentPattern( Pattern* newPattern ) +void PianoRoll::setCurrentMidiClip( MidiClip* newMidiClip ) { - if( hasValidPattern() ) + if( hasValidMidiClip() ) { - m_pattern->instrumentTrack()->disconnect( this ); + m_clip->instrumentTrack()->disconnect( this ); } // force the song-editor to stop playing if it played pattern before @@ -856,19 +856,19 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) } // set new data - m_pattern = newPattern; + m_clip = newMidiClip; m_currentPosition = 0; m_currentNote = NULL; m_startKey = INITIAL_START_KEY; - m_stepRecorder.setCurrentPattern(newPattern); + m_stepRecorder.setCurrentMidiClip(newMidiClip); - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { //resizeEvent( NULL ); update(); - emit currentPatternChanged(); + emit currentMidiClipChanged(); return; } @@ -877,7 +877,7 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) // determine the central key so that we can scroll to it int central_key = 0; int total_notes = 0; - for( const Note *note : m_pattern->notes() ) + for( const Note *note : m_clip->notes() ) { if( note->length() > 0 ) { @@ -897,26 +897,26 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) resizeEvent( NULL ); // make sure to always get informed about the pattern being destroyed - connect( m_pattern, SIGNAL( destroyedPattern( Pattern* ) ), this, SLOT( hidePattern( Pattern* ) ) ); + connect( m_clip, SIGNAL( destroyedMidiClip( MidiClip* ) ), this, SLOT( hideMidiClip( MidiClip* ) ) ); - connect( m_pattern->instrumentTrack(), SIGNAL( midiNoteOn( const Note& ) ), this, SLOT( startRecordNote( const Note& ) ) ); - connect( m_pattern->instrumentTrack(), SIGNAL( midiNoteOff( const Note& ) ), this, SLOT( finishRecordNote( const Note& ) ) ); - connect( m_pattern->instrumentTrack()->pianoModel(), SIGNAL( dataChanged() ), this, SLOT( update() ) ); + connect( m_clip->instrumentTrack(), SIGNAL( midiNoteOn( const Note& ) ), this, SLOT( startRecordNote( const Note& ) ) ); + connect( m_clip->instrumentTrack(), SIGNAL( midiNoteOff( const Note& ) ), this, SLOT( finishRecordNote( const Note& ) ) ); + connect( m_clip->instrumentTrack()->pianoModel(), SIGNAL( dataChanged() ), this, SLOT( update() ) ); - connect(m_pattern->instrumentTrack()->firstKeyModel(), SIGNAL(dataChanged()), this, SLOT(update())); - connect(m_pattern->instrumentTrack()->lastKeyModel(), SIGNAL(dataChanged()), this, SLOT(update())); + connect(m_clip->instrumentTrack()->firstKeyModel(), SIGNAL(dataChanged()), this, SLOT(update())); + connect(m_clip->instrumentTrack()->lastKeyModel(), SIGNAL(dataChanged()), this, SLOT(update())); update(); - emit currentPatternChanged(); + emit currentMidiClipChanged(); } -void PianoRoll::hidePattern( Pattern* pattern ) +void PianoRoll::hideMidiClip( MidiClip* pattern ) { - if( m_pattern == pattern ) + if( m_clip == pattern ) { - setCurrentPattern( NULL ); + setCurrentMidiClip( NULL ); } } @@ -1164,9 +1164,9 @@ void PianoRoll::removeSelection() void PianoRoll::clearSelectedNotes() { - if( m_pattern != NULL ) + if( m_clip != NULL ) { - for( Note *note : m_pattern->notes() ) + for( Note *note : m_clip->notes() ) { note->setSelected( false ); } @@ -1177,21 +1177,21 @@ void PianoRoll::clearSelectedNotes() void PianoRoll::shiftSemiTone(int amount) //Shift notes by amount semitones { - if (!hasValidPattern()) { return; } + if (!hasValidMidiClip()) { return; } auto selectedNotes = getSelectedNotes(); //If no notes are selected, shift all of them, otherwise shift selection - if (selectedNotes.empty()) { return shiftSemiTone(m_pattern->notes(), amount); } + if (selectedNotes.empty()) { return shiftSemiTone(m_clip->notes(), amount); } else { return shiftSemiTone(selectedNotes, amount); } } void PianoRoll::shiftSemiTone(NoteVector notes, int amount) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); for (Note *note : notes) { note->setKey( note->key() + amount ); } - m_pattern->rearrangeAllNotes(); - m_pattern->dataChanged(); + m_clip->rearrangeAllNotes(); + m_clip->dataChanged(); //We modified the song update(); gui->songEditor()->update(); @@ -1202,17 +1202,17 @@ void PianoRoll::shiftSemiTone(NoteVector notes, int amount) void PianoRoll::shiftPos(int amount) //Shift notes pos by amount { - if (!hasValidPattern()) { return; } + if (!hasValidMidiClip()) { return; } auto selectedNotes = getSelectedNotes(); //If no notes are selected, shift all of them, otherwise shift selection - if (selectedNotes.empty()) { return shiftPos(m_pattern->notes(), amount); } + if (selectedNotes.empty()) { return shiftPos(m_clip->notes(), amount); } else { return shiftPos(selectedNotes, amount); } } void PianoRoll::shiftPos(NoteVector notes, int amount) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); auto leftMostPos = notes.first()->pos(); //Limit leftwards shifts to prevent moving left of pattern start auto shiftAmount = (leftMostPos > -amount) ? amount : -leftMostPos; @@ -1220,9 +1220,9 @@ void PianoRoll::shiftPos(NoteVector notes, int amount) for (Note *note : notes) { note->setPos( note->pos() + shiftAmount ); } - m_pattern->rearrangeAllNotes(); - m_pattern->updateLength(); - m_pattern->dataChanged(); + m_clip->rearrangeAllNotes(); + m_clip->updateLength(); + m_clip->dataChanged(); // we modified the song update(); gui->songEditor()->update(); @@ -1233,7 +1233,7 @@ void PianoRoll::shiftPos(NoteVector notes, int amount) bool PianoRoll::isSelection() const // are any notes selected? { - for( const Note *note : m_pattern->notes() ) + for( const Note *note : m_clip->notes() ) { if( note->selected() ) { @@ -1266,13 +1266,13 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) } } - if( hasValidPattern() && ke->modifiers() == Qt::NoModifier ) + if( hasValidMidiClip() && ke->modifiers() == Qt::NoModifier ) { const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave; if (!ke->isAutoRepeat() && key_num > -1) { - m_pattern->instrumentTrack()->pianoModel()->handleKeyPress(key_num); + m_clip->instrumentTrack()->pianoModel()->handleKeyPress(key_num); // if a chord is set, play all chord notes (simulate click on all): playChordNotes(key_num); ke->accept(); @@ -1289,7 +1289,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) { // shift selection up an octave // if nothing selected, shift _everything_ - if (hasValidPattern()) + if (hasValidMidiClip()) { shiftSemiTone( 12 * direction ); } @@ -1297,7 +1297,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) else if((ke->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) { // Move selected notes up by one semitone - if (hasValidPattern()) + if (hasValidMidiClip()) { shiftSemiTone( 1 * direction ); } @@ -1333,7 +1333,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) if( ke->modifiers() & Qt::ControlModifier && m_action == ActionNone ) { // Move selected notes by one bar to the left - if (hasValidPattern()) + if (hasValidMidiClip()) { shiftPos( direction * TimePos::ticksPerBar() ); } @@ -1341,7 +1341,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) else if( ke->modifiers() & Qt::ShiftModifier && m_action == ActionNone) { // move notes - if (hasValidPattern()) + if (hasValidMidiClip()) { bool quantized = ! ( ke->modifiers() & Qt::AltModifier ); int amt = quantized ? quantization() : 1; @@ -1351,13 +1351,13 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) else if( ke->modifiers() & Qt::AltModifier) { // switch to editing a pattern adjacent to this one in the song editor - if (hasValidPattern()) + if (hasValidMidiClip()) { - Pattern * p = direction > 0 ? m_pattern->nextPattern() - : m_pattern->previousPattern(); + MidiClip * p = direction > 0 ? m_clip->nextMidiClip() + : m_clip->previousMidiClip(); if(p != NULL) { - setCurrentPattern(p); + setCurrentMidiClip(p); } } } @@ -1489,12 +1489,12 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) void PianoRoll::keyReleaseEvent(QKeyEvent* ke ) { - if( hasValidPattern() && ke->modifiers() == Qt::NoModifier ) + if( hasValidMidiClip() && ke->modifiers() == Qt::NoModifier ) { const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave; if (!ke->isAutoRepeat() && key_num > -1) { - m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease(key_num); + m_clip->instrumentTrack()->pianoModel()->handleKeyRelease(key_num); // if a chord is set, simulate click release on all chord notes pauseChordNotes(key_num); ke->accept(); @@ -1516,7 +1516,7 @@ void PianoRoll::keyReleaseEvent(QKeyEvent* ke ) // update after undo/redo case Qt::Key_Z: case Qt::Key_R: - if( hasValidPattern() && ke->modifiers() == Qt::ControlModifier ) + if( hasValidMidiClip() && ke->modifiers() == Qt::ControlModifier ) { update(); } @@ -1591,7 +1591,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { m_startedWithShift = me->modifiers() & Qt::ShiftModifier; - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } @@ -1609,7 +1609,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) updateKnifePos(me); // Call splitNotes for the note - m_pattern->splitNotes(n, TimePos(m_knifeTickPos)); + m_clip->splitNotes(n, TimePos(m_knifeTickPos)); } update(); @@ -1679,7 +1679,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) // get note-vector of current pattern - const NoteVector & notes = m_pattern->notes(); + const NoteVector & notes = m_clip->notes(); // will be our iterator in the following loop NoteVector::ConstIterator it = notes.begin()+notes.size()-1; @@ -1717,7 +1717,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) // area if( edit_note ) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); // scribble note edit changes mouseMoveEvent( me ); return; @@ -1735,7 +1735,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) if( it == notes.begin()-1 ) { is_new_note = true; - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); // then set new note @@ -1752,7 +1752,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) new_note.setSelected( true ); new_note.setPanning( m_lastNotePanning ); new_note.setVolume( m_lastNoteVolume ); - created_new_note = m_pattern->addNote( new_note ); + created_new_note = m_clip->addNote( new_note ); const InstrumentFunctionNoteStacking::Chord & chord = InstrumentFunctionNoteStacking::ChordTable::getInstance() .getChordByName( m_chordModel.currentText() ); @@ -1772,7 +1772,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) new_note.setSelected( true ); new_note.setPanning( m_lastNotePanning ); new_note.setVolume( m_lastNoteVolume ); - m_pattern->addNote( new_note ); + m_clip->addNote( new_note ); } } @@ -1829,7 +1829,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) m_currentNote->endPos() * m_ppb / TimePos::ticksPerBar() - RESIZE_AREA_WIDTH && m_currentNote->length() > 0 ) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); // then resize the note m_action = ActionResizeNote; @@ -1857,7 +1857,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { if( ! created_new_note ) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); } // otherwise move it @@ -1871,7 +1871,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { for (Note *note: selectedNotes) { - Note *newNote = m_pattern->addNote(*note, false); + Note *newNote = m_clip->addNote(*note, false); newNote->setSelected(false); } @@ -1898,8 +1898,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) m_mouseDownRight = true; if( it != notes.begin()-1 ) { - m_pattern->addJournalCheckPoint(); - m_pattern->removeNote( *it ); + m_clip->addJournalCheckPoint(); + m_clip->removeNote( *it ); Engine::getSong()->setModified(); } } @@ -1939,7 +1939,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { // left click - play the note int v = ((float) x) / ((float) m_whiteKeyWidth) * MidiDefaultVelocity; - m_pattern->instrumentTrack()->pianoModel()->handleKeyPress(key_num, v); + m_clip->instrumentTrack()->pianoModel()->handleKeyPress(key_num, v); // if a chord is set, play the chords notes as well: playChordNotes(key_num, v); } @@ -1970,7 +1970,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me ) { - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } @@ -1991,7 +1991,7 @@ void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me ) // go through notes to figure out which one we want to change bool altPressed = me->modifiers() & Qt::AltModifier; NoteVector nv; - for ( Note * i : m_pattern->notes() ) + for ( Note * i : m_clip->notes() ) { if( i->withinRange( ticks_start, ticks_end ) || ( i->selected() && !altPressed ) ) { @@ -2047,9 +2047,9 @@ void PianoRoll::testPlayNote( Note * n ) { n->setIsPlaying( true ); - const int baseVelocity = m_pattern->instrumentTrack()->midiPort()->baseVelocity(); + const int baseVelocity = m_clip->instrumentTrack()->midiPort()->baseVelocity(); - m_pattern->instrumentTrack()->pianoModel()->handleKeyPress(n->key(), n->midiVelocity(baseVelocity)); + m_clip->instrumentTrack()->pianoModel()->handleKeyPress(n->key(), n->midiVelocity(baseVelocity)); // if a chord is set, play the chords notes as well: playChordNotes(n->key(), n->midiVelocity(baseVelocity)); @@ -2058,7 +2058,7 @@ void PianoRoll::testPlayNote( Note * n ) event.setMetaEvent( MidiNotePanning ); - m_pattern->instrumentTrack()->processInEvent( event, 0 ); + m_clip->instrumentTrack()->processInEvent( event, 0 ); } } @@ -2067,14 +2067,14 @@ void PianoRoll::testPlayNote( Note * n ) void PianoRoll::pauseTestNotes( bool pause ) { - for (Note *note : m_pattern->notes()) + for (Note *note : m_clip->notes()) { if( note->isPlaying() ) { if( pause ) { // stop note - m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() ); + m_clip->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() ); // if a chord was set, stop the chords notes as well: pauseChordNotes(note->key()); @@ -2092,7 +2092,7 @@ void PianoRoll::pauseTestNotes( bool pause ) void PianoRoll::playChordNotes(int key, int velocity) { // if a chord is set, play the chords notes beside the base note. - Piano *pianoModel = m_pattern->instrumentTrack()->pianoModel(); + Piano *pianoModel = m_clip->instrumentTrack()->pianoModel(); const InstrumentFunctionNoteStacking::Chord & chord = InstrumentFunctionNoteStacking::ChordTable::getInstance().getChordByName( m_chordModel.currentText()); @@ -2108,7 +2108,7 @@ void PianoRoll::playChordNotes(int key, int velocity) void PianoRoll::pauseChordNotes(int key) { // if a chord was set, stop the chords notes beside the base note. - Piano *pianoModel = m_pattern->instrumentTrack()->pianoModel(); + Piano *pianoModel = m_clip->instrumentTrack()->pianoModel(); const InstrumentFunctionNoteStacking::Chord & chord = InstrumentFunctionNoteStacking::ChordTable::getInstance().getChordByName( m_chordModel.currentText()); @@ -2144,7 +2144,7 @@ void PianoRoll::cancelKnifeAction() void PianoRoll::testPlayKey( int key, int velocity, int pan ) { - Piano *pianoModel = m_pattern->instrumentTrack()->pianoModel(); + Piano *pianoModel = m_clip->instrumentTrack()->pianoModel(); // turn off old key pianoModel->handleKeyRelease( m_lastKey ); // if a chord was set, stop the chords notes as well @@ -2189,9 +2189,9 @@ void PianoRoll::computeSelectedNotes(bool shift) } //int y_base = noteEditTop() - 1; - if( hasValidPattern() ) + if( hasValidMidiClip() ) { - for( Note *note : m_pattern->notes() ) + for( Note *note : m_clip->notes() ) { // make a new selection unless they're holding shift if( ! shift ) @@ -2262,7 +2262,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) // we moved one or more notes so they have to be // moved properly according to new starting- // time in the note-array of pattern - m_pattern->rearrangeAllNotes(); + m_clip->rearrangeAllNotes(); } @@ -2283,14 +2283,14 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) mustRepaint = true; } - if( hasValidPattern() ) + if( hasValidMidiClip() ) { // turn off all notes that are playing - for ( Note *note : m_pattern->notes() ) + for ( Note *note : m_clip->notes() ) { if( note->isPlaying() ) { - m_pattern->instrumentTrack()->pianoModel()-> + m_clip->instrumentTrack()->pianoModel()-> handleKeyRelease( note->key() ); pauseChordNotes(note->key()); note->setIsPlaying( false ); @@ -2298,7 +2298,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) } // stop playing keys that we let go of - m_pattern->instrumentTrack()->pianoModel()-> + m_clip->instrumentTrack()->pianoModel()-> handleKeyRelease( m_lastKey ); pauseChordNotes(m_lastKey); } @@ -2326,7 +2326,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) void PianoRoll::mouseMoveEvent( QMouseEvent * me ) { - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { update(); return; @@ -2438,7 +2438,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) TimePos::ticksPerBar() / m_ppb + m_currentPosition; // get note-vector of current pattern - const NoteVector & notes = m_pattern->notes(); + const NoteVector & notes = m_clip->notes(); // determine what volume/panning to set note to // if middle-click, set to defaults @@ -2497,22 +2497,22 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) { n->setVolume( vol ); - const int baseVelocity = m_pattern->instrumentTrack()->midiPort()->baseVelocity(); + const int baseVelocity = m_clip->instrumentTrack()->midiPort()->baseVelocity(); - m_pattern->instrumentTrack()->processInEvent( MidiEvent( MidiKeyPressure, -1, n->key(), n->midiVelocity( baseVelocity ) ) ); + m_clip->instrumentTrack()->processInEvent( MidiEvent( MidiKeyPressure, -1, n->key(), n->midiVelocity( baseVelocity ) ) ); } else if( m_noteEditMode == NoteEditPanning ) { n->setPanning( pan ); MidiEvent evt( MidiMetaEvent, -1, n->key(), panningToMidi( pan ) ); evt.setMetaEvent( MidiNotePanning ); - m_pattern->instrumentTrack()->processInEvent( evt ); + m_clip->instrumentTrack()->processInEvent( evt ); } } else if( n->isPlaying() && !isSelection() ) { // mouse not over this note, stop playing it. - m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( n->key() ); + m_clip->instrumentTrack()->pianoModel()->handleKeyRelease( n->key() ); pauseChordNotes(n->key()); n->setIsPlaying( false ); @@ -2523,7 +2523,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) } // Emit pattern has changed - m_pattern->dataChanged(); + m_clip->dataChanged(); } else if( me->buttons() == Qt::NoButton && m_editMode == ModeDraw ) @@ -2535,7 +2535,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) m_ppb + m_currentPosition; // get note-vector of current pattern - const NoteVector & notes = m_pattern->notes(); + const NoteVector & notes = m_clip->notes(); // will be our iterator in the following loop NoteVector::ConstIterator it = notes.begin()+notes.size()-1; @@ -2612,7 +2612,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) // get note-vector of current pattern - const NoteVector & notes = m_pattern->notes(); + const NoteVector & notes = m_clip->notes(); // will be our iterator in the following loop NoteVector::ConstIterator it = notes.begin(); @@ -2644,7 +2644,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) ) { // delete this note - m_pattern->removeNote( note ); + m_clip->removeNote( note ); Engine::getSong()->setModified(); } else @@ -2781,7 +2781,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) off_key -= m_mouseDownKey - m_startKey; // get note-vector of current pattern - const NoteVector & notes = m_pattern->notes(); + const NoteVector & notes = m_clip->notes(); if (m_action == ActionMoveNote) { @@ -2982,8 +2982,8 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) } } - m_pattern->updateLength(); - m_pattern->dataChanged(); + m_clip->updateLength(); + m_clip->dataChanged(); Engine::getSong()->setModified(); } @@ -3026,7 +3026,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // - note edit area resize bar // - cursor mode icon - if (hasValidPattern()) + if (hasValidMidiClip()) { int pianoAreaHeight, partialKeyVisible, topKey, topNote; pianoAreaHeight = keyAreaBottom() - keyAreaTop(); @@ -3162,9 +3162,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) const int key, const int yb) { - const bool mapped = m_pattern->instrumentTrack()->firstKeyModel()->value() <= key && - m_pattern->instrumentTrack()->lastKeyModel()->value() >= key; - const bool pressed = m_pattern->instrumentTrack()->pianoModel()->isKeyPressed(key); + const bool mapped = m_clip->instrumentTrack()->firstKeyModel()->value() <= key && + m_clip->instrumentTrack()->lastKeyModel()->value() >= key; + const bool pressed = m_clip->instrumentTrack()->pianoModel()->isKeyPressed(key); const int keyCode = key % KeysPerOctave; const int yt = yb - gridCorrection(key); const int kh = keyHeight(key); @@ -3371,7 +3371,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } int y_base = keyAreaBottom() - 1; - if( hasValidPattern() ) + if( hasValidMidiClip() ) { p.setClipRect( m_whiteKeyWidth, @@ -3432,7 +3432,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } // -- End ghost pattern - for( const Note *note : m_pattern->notes() ) + for( const Note *note : m_clip->notes() ) { int len_ticks = note->length(); @@ -3622,7 +3622,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.drawRect(x + m_whiteKeyWidth, y, w, h); // TODO: Get this out of paint event - int l = ( hasValidPattern() )? (int) m_pattern->length() : 0; + int l = ( hasValidMidiClip() )? (int) m_clip->length() : 0; // reset scroll-range if( m_leftRightScroll->maximum() != l ) @@ -3639,7 +3639,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) currentKeyCol.setAlpha( 64 ); // horizontal line for the key under the cursor - if(hasValidPattern() && gui->pianoRoll()->hasFocus()) + if(hasValidMidiClip() && gui->pianoRoll()->hasFocus()) { int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() ); p.fillRect( 10, keyAreaBottom() + 3 - m_keyLineHeight * @@ -3732,7 +3732,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) if(position(we).x() > noteEditLeft() && position(we).x() < noteEditRight() && position(we).y() > noteEditTop() && position(we).y() < noteEditBottom()) { - if (!hasValidPattern()) {return;} + if (!hasValidMidiClip()) {return;} // get values for going through notes int pixel_range = 8; int x = position(we).x() - m_whiteKeyWidth; @@ -3745,7 +3745,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) bool altPressed = we->modifiers() & Qt::AltModifier; // go through notes to figure out which one we want to change NoteVector nv; - for ( Note * i : m_pattern->notes() ) + for ( Note * i : m_clip->notes() ) { if( i->withinRange( ticks_start, ticks_end ) || ( i->selected() && !altPressed ) ) { @@ -3874,12 +3874,12 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) void PianoRoll::focusOutEvent( QFocusEvent * ) { - if( hasValidPattern() ) + if( hasValidMidiClip() ) { for( int i = 0; i < NumKeys; ++i ) { - m_pattern->instrumentTrack()->pianoModel()->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, -1, i, 0 ) ); - m_pattern->instrumentTrack()->pianoModel()->setKeyState( i, false ); + m_clip->instrumentTrack()->pianoModel()->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, -1, i, 0 ) ); + m_clip->instrumentTrack()->pianoModel()->setKeyState( i, false ); } } if (m_editMode == ModeEditKnife) { @@ -3893,10 +3893,10 @@ void PianoRoll::focusOutEvent( QFocusEvent * ) void PianoRoll::focusInEvent( QFocusEvent * ev ) { - if ( hasValidPattern() ) + if ( hasValidMidiClip() ) { // Assign midi device - m_pattern->instrumentTrack()->autoAssignMidiDevice(true); + m_clip->instrumentTrack()->autoAssignMidiDevice(true); } QWidget::focusInEvent(ev); } @@ -3930,7 +3930,7 @@ QList PianoRoll::getAllOctavesForKey( int keyToMirror ) const Song::PlayModes PianoRoll::desiredPlayModeForAccompany() const { - if( m_pattern->getTrack()->trackContainer() == + if( m_clip->getTrack()->trackContainer() == Engine::getBBTrackContainer() ) { return Song::Mode_PlayBB; @@ -3943,14 +3943,14 @@ Song::PlayModes PianoRoll::desiredPlayModeForAccompany() const void PianoRoll::play() { - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } if( Engine::getSong()->playMode() != Song::Mode_PlayPattern ) { - Engine::getSong()->playPattern( m_pattern ); + Engine::getSong()->playPattern( m_clip ); } else { @@ -3967,15 +3967,15 @@ void PianoRoll::record() { stop(); } - if( m_recording || ! hasValidPattern() ) + if( m_recording || ! hasValidMidiClip() ) { return; } - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); m_recording = true; - Engine::getSong()->playPattern( m_pattern, false ); + Engine::getSong()->playPattern( m_clip, false ); } @@ -3987,15 +3987,15 @@ void PianoRoll::recordAccompany() { stop(); } - if( m_recording || ! hasValidPattern() ) + if( m_recording || ! hasValidMidiClip() ) { return; } - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); m_recording = true; - if( m_pattern->getTrack()->trackContainer() == Engine::getSong() ) + if( m_clip->getTrack()->trackContainer() == Engine::getSong() ) { Engine::getSong()->playSong(); } @@ -4016,7 +4016,7 @@ bool PianoRoll::toggleStepRecording() } else { - if(hasValidPattern()) + if(hasValidMidiClip()) { if(Engine::getSong()->isPlaying()) { @@ -4049,7 +4049,7 @@ void PianoRoll::stop() void PianoRoll::startRecordNote(const Note & n ) { - if(hasValidPattern()) + if(hasValidMidiClip()) { if( m_recording && Engine::getSong()->isPlaying() && @@ -4059,7 +4059,7 @@ void PianoRoll::startRecordNote(const Note & n ) TimePos sub; if( Engine::getSong()->playMode() == Song::Mode_PlaySong ) { - sub = m_pattern->startPosition(); + sub = m_clip->startPosition(); } Note n1( 1, Engine::getSong()->getPlayPos( Engine::getSong()->playMode() ) - sub, @@ -4081,7 +4081,7 @@ void PianoRoll::startRecordNote(const Note & n ) void PianoRoll::finishRecordNote(const Note & n ) { - if(hasValidPattern()) + if(hasValidMidiClip()) { if( m_recording && Engine::getSong()->isPlaying() && @@ -4099,7 +4099,7 @@ void PianoRoll::finishRecordNote(const Note & n ) it->key(), it->getVolume(), it->getPanning() ); n1.quantizeLength( quantization() ); - m_pattern->addNote( n1 ); + m_clip->addNote( n1 ); update(); m_recordingNotes.erase( it ); break; @@ -4148,7 +4148,7 @@ void PianoRoll::setEditMode(int mode) void PianoRoll::selectAll() { - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } @@ -4156,7 +4156,7 @@ void PianoRoll::selectAll() // if first_time = true, we HAVE to set the vars for select bool first_time = true; - for( const Note *note : m_pattern->notes() ) + for( const Note *note : m_clip->notes() ) { int len_ticks = static_cast( note->length() ) > 0 ? static_cast( note->length() ) : 1; @@ -4204,9 +4204,9 @@ NoteVector PianoRoll::getSelectedNotes() const { NoteVector selectedNotes; - if (hasValidPattern()) + if (hasValidMidiClip()) { - for( Note *note : m_pattern->notes() ) + for( Note *note : m_clip->notes() ) { if( note->selected() ) { @@ -4220,8 +4220,8 @@ NoteVector PianoRoll::getSelectedNotes() const // selects all notess associated with m_lastKey void PianoRoll::selectNotesOnKey() { - if (hasValidPattern()) { - for (Note * note : m_pattern->notes()) { + if (hasValidMidiClip()) { + for (Note * note : m_clip->notes()) { if (note->key() == m_lastKey) { note->setSelected(true); } @@ -4332,7 +4332,7 @@ void PianoRoll::copySelectedNotes() void PianoRoll::cutSelectedNotes() { - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } @@ -4341,7 +4341,7 @@ void PianoRoll::cutSelectedNotes() if( ! selected_notes.empty() ) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); copyToClipboard( selected_notes ); @@ -4351,7 +4351,7 @@ void PianoRoll::cutSelectedNotes() { // note (the memory of it) is also deleted by // pattern::removeNote(...) so we don't have to do that - m_pattern->removeNote( note ); + m_clip->removeNote( note ); } } @@ -4367,7 +4367,7 @@ void PianoRoll::pasteNotes() // For getString() and MimeType enum class using namespace Clipboard; - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } @@ -4385,7 +4385,7 @@ void PianoRoll::pasteNotes() if( ! list.isEmpty() ) { - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); } for( int i = 0; ! list.item( i ).isNull(); ++i ) @@ -4399,7 +4399,7 @@ void PianoRoll::pasteNotes() cur_note.setSelected( true ); // add to pattern - m_pattern->addNote( cur_note, false ); + m_clip->addNote( cur_note, false ); } // we only have to do the following lines if we pasted at @@ -4416,14 +4416,14 @@ void PianoRoll::pasteNotes() //Return false if no notes are deleted bool PianoRoll::deleteSelectedNotes() { - if (!hasValidPattern()) { return false; } + if (!hasValidMidiClip()) { return false; } auto selectedNotes = getSelectedNotes(); if (selectedNotes.empty()) { return false; } - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); - for (Note* note: selectedNotes) { m_pattern->removeNote( note ); } + for (Note* note: selectedNotes) { m_clip->removeNote( note ); } Engine::getSong()->setModified(); update(); @@ -4492,13 +4492,13 @@ void PianoRoll::updatePositionAccompany( const TimePos & t ) { Song * s = Engine::getSong(); - if( m_recording && hasValidPattern() && + if( m_recording && hasValidMidiClip() && s->playMode() != Song::Mode_PlayPattern ) { TimePos pos = t; if( s->playMode() != Song::Mode_PlayBB ) { - pos -= m_pattern->startPosition(); + pos -= m_clip->startPosition(); } if( (int) pos > 0 ) { @@ -4580,18 +4580,18 @@ int PianoRoll::quantization() const void PianoRoll::quantizeNotes(QuantizeActions mode) { - if( ! hasValidPattern() ) + if( ! hasValidMidiClip() ) { return; } - m_pattern->addJournalCheckPoint(); + m_clip->addJournalCheckPoint(); NoteVector notes = getSelectedNotes(); if( notes.empty() ) { - for( Note* n : m_pattern->notes() ) + for( Note* n : m_clip->notes() ) { notes.push_back( n ); } @@ -4605,7 +4605,7 @@ void PianoRoll::quantizeNotes(QuantizeActions mode) } Note copy(*n); - m_pattern->removeNote( n ); + m_clip->removeNote( n ); if (mode == QuantizeBoth || mode == QuantizePos) { copy.quantizePos(quantization()); @@ -4614,7 +4614,7 @@ void PianoRoll::quantizeNotes(QuantizeActions mode) { copy.quantizeLength(quantization()); } - m_pattern->addNote(copy, false); + m_clip->addNote(copy, false); } update(); @@ -4657,7 +4657,7 @@ TimePos PianoRoll::newNoteLen() const bool PianoRoll::mouseOverNote() { - return hasValidPattern() && noteUnderMouse() != NULL; + return hasValidMidiClip() && noteUnderMouse() != NULL; } @@ -4680,7 +4680,7 @@ Note * PianoRoll::noteUnderMouse() TimePos::ticksPerBar() / m_ppb + m_currentPosition; // loop through whole note-vector... - for( Note* const& note : m_pattern->notes() ) + for( Note* const& note : m_clip->notes() ) { // and check whether the cursor is over an // existing note @@ -4779,8 +4779,8 @@ PianoRollWindow::PianoRollWindow() : m_fileToolsButton->addAction(exportAction); fileActionsToolBar->addWidget(m_fileToolsButton); - connect(importAction, SIGNAL(triggered()), this, SLOT(importPattern())); - connect(exportAction, SIGNAL(triggered()), this, SLOT(exportPattern())); + connect(importAction, SIGNAL(triggered()), this, SLOT(importMidiClip())); + connect(exportAction, SIGNAL(triggered()), this, SLOT(exportMidiClip())); // -- End File actions // Copy + paste actions @@ -4926,8 +4926,8 @@ PianoRollWindow::PianoRollWindow() : m_clearGhostButton->setIcon( embed::getIconPixmap( "clear_ghost_note" ) ); m_clearGhostButton->setToolTip( tr( "Clear ghost notes" ) ); m_clearGhostButton->setEnabled( false ); - connect( m_clearGhostButton, SIGNAL( clicked() ), m_editor, SLOT( clearGhostPattern() ) ); - connect( m_editor, SIGNAL( ghostPatternSet( bool ) ), this, SLOT( ghostPatternSet( bool ) ) ); + connect( m_clearGhostButton, SIGNAL( clicked() ), m_editor, SLOT( clearGhostClip() ) ); + connect( m_editor, SIGNAL( ghostClipSet( bool ) ), this, SLOT( ghostClipSet( bool ) ) ); // Wrap label icons and comboboxes in a single widget so when // the window is resized smaller in width it hides both @@ -5001,35 +5001,35 @@ PianoRollWindow::PianoRollWindow() : setFocusPolicy( Qt::StrongFocus ); setFocus(); setWindowIcon( embed::getIconPixmap( "piano" ) ); - setCurrentPattern( NULL ); + setCurrentMidiClip( NULL ); // Connections - connect( m_editor, SIGNAL( currentPatternChanged() ), this, SIGNAL( currentPatternChanged() ) ); - connect( m_editor, SIGNAL( currentPatternChanged() ), this, SLOT( updateAfterPatternChange() ) ); + connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SIGNAL( currentMidiClipChanged() ) ); + connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SLOT( updateAfterPatternChange() ) ); } -const Pattern* PianoRollWindow::currentPattern() const +const MidiClip* PianoRollWindow::currentMidiClip() const { - return m_editor->currentPattern(); + return m_editor->currentMidiClip(); } -void PianoRollWindow::setGhostPattern( Pattern* pattern ) +void PianoRollWindow::setGhostClip( MidiClip* pattern ) { - m_editor->setGhostPattern( pattern ); + m_editor->setGhostClip( pattern ); } -void PianoRollWindow::setCurrentPattern( Pattern* pattern ) +void PianoRollWindow::setCurrentMidiClip( MidiClip* pattern ) { - m_editor->setCurrentPattern( pattern ); + m_editor->setCurrentMidiClip( pattern ); if ( pattern ) { @@ -5204,9 +5204,9 @@ void PianoRollWindow::updateAfterPatternChange() void PianoRollWindow::patternRenamed() { - if ( currentPattern() ) + if ( currentMidiClip() ) { - setWindowTitle( tr( "Piano-Roll - %1" ).arg( currentPattern()->name() ) ); + setWindowTitle( tr( "Piano-Roll - %1" ).arg( currentMidiClip()->name() ) ); m_fileToolsButton->setEnabled(true); } else @@ -5219,7 +5219,7 @@ void PianoRollWindow::patternRenamed() -void PianoRollWindow::ghostPatternSet( bool state ) +void PianoRollWindow::ghostClipSet( bool state ) { m_clearGhostButton->setEnabled( state ); } @@ -5227,7 +5227,7 @@ void PianoRollWindow::ghostPatternSet( bool state ) -void PianoRollWindow::exportPattern() +void PianoRollWindow::exportMidiClip() { FileDialog exportDialog(this, tr("Export pattern"), "", tr("XML pattern file (*.xpt *.xptz)")); @@ -5246,12 +5246,12 @@ void PianoRollWindow::exportPattern() const QString fullPath = exportDialog.selectedFiles()[0]; DataFile dataFile(DataFile::NotePattern); - m_editor->m_pattern->saveSettings(dataFile, dataFile.content()); + m_editor->m_clip->saveSettings(dataFile, dataFile.content()); if (dataFile.writeFile(fullPath)) { TextFloat::displayMessage(tr("Export pattern success"), - tr("Pattern saved to %1").arg(fullPath), + tr("MidiClip saved to %1").arg(fullPath), embed::getIconPixmap("project_export"), 4000); } } @@ -5260,10 +5260,10 @@ void PianoRollWindow::exportPattern() -void PianoRollWindow::importPattern() +void PianoRollWindow::importMidiClip() { // Overwrite confirmation. - if (!m_editor->m_pattern->empty() && + if (!m_editor->m_clip->empty() && QMessageBox::warning( NULL, tr("Import pattern."), @@ -5291,10 +5291,10 @@ void PianoRollWindow::importPattern() return; } - TimePos pos = m_editor->m_pattern->startPosition(); // Backup position in timeline. + TimePos pos = m_editor->m_clip->startPosition(); // Backup position in timeline. - m_editor->m_pattern->loadSettings(dataFile.content()); - m_editor->m_pattern->movePosition(pos); + m_editor->m_clip->loadSettings(dataFile.content()); + m_editor->m_clip->movePosition(pos); TextFloat::displayMessage(tr("Import pattern success"), tr("Imported pattern %1!").arg(fullPath), diff --git a/src/tracks/CMakeLists.txt b/src/tracks/CMakeLists.txt index 158588318ac..a9fd83e908d 100644 --- a/src/tracks/CMakeLists.txt +++ b/src/tracks/CMakeLists.txt @@ -3,7 +3,7 @@ set(LMMS_SRCS tracks/AutomationTrack.cpp tracks/BBTrack.cpp tracks/InstrumentTrack.cpp - tracks/Pattern.cpp + tracks/MidiClip.cpp tracks/SampleTrack.cpp PARENT_SCOPE diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 6f08c0c16e0..cbe7d65295a 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -68,7 +68,7 @@ #include "MidiPortMenu.h" #include "Mixer.h" #include "MixHelpers.h" -#include "Pattern.h" +#include "MidiClip.h" #include "PluginFactory.h" #include "PluginView.h" #include "SamplePlayHandle.h" @@ -698,7 +698,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it ) { - Pattern* p = dynamic_cast( *it ); + MidiClip* p = dynamic_cast( *it ); // everything which is not a pattern won't be played // A pattern playing in the Piano Roll window will always play if(p == NULL || @@ -762,7 +762,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, Clip* InstrumentTrack::createClip(const TimePos & pos) { - Pattern* p = new Pattern(this); + MidiClip* p = new MidiClip(this); p->movePosition(pos); return p; } diff --git a/src/tracks/Pattern.cpp b/src/tracks/MidiClip.cpp similarity index 79% rename from src/tracks/Pattern.cpp rename to src/tracks/MidiClip.cpp index 067eeaa3b57..4ef4b0b3938 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/MidiClip.cpp @@ -1,5 +1,5 @@ /* - * Pattern.cpp - implementation of class pattern which holds notes + * MidiClip.cpp - implementation of class clip which holds notes * * Copyright (c) 2004-2014 Tobias Doerffel * Copyright (c) 2005-2007 Danny McRae @@ -23,7 +23,7 @@ * */ -#include "Pattern.h" +#include "MidiClip.h" #include "BBTrackContainer.h" #include "GuiApplication.h" @@ -33,17 +33,17 @@ #include -QPixmap * PatternView::s_stepBtnOn0 = NULL; -QPixmap * PatternView::s_stepBtnOn200 = NULL; -QPixmap * PatternView::s_stepBtnOff = NULL; -QPixmap * PatternView::s_stepBtnOffLight = NULL; +QPixmap * MidiClipView::s_stepBtnOn0 = NULL; +QPixmap * MidiClipView::s_stepBtnOn200 = NULL; +QPixmap * MidiClipView::s_stepBtnOff = NULL; +QPixmap * MidiClipView::s_stepBtnOffLight = NULL; -Pattern::Pattern( InstrumentTrack * _instrument_track ) : +MidiClip::MidiClip( InstrumentTrack * _instrument_track ) : Clip( _instrument_track ), m_instrumentTrack( _instrument_track ), - m_patternType( BeatPattern ), + m_clipType( BeatClip ), m_steps( TimePos::stepsPerBar() ) { if( _instrument_track->trackContainer() @@ -58,10 +58,10 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) : -Pattern::Pattern( const Pattern& other ) : +MidiClip::MidiClip( const MidiClip& other ) : Clip( other.m_instrumentTrack ), m_instrumentTrack( other.m_instrumentTrack ), - m_patternType( other.m_patternType ), + m_clipType( other.m_clipType ), m_steps( other.m_steps ) { for( NoteVector::ConstIterator it = other.m_notes.begin(); it != other.m_notes.end(); ++it ) @@ -85,9 +85,9 @@ Pattern::Pattern( const Pattern& other ) : } -Pattern::~Pattern() +MidiClip::~MidiClip() { - emit destroyedPattern( this ); + emit destroyedMidiClip( this ); for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); ++it ) @@ -101,7 +101,7 @@ Pattern::~Pattern() -void Pattern::resizeToFirstTrack() +void MidiClip::resizeToFirstTrack() { // Resize this track to be the same as existing tracks in the BB const TrackContainer::TrackList & tracks = @@ -114,7 +114,7 @@ void Pattern::resizeToFirstTrack() { unsigned int currentClip = m_instrumentTrack-> getClips().indexOf(this); - m_steps = static_cast + m_steps = static_cast (tracks.at(trackID)->getClip(currentClip)) ->m_steps; } @@ -126,7 +126,7 @@ void Pattern::resizeToFirstTrack() -void Pattern::init() +void MidiClip::init() { connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), this, SLOT( changeTimeSignature() ) ); @@ -139,11 +139,11 @@ void Pattern::init() -void Pattern::updateLength() +void MidiClip::updateLength() { - if( m_patternType == BeatPattern ) + if( m_clipType == BeatClip ) { - changeLength( beatPatternLength() ); + changeLength( beatClipLength() ); updateBBTrack(); return; } @@ -167,7 +167,7 @@ void Pattern::updateLength() -TimePos Pattern::beatPatternLength() const +TimePos MidiClip::beatClipLength() const { tick_t max_length = TimePos::ticksPerBar(); @@ -193,7 +193,7 @@ TimePos Pattern::beatPatternLength() const -Note * Pattern::addNote( const Note & _new_note, const bool _quant_pos ) +Note * MidiClip::addNote( const Note & _new_note, const bool _quant_pos ) { Note * new_note = new Note( _new_note ); if( _quant_pos && gui->pianoRoll() ) @@ -216,7 +216,7 @@ Note * Pattern::addNote( const Note & _new_note, const bool _quant_pos ) -void Pattern::removeNote( Note * _note_to_del ) +void MidiClip::removeNote( Note * _note_to_del ) { instrumentTrack()->lock(); NoteVector::Iterator it = m_notes.begin(); @@ -241,7 +241,7 @@ void Pattern::removeNote( Note * _note_to_del ) // returns a pointer to the note at specified step, or NULL if note doesn't exist -Note * Pattern::noteAtStep( int _step ) +Note * MidiClip::noteAtStep( int _step ) { for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); ++it ) @@ -257,7 +257,7 @@ Note * Pattern::noteAtStep( int _step ) -void Pattern::rearrangeAllNotes() +void MidiClip::rearrangeAllNotes() { // sort notes by start time std::sort(m_notes.begin(), m_notes.end(), Note::lessThan); @@ -265,7 +265,7 @@ void Pattern::rearrangeAllNotes() -void Pattern::clearNotes() +void MidiClip::clearNotes() { instrumentTrack()->lock(); for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); @@ -283,7 +283,7 @@ void Pattern::clearNotes() -Note * Pattern::addStepNote( int step ) +Note * MidiClip::addStepNote( int step ) { return addNote( Note( TimePos( -DefaultTicksPerBar ), TimePos::stepPosition( step ) ), false ); @@ -292,7 +292,7 @@ Note * Pattern::addStepNote( int step ) -void Pattern::setStep( int step, bool enabled ) +void MidiClip::setStep( int step, bool enabled ) { if( enabled ) { @@ -312,7 +312,7 @@ void Pattern::setStep( int step, bool enabled ) -void Pattern::splitNotes(NoteVector notes, TimePos pos) +void MidiClip::splitNotes(NoteVector notes, TimePos pos) { if (notes.empty()) { return; } @@ -346,47 +346,47 @@ void Pattern::splitNotes(NoteVector notes, TimePos pos) -void Pattern::setType( PatternTypes _new_pattern_type ) +void MidiClip::setType( MidiClipTypes _new_clip_type ) { - if( _new_pattern_type == BeatPattern || - _new_pattern_type == MelodyPattern ) + if( _new_clip_type == BeatClip || + _new_clip_type == MelodyClip ) { - m_patternType = _new_pattern_type; + m_clipType = _new_clip_type; } } -void Pattern::checkType() +void MidiClip::checkType() { NoteVector::Iterator it = m_notes.begin(); while( it != m_notes.end() ) { if( ( *it )->length() > 0 ) { - setType( MelodyPattern ); + setType( MelodyClip ); return; } ++it; } - setType( BeatPattern ); + setType( BeatClip ); } -void Pattern::saveSettings( QDomDocument & _doc, QDomElement & _this ) +void MidiClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) { - _this.setAttribute( "type", m_patternType ); + _this.setAttribute( "type", m_clipType ); _this.setAttribute( "name", name() ); if( usesCustomClipColor() ) { _this.setAttribute( "color", color().name() ); } - // as the target of copied/dragged pattern is always an existing - // pattern, we must not store actual position, instead we store -1 + // as the target of copied/dragged clip is always an existing + // clip, we must not store actual position, instead we store -1 // which tells loadSettings() not to mess around with position if( _this.parentNode().nodeName() == "clipboard" || _this.parentNode().nodeName() == "dnddata" ) @@ -411,9 +411,9 @@ void Pattern::saveSettings( QDomDocument & _doc, QDomElement & _this ) -void Pattern::loadSettings( const QDomElement & _this ) +void MidiClip::loadSettings( const QDomElement & _this ) { - m_patternType = static_cast( _this.attribute( "type" + m_clipType = static_cast( _this.attribute( "type" ).toInt() ); setName( _this.attribute( "name" ) ); @@ -462,33 +462,33 @@ void Pattern::loadSettings( const QDomElement & _this ) -Pattern * Pattern::previousPattern() const +MidiClip * MidiClip::previousMidiClip() const { - return adjacentPatternByOffset(-1); + return adjacentMidiClipByOffset(-1); } -Pattern * Pattern::nextPattern() const +MidiClip * MidiClip::nextMidiClip() const { - return adjacentPatternByOffset(1); + return adjacentMidiClipByOffset(1); } -Pattern * Pattern::adjacentPatternByOffset(int offset) const +MidiClip * MidiClip::adjacentMidiClipByOffset(int offset) const { QVector clips = m_instrumentTrack->getClips(); int clipNum = m_instrumentTrack->getClipNum(this); - return dynamic_cast(clips.value(clipNum + offset, NULL)); + return dynamic_cast(clips.value(clipNum + offset, NULL)); } -void Pattern::clear() +void MidiClip::clear() { addJournalCheckPoint(); clearNotes(); @@ -497,14 +497,14 @@ void Pattern::clear() -void Pattern::addSteps() +void MidiClip::addSteps() { m_steps += TimePos::stepsPerBar(); updateLength(); emit dataChanged(); } -void Pattern::cloneSteps() +void MidiClip::cloneSteps() { int oldLength = m_steps; m_steps *= 2; // cloning doubles the track @@ -528,7 +528,7 @@ void Pattern::cloneSteps() -void Pattern::removeSteps() +void MidiClip::removeSteps() { int n = TimePos::stepsPerBar(); if( n < m_steps ) @@ -546,22 +546,22 @@ void Pattern::removeSteps() -ClipView * Pattern::createView( TrackView * _tv ) +ClipView * MidiClip::createView( TrackView * _tv ) { - return new PatternView( this, _tv ); + return new MidiClipView( this, _tv ); } -void Pattern::updateBBTrack() +void MidiClip::updateBBTrack() { if( getTrack()->trackContainer() == Engine::getBBTrackContainer() ) { Engine::getBBTrackContainer()->updateBBTrack( this ); } - if( gui && gui->pianoRoll() && gui->pianoRoll()->currentPattern() == this ) + if( gui && gui->pianoRoll() && gui->pianoRoll()->currentMidiClip() == this ) { gui->pianoRoll()->update(); } @@ -570,7 +570,7 @@ void Pattern::updateBBTrack() -bool Pattern::empty() +bool MidiClip::empty() { for( NoteVector::ConstIterator it = m_notes.begin(); it != m_notes.end(); ++it ) @@ -586,7 +586,7 @@ bool Pattern::empty() -void Pattern::changeTimeSignature() +void MidiClip::changeTimeSignature() { TimePos last_pos = TimePos::ticksPerBar() - 1; for( NoteVector::ConstIterator cit = m_notes.begin(); @@ -602,4 +602,4 @@ void Pattern::changeTimeSignature() m_steps = qMax( TimePos::stepsPerBar(), last_pos.getBar() * TimePos::stepsPerBar() ); updateLength(); -} \ No newline at end of file +} diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index 024abe35cd8..a946ee8fb7d 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -32,7 +32,7 @@ #include "BBTrackContainer.h" #include "DetuningHelper.h" #include "InstrumentTrack.h" -#include "Pattern.h" +#include "MidiClip.h" #include "TrackContainer.h" #include "Engine.h" @@ -140,9 +140,9 @@ private slots: InstrumentTrack* instrumentTrack = dynamic_cast(Track::create(Track::InstrumentTrack, song)); - Pattern* notePattern = dynamic_cast(instrumentTrack->createClip(0)); - notePattern->changeLength(TimePos(4, 0)); - Note* note = notePattern->addNote(Note(TimePos(4, 0)), false); + MidiClip* noteMidiClip = dynamic_cast(instrumentTrack->createClip(0)); + noteMidiClip->changeLength(TimePos(4, 0)); + Note* note = noteMidiClip->addNote(Note(TimePos(4, 0)), false); note->createDetuning(); DetuningHelper* dh = note->detuning(); From 385c0874d61e027487d36cff71808621a3c38d79 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 25 Jun 2021 10:03:51 +0530 Subject: [PATCH 6/6] Finish Pattern -> Clip rename --- ...ck_pattern.png => clone_bb_track_clip.png} | Bin ...ck_pattern.png => clone_bb_track_clip.png} | Bin include/BBEditor.h | 2 +- include/Clipboard.h | 2 +- include/DataFile.h | 2 +- include/InlineAutomation.h | 26 ++-- include/InstrumentTrack.h | 2 +- include/NotePlayHandle.h | 8 +- include/PianoRoll.h | 10 +- include/Song.h | 6 +- include/StepRecorder.h | 2 +- src/core/DataFile.cpp | 4 +- src/core/InlineAutomation.cpp | 4 +- src/core/Mixer.cpp | 2 +- src/core/Note.cpp | 4 +- src/core/NotePlayHandle.cpp | 4 +- src/core/Song.cpp | 14 +- src/gui/BBClipView.cpp | 6 +- src/gui/ClipView.cpp | 2 +- src/gui/LmmsStyle.cpp | 6 +- src/gui/MainWindow.cpp | 2 +- src/gui/SampleClipView.cpp | 4 +- src/gui/editors/AutomationEditor.cpp | 6 +- src/gui/editors/BBEditor.cpp | 8 +- src/gui/editors/PianoRoll.cpp | 136 +++++++++--------- src/gui/widgets/PositionLine.cpp | 2 +- src/gui/widgets/TrackContentWidget.cpp | 2 +- src/tracks/InstrumentTrack.cpp | 12 +- tests/src/tracks/AutomationTrackTest.cpp | 2 +- 29 files changed, 140 insertions(+), 140 deletions(-) rename data/themes/classic/{clone_bb_track_pattern.png => clone_bb_track_clip.png} (100%) rename data/themes/default/{clone_bb_track_pattern.png => clone_bb_track_clip.png} (100%) diff --git a/data/themes/classic/clone_bb_track_pattern.png b/data/themes/classic/clone_bb_track_clip.png similarity index 100% rename from data/themes/classic/clone_bb_track_pattern.png rename to data/themes/classic/clone_bb_track_clip.png diff --git a/data/themes/default/clone_bb_track_pattern.png b/data/themes/default/clone_bb_track_clip.png similarity index 100% rename from data/themes/default/clone_bb_track_pattern.png rename to data/themes/default/clone_bb_track_clip.png diff --git a/include/BBEditor.h b/include/BBEditor.h index 96541ee7786..e13097e59b1 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -87,7 +87,7 @@ public slots: void removeSteps(); void addSampleTrack(); void addAutomationTrack(); - void clonePattern(); + void cloneClip(); protected slots: void dropEvent(QDropEvent * de ) override; diff --git a/include/Clipboard.h b/include/Clipboard.h index 5aa03d8d842..f78e143211e 100644 --- a/include/Clipboard.h +++ b/include/Clipboard.h @@ -1,5 +1,5 @@ /* - * Clipboard.h - the clipboard for patterns, notes etc. + * Clipboard.h - the clipboard for clips, notes etc. * * Copyright (c) 2004-2009 Tobias Doerffel * diff --git a/include/DataFile.h b/include/DataFile.h index ff3b934f08b..a19fc823c10 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -53,7 +53,7 @@ class LMMS_EXPORT DataFile : public QDomDocument ClipboardData, JournalData, EffectSettings, - NotePattern, + NoteClip, TypeCount } ; typedef Types Type; diff --git a/include/InlineAutomation.h b/include/InlineAutomation.h index 5a599b7e1d6..c0397bb18f5 100644 --- a/include/InlineAutomation.h +++ b/include/InlineAutomation.h @@ -36,15 +36,15 @@ class InlineAutomation : public FloatModel, public sharedObject InlineAutomation() : FloatModel(), sharedObject(), - m_autoPattern( NULL ) + m_autoClip( NULL ) { } virtual ~InlineAutomation() { - if( m_autoPattern ) + if( m_autoClip ) { - delete m_autoPattern; + delete m_autoClip; } } @@ -52,16 +52,16 @@ class InlineAutomation : public FloatModel, public sharedObject bool hasAutomation() const { - if( m_autoPattern != NULL && m_autoPattern->getTimeMap().isEmpty() == false ) + if( m_autoClip != NULL && m_autoClip->getTimeMap().isEmpty() == false ) { // Prevent saving inline automation if there's just one node at the beginning of - // the pattern, which has a InValue equal to the value of model (which is going + // the clip, which has a InValue equal to the value of model (which is going // to be saved anyways) and no offset between the InValue and OutValue AutomationClip::timeMap::const_iterator firstNode = - m_autoPattern->getTimeMap().begin(); + m_autoClip->getTimeMap().begin(); if (isAtInitValue() - && m_autoPattern->getTimeMap().size() == 1 + && m_autoClip->getTimeMap().size() == 1 && POS(firstNode) == 0 && INVAL(firstNode) == value() && OFFSET(firstNode) == 0) @@ -75,14 +75,14 @@ class InlineAutomation : public FloatModel, public sharedObject return false; } - AutomationClip * automationPattern() + AutomationClip * automationClip() { - if( m_autoPattern == NULL ) + if( m_autoClip == NULL ) { - m_autoPattern = new AutomationClip( NULL ); - m_autoPattern->addObject( this ); + m_autoClip = new AutomationClip( NULL ); + m_autoClip->addObject( this ); } - return m_autoPattern; + return m_autoClip; } void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; @@ -90,7 +90,7 @@ class InlineAutomation : public FloatModel, public sharedObject private: - AutomationClip * m_autoPattern; + AutomationClip * m_autoClip; } ; diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 7510ff8641f..cd954181aa2 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -137,7 +137,7 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor // create new view for me TrackView * createView( TrackContainerView* tcv ) override; - // create new track-content-object = pattern + // create new track-content-object = clip Clip* createClip(const TimePos & pos) override; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index e97b4607fe8..ae1b0f9f765 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -55,7 +55,7 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note // specifies origin of NotePlayHandle enum Origins { - OriginPattern, /*! playback of a note from a pattern */ + OriginMidiClip, /*! playback of a note from a clip */ OriginMidiInput, /*! playback of a MIDI note input event */ OriginNoteStacking, /*! created by note stacking instrument function */ OriginArpeggio, /*! created by arpeggio instrument function */ @@ -69,7 +69,7 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note const Note& noteToPlay, NotePlayHandle* parent = NULL, int midiEventChannel = -1, - Origin origin = OriginPattern ); + Origin origin = OriginMidiClip ); virtual ~NotePlayHandle(); void * operator new ( size_t size, void * p ) @@ -249,7 +249,7 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note /*! Updates total length (m_frames) depending on a new tempo */ void resize( const bpm_t newTempo ); - /*! Set song-global offset (relative to containing pattern) in order to properly perform the note detuning */ + /*! Set song-global offset (relative to containing clip) in order to properly perform the note detuning */ void setSongGlobalParentOffset( const TimePos& offset ) { m_songGlobalParentOffset = offset; @@ -346,7 +346,7 @@ class NotePlayHandleManager const Note& noteToPlay, NotePlayHandle* parent = NULL, int midiEventChannel = -1, - NotePlayHandle::Origin origin = NotePlayHandle::OriginPattern ); + NotePlayHandle::Origin origin = NotePlayHandle::OriginMidiClip ); static void release( NotePlayHandle * nph ); static void extend( int i ); static void free(); diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 185152a530a..168d0ddf3d6 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -215,7 +215,7 @@ protected slots: void changeNoteEditMode( int i ); void markSemiTone(int i, bool fromMenu = true); - void hideMidiClip( MidiClip* pattern ); + void hideMidiClip( MidiClip* clip ); void selectRegionFromPixels( int xStart, int xEnd ); @@ -497,8 +497,8 @@ class PianoRollWindow : public Editor, SerializingObject PianoRollWindow(); const MidiClip* currentMidiClip() const; - void setCurrentMidiClip( MidiClip* pattern ); - void setGhostClip( MidiClip* pattern ); + void setCurrentMidiClip( MidiClip* clip ); + void setGhostClip( MidiClip* clip ); int quantization() const; @@ -532,13 +532,13 @@ class PianoRollWindow : public Editor, SerializingObject private slots: - void updateAfterPatternChange(); + void updateAfterMidiClipChange(); void ghostClipSet( bool state ); void exportMidiClip(); void importMidiClip(); private: - void patternRenamed(); + void clipRenamed(); void focusInEvent(QFocusEvent * event) override; void stopStepRecording(); void updateStepRecordingIcon(); diff --git a/include/Song.h b/include/Song.h index 81309ffe650..e3729604d24 100644 --- a/include/Song.h +++ b/include/Song.h @@ -62,7 +62,7 @@ class LMMS_EXPORT Song : public TrackContainer Mode_None, Mode_PlaySong, Mode_PlayBB, - Mode_PlayPattern, + Mode_PlayClip, Mode_PlayAutomationClip, Mode_Count } ; @@ -355,7 +355,7 @@ public slots: void record(); void playAndRecord(); void playBB(); - void playPattern( const MidiClip * patternToPlay, bool loop = true ); + void playMidiClip( const MidiClip * clipToPlay, bool loop = true ); void togglePause(); void stop(); @@ -459,7 +459,7 @@ private slots: bar_t m_length; const MidiClip* m_clipToPlay; - bool m_loopPattern; + bool m_loopClip; double m_elapsedMilliSeconds[Mode_Count]; tick_t m_elapsedTicks; diff --git a/include/StepRecorder.h b/include/StepRecorder.h index 0c1b0f9c8bf..48e99097d9c 100644 --- a/include/StepRecorder.h +++ b/include/StepRecorder.h @@ -133,7 +133,7 @@ class StepRecorder : public QObject QElapsedTimer releasedTimer; } ; - QVector m_curStepNotes; // contains the current recorded step notes (i.e. while user still press the notes; before they are applied to the pattern) + QVector m_curStepNotes; // contains the current recorded step notes (i.e. while user still press the notes; before they are applied to the clip) StepNote* findCurStepNote(const int key); diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 898903ebe09..f176198d32e 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -93,7 +93,7 @@ DataFile::typeDescStruct { DataFile::ClipboardData, "clipboard-data" }, { DataFile::JournalData, "journaldata" }, { DataFile::EffectSettings, "effectsettings" }, - { DataFile::NotePattern, "pattern" } + { DataFile::NoteClip, "pattern" } } ; @@ -198,7 +198,7 @@ bool DataFile::validate( QString extension ) return true; } break; - case Type::NotePattern: + case Type::NoteClip: if (extension == "xpt" || extension == "xptz") { return true; diff --git a/src/core/InlineAutomation.cpp b/src/core/InlineAutomation.cpp index 8f122baff99..7df6a2d75e8 100644 --- a/src/core/InlineAutomation.cpp +++ b/src/core/InlineAutomation.cpp @@ -35,7 +35,7 @@ void InlineAutomation::saveSettings( QDomDocument & _doc, QDomElement ap = _doc.createElement( AutomationClip::classNodeName() ); QDomElement v = _doc.createElement( nodeName() ); - automationPattern()->saveSettings( _doc, v ); + automationClip()->saveSettings( _doc, v ); ap.appendChild( v ); _parent.appendChild( ap ); } @@ -52,7 +52,7 @@ void InlineAutomation::loadSettings( const QDomElement & _this ) node = node.namedItem( nodeName() ); if( node.isElement() ) { - automationPattern()->loadSettings( + automationClip()->loadSettings( node.toElement() ); } } diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 4a726dc2381..8df190dc079 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -463,7 +463,7 @@ void Mixer::handleMetronome() Song::PlayModes currentPlayMode = song->playMode(); bool metronomeSupported = - currentPlayMode == Song::Mode_PlayPattern + currentPlayMode == Song::Mode_PlayClip || currentPlayMode == Song::Mode_PlaySong || currentPlayMode == Song::Mode_PlayBB; diff --git a/src/core/Note.cpp b/src/core/Note.cpp index e6876087a81..dd3a1b70aed 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -211,9 +211,9 @@ void Note::createDetuning() if( m_detuning == NULL ) { m_detuning = new DetuningHelper; - (void) m_detuning->automationPattern(); + (void) m_detuning->automationClip(); m_detuning->setRange( -MaxDetuning, MaxDetuning, 0.5f ); - m_detuning->automationPattern()->setProgressionType( AutomationClip::LinearProgression ); + m_detuning->automationClip()->setProgressionType( AutomationClip::LinearProgression ); } } diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 0caf39b6a77..5d4eb56a961 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -34,7 +34,7 @@ NotePlayHandle::BaseDetuning::BaseDetuning( DetuningHelper *detuning ) : - m_value( detuning ? detuning->automationPattern()->valueAt( 0 ) : 0 ) + m_value( detuning ? detuning->automationClip()->valueAt( 0 ) : 0 ) { } @@ -539,7 +539,7 @@ void NotePlayHandle::processTimePos( const TimePos& time ) { if( detuning() && time >= songGlobalParentOffset()+pos() ) { - const float v = detuning()->automationPattern()->valueAt( time - songGlobalParentOffset() - pos() ); + const float v = detuning()->automationClip()->valueAt( time - songGlobalParentOffset() - pos() ); if( !typeInfo::isEqual( v, m_baseDetuning->value() ) ) { m_baseDetuning->setValue( v ); diff --git a/src/core/Song.cpp b/src/core/Song.cpp index a59c682112c..ad3037219a7 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -90,7 +90,7 @@ Song::Song() : m_playMode( Mode_None ), m_length( 0 ), m_clipToPlay( NULL ), - m_loopPattern( false ), + m_loopClip( false ), m_elapsedTicks( 0 ), m_elapsedBars( 0 ), m_loopRenderCount(1), @@ -225,7 +225,7 @@ void Song::processNextBuffer() } break; - case Mode_PlayPattern: + case Mode_PlayClip: if (m_clipToPlay) { clipNum = m_clipToPlay->getTrack()->getClipNum(m_clipToPlay); @@ -292,7 +292,7 @@ void Song::processNextBuffer() { enforceLoop(TimePos{0}, TimePos{Engine::getBBTrackContainer()->lengthOfCurrentBB(), 0}); } - else if (m_playMode == Mode_PlayPattern && m_loopPattern && !loopEnabled) + else if (m_playMode == Mode_PlayClip && m_loopClip && !loopEnabled) { enforceLoop(TimePos{0}, m_clipToPlay->length()); } @@ -537,19 +537,19 @@ void Song::playBB() -void Song::playPattern( const MidiClip* patternToPlay, bool loop ) +void Song::playMidiClip( const MidiClip* clipToPlay, bool loop ) { if( isStopped() == false ) { stop(); } - m_clipToPlay = patternToPlay; - m_loopPattern = loop; + m_clipToPlay = clipToPlay; + m_loopClip = loop; if( m_clipToPlay != NULL ) { - m_playMode = Mode_PlayPattern; + m_playMode = Mode_PlayClip; m_playing = true; m_paused = false; } diff --git a/src/gui/BBClipView.cpp b/src/gui/BBClipView.cpp index 1dd9b9c9a80..c0daae2cb7e 100644 --- a/src/gui/BBClipView.cpp +++ b/src/gui/BBClipView.cpp @@ -100,7 +100,7 @@ void BBClipView::paintEvent( QPaintEvent * ) lingrad.setColorAt( 0, c.lighter( 130 ) ); lingrad.setColorAt( 1, c.lighter( 70 ) ); - // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds + // paint a black rectangle under the clip to prevent glitches with transparent backgrounds p.fillRect( rect(), QColor( 0, 0, 0 ) ); if( gradient() ) @@ -129,7 +129,7 @@ void BBClipView::paintEvent( QPaintEvent * ) } } - // pattern name + // clip name paintTextLabel(m_bbClip->name(), p); // inner border @@ -141,7 +141,7 @@ void BBClipView::paintEvent( QPaintEvent * ) p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); - // draw the 'muted' pixmap only if the pattern was manualy muted + // draw the 'muted' pixmap only if the clip was manualy muted if( m_bbClip->isMuted() ) { const int spacing = CLIP_BORDER_WIDTH; diff --git a/src/gui/ClipView.cpp b/src/gui/ClipView.cpp index d26c0329151..4e877b9922a 100644 --- a/src/gui/ClipView.cpp +++ b/src/gui/ClipView.cpp @@ -1212,7 +1212,7 @@ void ClipView::mergeClips(QVector clipvs) const TimePos earliestPos = (*earliestClipV)->getClip()->startPosition(); - // Create a pattern where all notes will be added + // Create a clip where all notes will be added MidiClip* newMidiClip = dynamic_cast(track->createClip(earliestPos)); if (!newMidiClip) { diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 1f6d6f1cd3b..fdd3b288468 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -45,11 +45,11 @@ QLinearGradient getGradient( const QColor & _col, const QRectF & _rect ) qreal saturation = _col.saturationF(); QColor c = _col; - c.setHsvF( hue, 0.42 * saturation, 0.98 * value ); // TODO: pattern: 1.08 + c.setHsvF( hue, 0.42 * saturation, 0.98 * value ); // TODO: clip: 1.08 g.setColorAt( 0, c ); - c.setHsvF( hue, 0.58 * saturation, 0.95 * value ); // TODO: pattern: 1.05 + c.setHsvF( hue, 0.58 * saturation, 0.95 * value ); // TODO: clip: 1.05 g.setColorAt( 0.25, c ); - c.setHsvF( hue, 0.70 * saturation, 0.93 * value ); // TODO: pattern: 1.03 + c.setHsvF( hue, 0.70 * saturation, 0.93 * value ); // TODO: clip: 1.03 g.setColorAt( 0.5, c ); c.setHsvF( hue, 0.95 * saturation, 0.9 * value ); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 02ae9c2ad07..6f2de3d58d1 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1275,7 +1275,7 @@ void MainWindow::updatePlayPauseIcons() gui->getBBEditor()->setPauseIcon( true ); break; - case Song::Mode_PlayPattern: + case Song::Mode_PlayClip: gui->pianoRoll()->setPauseIcon( true ); break; diff --git a/src/gui/SampleClipView.cpp b/src/gui/SampleClipView.cpp index e336ec74a13..706a3177090 100644 --- a/src/gui/SampleClipView.cpp +++ b/src/gui/SampleClipView.cpp @@ -272,7 +272,7 @@ void SampleClipView::paintEvent( QPaintEvent * pe ) lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); - // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds + // paint a black rectangle under the clip to prevent glitches with transparent backgrounds p.fillRect( rect(), QColor( 0, 0, 0 ) ); if( gradient() ) @@ -333,7 +333,7 @@ void SampleClipView::paintEvent( QPaintEvent * pe ) p.setPen( c.darker( 200 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); - // draw the 'muted' pixmap only if the pattern was manualy muted + // draw the 'muted' pixmap only if the clip was manualy muted if( m_clip->isMuted() ) { const int spacing = CLIP_BORDER_WIDTH; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index c9b80d27d3c..c010f349342 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1526,10 +1526,10 @@ void AutomationEditor::play() if( !m_clip->getTrack() ) { - if( Engine::getSong()->playMode() != Song::Mode_PlayPattern ) + if( Engine::getSong()->playMode() != Song::Mode_PlayClip ) { Engine::getSong()->stop(); - Engine::getSong()->playPattern( gui->pianoRoll()->currentMidiClip() ); + Engine::getSong()->playMidiClip( gui->pianoRoll()->currentMidiClip() ); } else if( Engine::getSong()->isStopped() == false ) { @@ -1537,7 +1537,7 @@ void AutomationEditor::play() } else { - Engine::getSong()->playPattern( gui->pianoRoll()->currentMidiClip() ); + Engine::getSong()->playMidiClip( gui->pianoRoll()->currentMidiClip() ); } } else if( inBBEditor() ) diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index 3b0066c1f06..1fd5467aeb0 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -88,8 +88,8 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_bb_track"), tr("Add beat/bassline"), Engine::getSong(), SLOT(addBBTrack())); - trackAndStepActionsToolBar->addAction(embed::getIconPixmap("clone_bb_track_pattern"), tr("Clone beat/bassline pattern"), - m_trackContainerView, SLOT(clonePattern())); + trackAndStepActionsToolBar->addAction(embed::getIconPixmap("clone_bb_track_clip"), tr("Clone beat/bassline clip"), + m_trackContainerView, SLOT(cloneClip())); trackAndStepActionsToolBar->addAction( embed::getIconPixmap("add_sample_track"), tr("Add sample-track"), m_trackContainerView, @@ -316,9 +316,9 @@ void BBTrackContainerView::makeSteps( bool clone ) } } -// Creates a clone of the current BB track with the same pattern, but no Clips in the song editor +// Creates a clone of the current BB track with the same clip, but no Clips in the song editor // TODO: Avoid repeated code from cloneTrack and clearTrack in TrackOperationsWidget somehow -void BBTrackContainerView::clonePattern() +void BBTrackContainerView::cloneClip() { // Get the current BBTrack id BBTrackContainer *bbtc = static_cast(model()); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 93ba41bd4d4..f6a2eb582a1 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -291,9 +291,9 @@ PianoRoll::PianoRoll() : // add time-line m_timeLine = new TimeLineWidget(m_whiteKeyWidth, 0, m_ppb, Engine::getSong()->getPlayPos( - Song::Mode_PlayPattern ), + Song::Mode_PlayClip ), m_currentPosition, - Song::Mode_PlayPattern, this ); + Song::Mode_PlayClip, this ); connect( this, SIGNAL( positionChanged( const TimePos & ) ), m_timeLine, SLOT( updatePosition( const TimePos & ) ) ); connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), @@ -622,7 +622,7 @@ PianoRoll::~PianoRoll() void PianoRoll::setGhostClip( MidiClip* newMidiClip ) { - // Expects a pointer to a pattern or nullptr. + // Expects a pointer to a clip or nullptr. m_ghostNotes.clear(); if( newMidiClip != nullptr ) { @@ -843,11 +843,11 @@ void PianoRoll::setCurrentMidiClip( MidiClip* newMidiClip ) m_clip->instrumentTrack()->disconnect( this ); } - // force the song-editor to stop playing if it played pattern before + // force the song-editor to stop playing if it played clip before if( Engine::getSong()->isPlaying() && - Engine::getSong()->playMode() == Song::Mode_PlayPattern ) + Engine::getSong()->playMode() == Song::Mode_PlayClip ) { - Engine::getSong()->playPattern( NULL ); + Engine::getSong()->playMidiClip( NULL ); } if(m_stepRecorder.isRecording()) @@ -896,7 +896,7 @@ void PianoRoll::setCurrentMidiClip( MidiClip* newMidiClip ) // of start-notes and so on...) resizeEvent( NULL ); - // make sure to always get informed about the pattern being destroyed + // make sure to always get informed about the clip being destroyed connect( m_clip, SIGNAL( destroyedMidiClip( MidiClip* ) ), this, SLOT( hideMidiClip( MidiClip* ) ) ); connect( m_clip->instrumentTrack(), SIGNAL( midiNoteOn( const Note& ) ), this, SLOT( startRecordNote( const Note& ) ) ); @@ -912,9 +912,9 @@ void PianoRoll::setCurrentMidiClip( MidiClip* newMidiClip ) -void PianoRoll::hideMidiClip( MidiClip* pattern ) +void PianoRoll::hideMidiClip( MidiClip* clip ) { - if( m_clip == pattern ) + if( m_clip == clip ) { setCurrentMidiClip( NULL ); } @@ -1085,7 +1085,7 @@ void PianoRoll::drawDetuningInfo( QPainter & _p, const Note * _n, int _x, int old_x = 0; int old_y = 0; - timeMap & map = _n->detuning()->automationPattern()->getTimeMap(); + timeMap & map = _n->detuning()->automationClip()->getTimeMap(); for (timeMap::const_iterator it = map.begin(); it != map.end(); ++it) { // Current node values @@ -1118,7 +1118,7 @@ void PianoRoll::drawDetuningInfo( QPainter & _p, const Note * _n, int _x, // Now draw the lines representing the actual progression from one // node to the other - switch (_n->detuning()->automationPattern()->progressionType()) + switch (_n->detuning()->automationClip()->progressionType()) { case AutomationClip::DiscreteProgression: _p.drawLine(old_x, pre_y, cur_x, pre_y); @@ -1214,7 +1214,7 @@ void PianoRoll::shiftPos(NoteVector notes, int amount) { m_clip->addJournalCheckPoint(); auto leftMostPos = notes.first()->pos(); - //Limit leftwards shifts to prevent moving left of pattern start + //Limit leftwards shifts to prevent moving left of clip start auto shiftAmount = (leftMostPos > -amount) ? amount : -leftMostPos; if (shiftAmount == 0) { return; } @@ -1350,7 +1350,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) } else if( ke->modifiers() & Qt::AltModifier) { - // switch to editing a pattern adjacent to this one in the song editor + // switch to editing a clip adjacent to this one in the song editor if (hasValidMidiClip()) { MidiClip * p = direction > 0 ? m_clip->nextMidiClip() @@ -1628,7 +1628,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { n->createDetuning(); } - detuningPattern = n->detuning()->automationPattern(); + detuningPattern = n->detuning()->automationClip(); connect(detuningPattern.data(), SIGNAL(dataChanged()), this, SLOT(update())); gui->automationEditor()->open(detuningPattern); return; @@ -1678,7 +1678,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) m_currentPosition; - // get note-vector of current pattern + // get note-vector of current clip const NoteVector & notes = m_clip->notes(); // will be our iterator in the following loop @@ -2261,7 +2261,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) { // we moved one or more notes so they have to be // moved properly according to new starting- - // time in the note-array of pattern + // time in the note-array of clip m_clip->rearrangeAllNotes(); } @@ -2437,7 +2437,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) int ticks_end = ( x+pixel_range/2 ) * TimePos::ticksPerBar() / m_ppb + m_currentPosition; - // get note-vector of current pattern + // get note-vector of current clip const NoteVector & notes = m_clip->notes(); // determine what volume/panning to set note to @@ -2474,7 +2474,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) // When alt is pressed we only edit the note under the cursor bool altPressed = me->modifiers() & Qt::AltModifier; - // We iterate from last note in pattern to the first, + // We iterate from last note in clip to the first, // chronologically NoteVector::ConstIterator it = notes.begin()+notes.size()-1; for( int i = 0; i < notes.size(); ++i ) @@ -2522,7 +2522,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) --it; } - // Emit pattern has changed + // Emit clip has changed m_clip->dataChanged(); } @@ -2534,7 +2534,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) int pos_ticks = ( x * TimePos::ticksPerBar() ) / m_ppb + m_currentPosition; - // get note-vector of current pattern + // get note-vector of current clip const NoteVector & notes = m_clip->notes(); // will be our iterator in the following loop @@ -2611,7 +2611,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) m_currentPosition; - // get note-vector of current pattern + // get note-vector of current clip const NoteVector & notes = m_clip->notes(); // will be our iterator in the following loop @@ -2780,7 +2780,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) off_ticks -= m_mouseDownTick - m_currentPosition; off_key -= m_mouseDownKey - m_startKey; - // get note-vector of current pattern + // get note-vector of current clip const NoteVector & notes = m_clip->notes(); if (m_action == ActionMoveNote) @@ -3390,7 +3390,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) return (topKey - key) * m_keyLineHeight + keyAreaTop() - 1; }; - // -- Begin ghost pattern + // -- Begin ghost clip if( !m_ghostNotes.empty() ) { for( const Note *note : m_ghostNotes ) @@ -3430,7 +3430,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } } - // -- End ghost pattern + // -- End ghost clip for( const Note *note : m_clip->notes() ) { @@ -3600,7 +3600,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.setPen( QApplication::palette().color( QPalette::Active, QPalette::BrightText ) ); p.drawText(m_whiteKeyWidth + 20, PR_TOP_MARGIN + 40, - tr( "Please open a pattern by double-clicking " + tr( "Please open a clip by double-clicking " "on it!" ) ); } @@ -3717,7 +3717,7 @@ void PianoRoll::resizeEvent(QResizeEvent* re) { updatePositionLineHeight(); updateScrollbars(); - Engine::getSong()->getPlayPos(Song::Mode_PlayPattern) + Engine::getSong()->getPlayPos(Song::Mode_PlayClip) .m_timeLine->setFixedWidth(width()); update(); } @@ -3948,9 +3948,9 @@ void PianoRoll::play() return; } - if( Engine::getSong()->playMode() != Song::Mode_PlayPattern ) + if( Engine::getSong()->playMode() != Song::Mode_PlayClip ) { - Engine::getSong()->playPattern( m_clip ); + Engine::getSong()->playMidiClip( m_clip ); } else { @@ -3975,7 +3975,7 @@ void PianoRoll::record() m_clip->addJournalCheckPoint(); m_recording = true; - Engine::getSong()->playPattern( m_clip, false ); + Engine::getSong()->playMidiClip( m_clip, false ); } @@ -4026,7 +4026,7 @@ bool PianoRoll::toggleStepRecording() { m_stepRecorder.start( Engine::getSong()->getPlayPos( - Song::Mode_PlayPattern), newNoteLen()); + Song::Mode_PlayClip), newNoteLen()); } } } @@ -4054,7 +4054,7 @@ void PianoRoll::startRecordNote(const Note & n ) if( m_recording && Engine::getSong()->isPlaying() && (Engine::getSong()->playMode() == desiredPlayModeForAccompany() || - Engine::getSong()->playMode() == Song::Mode_PlayPattern )) + Engine::getSong()->playMode() == Song::Mode_PlayClip )) { TimePos sub; if( Engine::getSong()->playMode() == Song::Mode_PlaySong ) @@ -4088,7 +4088,7 @@ void PianoRoll::finishRecordNote(const Note & n ) ( Engine::getSong()->playMode() == desiredPlayModeForAccompany() || Engine::getSong()->playMode() == - Song::Mode_PlayPattern ) ) + Song::Mode_PlayClip ) ) { for( QList::Iterator it = m_recordingNotes.begin(); it != m_recordingNotes.end(); ++it ) @@ -4350,7 +4350,7 @@ void PianoRoll::cutSelectedNotes() for( Note *note : selected_notes ) { // note (the memory of it) is also deleted by - // pattern::removeNote(...) so we don't have to do that + // clip::removeNote(...) so we don't have to do that m_clip->removeNote( note ); } } @@ -4398,7 +4398,7 @@ void PianoRoll::pasteNotes() // select it cur_note.setSelected( true ); - // add to pattern + // add to clip m_clip->addNote( cur_note, false ); } @@ -4456,7 +4456,7 @@ void PianoRoll::autoScroll( const TimePos & t ) void PianoRoll::updatePosition( const TimePos & t ) { if( ( Engine::getSong()->isPlaying() - && Engine::getSong()->playMode() == Song::Mode_PlayPattern + && Engine::getSong()->playMode() == Song::Mode_PlayClip && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled ) || m_scrollBack ) { @@ -4493,7 +4493,7 @@ void PianoRoll::updatePositionAccompany( const TimePos & t ) Song * s = Engine::getSong(); if( m_recording && hasValidMidiClip() && - s->playMode() != Song::Mode_PlayPattern ) + s->playMode() != Song::Mode_PlayClip ) { TimePos pos = t; if( s->playMode() != Song::Mode_PlayBB ) @@ -4502,7 +4502,7 @@ void PianoRoll::updatePositionAccompany( const TimePos & t ) } if( (int) pos > 0 ) { - s->getPlayPos( Song::Mode_PlayPattern ).setTicks( pos ); + s->getPlayPos( Song::Mode_PlayClip ).setTicks( pos ); autoScroll( pos ); } } @@ -4711,11 +4711,11 @@ PianoRollWindow::PianoRollWindow() : { setCentralWidget( m_editor ); - m_playAction->setToolTip(tr( "Play/pause current pattern (Space)" ) ); + m_playAction->setToolTip(tr( "Play/pause current clip (Space)" ) ); m_recordAction->setToolTip(tr( "Record notes from MIDI-device/channel-piano" ) ); m_recordAccompanyAction->setToolTip( tr( "Record notes from MIDI-device/channel-piano while playing song or BB track" ) ); m_toggleStepRecordingAction->setToolTip( tr( "Record notes from MIDI-device/channel-piano, one step at the time" ) ); - m_stopAction->setToolTip( tr( "Stop playing of current pattern (Space)" ) ); + m_stopAction->setToolTip( tr( "Stop playing of current clip (Space)" ) ); DropToolBar *notesActionsToolBar = addDropToolBarToTop( tr( "Edit actions" ) ); @@ -4770,10 +4770,10 @@ PianoRollWindow::PianoRollWindow() : // Import / export QAction* importAction = new QAction(embed::getIconPixmap("project_import"), - tr("Import pattern"), m_fileToolsButton); + tr("Import clip"), m_fileToolsButton); QAction* exportAction = new QAction(embed::getIconPixmap("project_export"), - tr("Export pattern"), m_fileToolsButton); + tr("Export clip"), m_fileToolsButton); m_fileToolsButton->addAction(importAction); m_fileToolsButton->addAction(exportAction); @@ -4921,7 +4921,7 @@ PianoRollWindow::PianoRollWindow() : m_snapComboBox->setFixedSize(105, ComboBox::DEFAULT_HEIGHT); m_snapComboBox->setToolTip(tr("Snap mode")); - // -- Clear ghost pattern button + // -- Clear ghost clip button m_clearGhostButton = new QPushButton( m_toolBar ); m_clearGhostButton->setIcon( embed::getIconPixmap( "clear_ghost_note" ) ); m_clearGhostButton->setToolTip( tr( "Clear ghost notes" ) ); @@ -5005,7 +5005,7 @@ PianoRollWindow::PianoRollWindow() : // Connections connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SIGNAL( currentMidiClipChanged() ) ); - connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SLOT( updateAfterPatternChange() ) ); + connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SLOT( updateAfterMidiClipChange() ) ); } @@ -5019,28 +5019,28 @@ const MidiClip* PianoRollWindow::currentMidiClip() const -void PianoRollWindow::setGhostClip( MidiClip* pattern ) +void PianoRollWindow::setGhostClip( MidiClip* clip ) { - m_editor->setGhostClip( pattern ); + m_editor->setGhostClip( clip ); } -void PianoRollWindow::setCurrentMidiClip( MidiClip* pattern ) +void PianoRollWindow::setCurrentMidiClip( MidiClip* clip ) { - m_editor->setCurrentMidiClip( pattern ); + m_editor->setCurrentMidiClip( clip ); - if ( pattern ) + if ( clip ) { - setWindowTitle( tr( "Piano-Roll - %1" ).arg( pattern->name() ) ); + setWindowTitle( tr( "Piano-Roll - %1" ).arg( clip->name() ) ); m_fileToolsButton->setEnabled(true); - connect( pattern->instrumentTrack(), SIGNAL( nameChanged() ), this, SLOT( updateAfterPatternChange()) ); - connect( pattern, SIGNAL( dataChanged() ), this, SLOT( updateAfterPatternChange() ) ); + connect( clip->instrumentTrack(), SIGNAL( nameChanged() ), this, SLOT( updateAfterMidiClipChange()) ); + connect( clip, SIGNAL( dataChanged() ), this, SLOT( updateAfterMidiClipChange() ) ); } else { - setWindowTitle( tr( "Piano-Roll - no pattern" ) ); + setWindowTitle( tr( "Piano-Roll - no clip" ) ); m_fileToolsButton->setEnabled(false); } } @@ -5196,13 +5196,13 @@ bool PianoRollWindow::hasFocus() const -void PianoRollWindow::updateAfterPatternChange() +void PianoRollWindow::updateAfterMidiClipChange() { - patternRenamed(); - updateStepRecordingIcon(); //pattern change turn step recording OFF - update icon accordingly + clipRenamed(); + updateStepRecordingIcon(); //clip change turn step recording OFF - update icon accordingly } -void PianoRollWindow::patternRenamed() +void PianoRollWindow::clipRenamed() { if ( currentMidiClip() ) { @@ -5211,7 +5211,7 @@ void PianoRollWindow::patternRenamed() } else { - setWindowTitle( tr( "Piano-Roll - no pattern" ) ); + setWindowTitle( tr( "Piano-Roll - no clip" ) ); m_fileToolsButton->setEnabled(false); } } @@ -5229,8 +5229,8 @@ void PianoRollWindow::ghostClipSet( bool state ) void PianoRollWindow::exportMidiClip() { - FileDialog exportDialog(this, tr("Export pattern"), "", - tr("XML pattern file (*.xpt *.xptz)")); + FileDialog exportDialog(this, tr("Export clip"), "", + tr("XML clip file (*.xpt *.xptz)")); exportDialog.setAcceptMode(FileDialog::AcceptSave); @@ -5245,12 +5245,12 @@ void PianoRollWindow::exportMidiClip() exportDialog.setDefaultSuffix(suffix); const QString fullPath = exportDialog.selectedFiles()[0]; - DataFile dataFile(DataFile::NotePattern); + DataFile dataFile(DataFile::NoteClip); m_editor->m_clip->saveSettings(dataFile, dataFile.content()); if (dataFile.writeFile(fullPath)) { - TextFloat::displayMessage(tr("Export pattern success"), + TextFloat::displayMessage(tr("Export clip success"), tr("MidiClip saved to %1").arg(fullPath), embed::getIconPixmap("project_export"), 4000); } @@ -5266,9 +5266,9 @@ void PianoRollWindow::importMidiClip() if (!m_editor->m_clip->empty() && QMessageBox::warning( NULL, - tr("Import pattern."), - tr("You are about to import a pattern, this will " - "overwrite your current pattern. Do you want to " + tr("Import clip."), + tr("You are about to import a clip, this will " + "overwrite your current clip. Do you want to " "continue?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) != QMessageBox::Yes) @@ -5276,8 +5276,8 @@ void PianoRollWindow::importMidiClip() return; } - FileDialog importDialog(this, tr("Open pattern"), "", - tr("XML pattern file (*.xpt *.xptz)")); + FileDialog importDialog(this, tr("Open clip"), "", + tr("XML clip file (*.xpt *.xptz)")); importDialog.setFileMode(FileDialog::ExistingFile); if (importDialog.exec() == QDialog::Accepted && @@ -5296,8 +5296,8 @@ void PianoRollWindow::importMidiClip() m_editor->m_clip->loadSettings(dataFile.content()); m_editor->m_clip->movePosition(pos); - TextFloat::displayMessage(tr("Import pattern success"), - tr("Imported pattern %1!").arg(fullPath), + TextFloat::displayMessage(tr("Import clip success"), + tr("Imported clip %1!").arg(fullPath), embed::getIconPixmap("project_import"), 4000); } } diff --git a/src/gui/widgets/PositionLine.cpp b/src/gui/widgets/PositionLine.cpp index 978c94a96c2..1fb2a162bf0 100644 --- a/src/gui/widgets/PositionLine.cpp +++ b/src/gui/widgets/PositionLine.cpp @@ -63,7 +63,7 @@ void PositionLine::paintEvent(QPaintEvent* pe) if (m_hasTailGradient && Engine::getSong()->isPlaying() && (Engine::getSong()->playMode() == Song::Mode_PlaySong || - Engine::getSong()->playMode() == Song::Mode_PlayPattern)) + Engine::getSong()->playMode() == Song::Mode_PlayClip)) { c.setAlpha(60); gradient.setColorAt(w, c); diff --git a/src/gui/widgets/TrackContentWidget.cpp b/src/gui/widgets/TrackContentWidget.cpp index 4d9ff738361..d66838fb992 100644 --- a/src/gui/widgets/TrackContentWidget.cpp +++ b/src/gui/widgets/TrackContentWidget.cpp @@ -474,7 +474,7 @@ bool TrackContentWidget::pasteSelection( TimePos clipPos, const QMimeData * md, // onto their final position. float snapSize = gui->songEditor()->m_editor->getSnapSize(); - // All patterns should be offset the same amount as the grabbed pattern + // All clips should be offset the same amount as the grabbed clip TimePos offset = TimePos(clipPos - grabbedClipPos); // Users expect clips to "fall" backwards, so bias the offset offset -= TimePos::ticksPerBar() * snapSize / 2; diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index cbe7d65295a..9a97f98328e 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -191,7 +191,7 @@ InstrumentTrack::~InstrumentTrack() void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, NotePlayHandle* n ) { // we must not play the sound if this InstrumentTrack is muted... - if( isMuted() || ( Engine::getSong()->playMode() != Song::Mode_PlayPattern && + if( isMuted() || ( Engine::getSong()->playMode() != Song::Mode_PlayClip && n && n->isBbTrackMuted() ) || ! m_instrument ) { return; @@ -699,10 +699,10 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it ) { MidiClip* p = dynamic_cast( *it ); - // everything which is not a pattern won't be played - // A pattern playing in the Piano Roll window will always play + // everything which is not a clip won't be played + // A clip playing in the Piano Roll window will always play if(p == NULL || - (Engine::getSong()->playMode() != Song::Mode_PlayPattern + (Engine::getSong()->playMode() != Song::Mode_PlayClip && (*it)->isMuted())) { continue; @@ -713,7 +713,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, cur_start -= p->startPosition(); } - // get all notes from the given pattern... + // get all notes from the given clip... const NoteVector & notes = p->notes(); // ...and set our index to zero NoteVector::ConstIterator nit = notes.begin(); @@ -743,7 +743,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, // are we playing global song? if( _clip_num < 0 ) { - // then set song-global offset of pattern in order to + // then set song-global offset of clip in order to // properly perform the note detuning notePlayHandle->setSongGlobalParentOffset( p->startPosition() ); } diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index a946ee8fb7d..dbf0925c73d 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -146,7 +146,7 @@ private slots: note->createDetuning(); DetuningHelper* dh = note->detuning(); - auto pattern = dh->automationPattern(); + auto pattern = dh->automationClip(); pattern->setProgressionType( AutomationClip::LinearProgression ); pattern->putValue(TimePos(0, 0), 0.0); pattern->putValue(TimePos(4, 0), 1.0);