diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index c332858b7..2091b3f9a 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -30,7 +30,7 @@ #include "JournallingObject.h" #include "Model.h" -#include "MidiTime.h" +#include "TimePos.h" #include "ValueBuffer.h" #include "MemoryManager.h" #include "ModelVisitor.h" @@ -281,7 +281,7 @@ public: return false; } - float globalAutomationValueAt( const MidiTime& time ); + float globalAutomationValueAt( const TimePos& time ); void setStrictStepSize( const bool b ) { diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 481375969..a4e9d5286 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -34,7 +34,7 @@ #include "lmms_basics.h" #include "JournallingObject.h" -#include "MidiTime.h" +#include "TimePos.h" #include "AutomationPattern.h" #include "ComboBoxModel.h" #include "Knob.h" @@ -153,7 +153,7 @@ protected slots: void pasteValues(); void deleteSelectedValues(); - void updatePosition( const MidiTime & t ); + void updatePosition( const TimePos & t ); void zoomingXChanged(); void zoomingYChanged(); @@ -215,7 +215,7 @@ private: QScrollBar * m_leftRightScroll; QScrollBar * m_topBottomScroll; - MidiTime m_currentPosition; + TimePos m_currentPosition; Actions m_action; @@ -265,7 +265,7 @@ private: signals: void currentPatternChanged(); - void positionChanged( const MidiTime & ); + void positionChanged( const TimePos & ); } ; diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index cad9d0a1d..0e98c48d3 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -34,7 +34,7 @@ class AutomationTrack; -class MidiTime; +class TimePos; @@ -74,19 +74,19 @@ public: } void setTension( QString _new_tension ); - MidiTime timeMapLength() const; + TimePos timeMapLength() const; void updateLength(); - MidiTime putValue( const MidiTime & time, + TimePos putValue( const TimePos & time, const float value, const bool quantPos = true, const bool ignoreSurroundingPoints = true ); - void removeValue( const MidiTime & time ); + void removeValue( const TimePos & time ); - void recordValue(MidiTime time, float value); + void recordValue(TimePos time, float value); - MidiTime setDragValue( const MidiTime & time, + TimePos setDragValue( const TimePos & time, const float value, const bool quantPos = true, const bool controlKey = false ); @@ -134,8 +134,8 @@ public: return m_timeMap.isEmpty() == false; } - float valueAt( const MidiTime & _time ) const; - float *valuesAfter( const MidiTime & _time ) const; + float valueAt( const TimePos & _time ) const; + float *valuesAfter( const TimePos & _time ) const; const QString name() const; diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index c8a0009e9..0d53faaef 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -37,7 +37,7 @@ public: AutomationTrack( TrackContainer* tc, bool _hidden = false ); virtual ~AutomationTrack() = default; - virtual bool play( const MidiTime & _start, const fpp_t _frames, + virtual bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num = -1 ) override; QString nodeName() const override @@ -46,7 +46,7 @@ public: } TrackView * createView( TrackContainerView* ) override; - TrackContentObject* createTCO(const MidiTime & pos) override; + TrackContentObject* createTCO(const TimePos & pos) override; virtual void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; diff --git a/include/BBTrack.h b/include/BBTrack.h index 5f9cfe408..3c2f2ede5 100644 --- a/include/BBTrack.h +++ b/include/BBTrack.h @@ -103,10 +103,10 @@ public: BBTrack( TrackContainer* tc ); virtual ~BBTrack(); - virtual bool play( const MidiTime & _start, const fpp_t _frames, + 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 MidiTime & pos) override; + TrackContentObject* createTCO(const TimePos & pos) override; virtual void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; diff --git a/include/BBTrackContainer.h b/include/BBTrackContainer.h index 17d6eb5fe..1d8f73901 100644 --- a/include/BBTrackContainer.h +++ b/include/BBTrackContainer.h @@ -38,7 +38,7 @@ public: BBTrackContainer(); virtual ~BBTrackContainer(); - virtual bool play( MidiTime _start, const fpp_t _frames, + virtual bool play( TimePos _start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num = -1 ); void updateAfterTrackAdd() override; @@ -62,7 +62,7 @@ public: void fixIncorrectPositions(); void createTCOsForBB( int _bb ); - AutomatedValueMap automatedValuesAt(MidiTime time, int tcoNum) const override; + AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum) const override; public slots: void play(); diff --git a/include/Instrument.h b/include/Instrument.h index 1dbf1ba58..eab218081 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -30,8 +30,8 @@ #include "lmms_export.h" #include "lmms_basics.h" #include "MemoryManager.h" -#include "MidiTime.h" #include "Plugin.h" +#include "TimePos.h" // forward-declarations @@ -105,7 +105,7 @@ public: // sub-classes can re-implement this for receiving all incoming // MIDI-events - inline virtual bool handleMidiEvent( const MidiEvent&, const MidiTime& = MidiTime(), f_cnt_t offset = 0 ) + inline virtual bool handleMidiEvent( const MidiEvent&, const TimePos& = TimePos(), f_cnt_t offset = 0 ) { return true; } diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 944791552..b4bac9136 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -80,8 +80,8 @@ public: MidiEvent applyMasterKey( const MidiEvent& event ); - void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ) override; - void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ) override; + void processInEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) override; + void processOutEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) override; // silence all running notes played by this track void silenceAllNotes( bool removeIPH = false ); @@ -130,13 +130,13 @@ public: } // play everything in given frame-range - creates note-play-handles - virtual bool play( const MidiTime & _start, const fpp_t _frames, + virtual bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num = -1 ) override; // create new view for me TrackView * createView( TrackContainerView* tcv ) override; // create new track-content-object = pattern - TrackContentObject* createTCO(const MidiTime & pos) override; + TrackContentObject* createTCO(const TimePos & pos) override; // called by track diff --git a/include/Lv2ControlBase.h b/include/Lv2ControlBase.h index 176b5045c..de90960dc 100644 --- a/include/Lv2ControlBase.h +++ b/include/Lv2ControlBase.h @@ -134,7 +134,7 @@ protected: QString nodeName() const { return "lv2controls"; } bool hasNoteInput() const; void handleMidiInputEvent(const class MidiEvent &event, - const class MidiTime &time, f_cnt_t offset); + const class TimePos &time, f_cnt_t offset); private: //! Return the DataFile settings type diff --git a/include/Lv2Proc.h b/include/Lv2Proc.h index 702f41cb9..312f9cf34 100644 --- a/include/Lv2Proc.h +++ b/include/Lv2Proc.h @@ -37,10 +37,10 @@ #include "Lv2Features.h" #include "LinkedModelGroups.h" #include "MidiEvent.h" -#include "MidiTime.h" #include "Plugin.h" #include "PluginIssue.h" #include "../src/3rdparty/ringbuffer/include/ringbuffer/ringbuffer.h" +#include "TimePos.h" // forward declare port structs/enums namespace Lv2Ports @@ -144,7 +144,7 @@ public: void run(fpp_t frames); void handleMidiInputEvent(const class MidiEvent &event, - const MidiTime &time, f_cnt_t offset); + const TimePos &time, f_cnt_t offset); /* misc diff --git a/include/MidiAlsaSeq.h b/include/MidiAlsaSeq.h index b6e498721..5db5357d8 100644 --- a/include/MidiAlsaSeq.h +++ b/include/MidiAlsaSeq.h @@ -66,7 +66,7 @@ public: virtual void processOutEvent( const MidiEvent & _me, - const MidiTime & _time, + const TimePos & _time, const MidiPort * _port ) override; void applyPortMode( MidiPort * _port ) override; diff --git a/include/MidiApple.h b/include/MidiApple.h index 21b88073b..4ea4805e5 100644 --- a/include/MidiApple.h +++ b/include/MidiApple.h @@ -60,7 +60,7 @@ public: } virtual void processOutEvent( const MidiEvent & _me, - const MidiTime & _time, + const TimePos & _time, const MidiPort * _port ); virtual void applyPortMode( MidiPort * _port ); diff --git a/include/MidiClient.h b/include/MidiClient.h index f06cac893..ff441e24f 100644 --- a/include/MidiClient.h +++ b/include/MidiClient.h @@ -46,7 +46,7 @@ public: // to be implemented by sub-classes virtual void processOutEvent( const MidiEvent & _me, - const MidiTime & _time, + const TimePos & _time, const MidiPort * _port ) = 0; // inheriting classes can re-implement this for being able to update @@ -141,7 +141,7 @@ protected: private: // this does MIDI-event-process void processParsedEvent(); - void processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port ) override; + void processOutEvent( const MidiEvent& event, const TimePos& time, const MidiPort* port ) override; // small helper function returning length of a certain event - this // is necessary for parsing raw-MIDI-data diff --git a/include/MidiController.h b/include/MidiController.h index 43f928a25..74b408f86 100644 --- a/include/MidiController.h +++ b/include/MidiController.h @@ -44,10 +44,10 @@ public: virtual ~MidiController(); virtual void processInEvent( const MidiEvent & _me, - const MidiTime & _time, f_cnt_t offset = 0 ) override; + const TimePos & _time, f_cnt_t offset = 0 ) override; virtual void processOutEvent( const MidiEvent& _me, - const MidiTime & _time, f_cnt_t offset = 0 ) override + const TimePos & _time, f_cnt_t offset = 0 ) override { // No output yet } diff --git a/include/MidiEventProcessor.h b/include/MidiEventProcessor.h index b48f75d2b..3ded20430 100644 --- a/include/MidiEventProcessor.h +++ b/include/MidiEventProcessor.h @@ -26,8 +26,8 @@ #define MIDI_EVENT_PROCESSOR_H #include "MidiEvent.h" -#include "MidiTime.h" #include "MemoryManager.h" +#include "TimePos.h" // all classes being able to process MIDI-events should inherit from this class MidiEventProcessor @@ -43,8 +43,8 @@ public: } // to be implemented by inheriting classes - virtual void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ) = 0; - virtual void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ) = 0; + virtual void processInEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) = 0; + virtual void processOutEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) = 0; } ; diff --git a/include/MidiPort.h b/include/MidiPort.h index acf95992f..9592147da 100644 --- a/include/MidiPort.h +++ b/include/MidiPort.h @@ -31,7 +31,7 @@ #include #include "Midi.h" -#include "MidiTime.h" +#include "TimePos.h" #include "AutomatableModel.h" @@ -102,8 +102,8 @@ public: return outputChannel() ? outputChannel() - 1 : 0; } - void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime() ); - void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime() ); + void processInEvent( const MidiEvent& event, const TimePos& time = TimePos() ); + void processOutEvent( const MidiEvent& event, const TimePos& time = TimePos() ); void saveSettings( QDomDocument& doc, QDomElement& thisElement ) override; diff --git a/include/MidiWinMM.h b/include/MidiWinMM.h index a51fa7ed6..cbb139983 100644 --- a/include/MidiWinMM.h +++ b/include/MidiWinMM.h @@ -64,7 +64,7 @@ public: virtual void processOutEvent( const MidiEvent & _me, - const MidiTime & _time, + const TimePos & _time, const MidiPort * _port ); virtual void applyPortMode( MidiPort * _port ); diff --git a/include/Note.h b/include/Note.h index 30969b4c8..c08a3e24e 100644 --- a/include/Note.h +++ b/include/Note.h @@ -30,8 +30,8 @@ #include "volume.h" #include "panning.h" -#include "MidiTime.h" #include "SerializingObject.h" +#include "TimePos.h" class DetuningHelper; @@ -81,8 +81,8 @@ const float MaxDetuning = 4 * 12.0f; class LMMS_EXPORT Note : public SerializingObject { public: - Note( const MidiTime & length = MidiTime( 0 ), - const MidiTime & pos = MidiTime( 0 ), + Note( const TimePos & length = TimePos( 0 ), + const TimePos & pos = TimePos( 0 ), int key = DefaultKey, volume_t volume = DefaultVolume, panning_t panning = DefaultPanning, @@ -93,9 +93,9 @@ public: // used by GUI inline void setSelected( const bool selected ) { m_selected = selected; } inline void setOldKey( const int oldKey ) { m_oldKey = oldKey; } - inline void setOldPos( const MidiTime & oldPos ) { m_oldPos = oldPos; } + inline void setOldPos( const TimePos & oldPos ) { m_oldPos = oldPos; } - inline void setOldLength( const MidiTime & oldLength ) + inline void setOldLength( const TimePos & oldLength ) { m_oldLength = oldLength; } @@ -105,8 +105,8 @@ public: } - void setLength( const MidiTime & length ); - void setPos( const MidiTime & pos ); + void setLength( const TimePos & length ); + void setPos( const TimePos & pos ); void setKey( const int key ); virtual void setVolume( volume_t volume ); virtual void setPanning( panning_t panning ); @@ -138,12 +138,12 @@ public: return m_oldKey; } - inline MidiTime oldPos() const + inline TimePos oldPos() const { return m_oldPos; } - inline MidiTime oldLength() const + inline TimePos oldLength() const { return m_oldLength; } @@ -153,23 +153,23 @@ public: return m_isPlaying; } - inline MidiTime endPos() const + inline TimePos endPos() const { const int l = length(); return pos() + l; } - inline const MidiTime & length() const + inline const TimePos & length() const { return m_length; } - inline const MidiTime & pos() const + inline const TimePos & pos() const { return m_pos; } - inline MidiTime pos( MidiTime basePos ) const + inline TimePos pos( TimePos basePos ) const { const int bp = basePos; return m_pos - bp; @@ -205,7 +205,7 @@ public: return classNodeName(); } - static MidiTime quantized( const MidiTime & m, const int qGrid ); + static TimePos quantized( const TimePos & m, const int qGrid ); DetuningHelper * detuning() const { @@ -226,15 +226,15 @@ private: // for piano roll editing bool m_selected; int m_oldKey; - MidiTime m_oldPos; - MidiTime m_oldLength; + TimePos m_oldPos; + TimePos m_oldLength; bool m_isPlaying; int m_key; volume_t m_volume; panning_t m_panning; - MidiTime m_length; - MidiTime m_pos; + TimePos m_length; + TimePos m_pos; DetuningHelper * m_detuning; }; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 71866d13b..de324729a 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -244,19 +244,19 @@ public: } /*! Process note detuning automation */ - void processMidiTime( const MidiTime& time ); + void processTimePos( const TimePos& time ); /*! 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 */ - void setSongGlobalParentOffset( const MidiTime& offset ) + void setSongGlobalParentOffset( const TimePos& offset ) { m_songGlobalParentOffset = offset; } /*! Returns song-global offset */ - const MidiTime& songGlobalParentOffset() const + const TimePos& songGlobalParentOffset() const { return m_songGlobalParentOffset; } @@ -323,7 +323,7 @@ private: float m_unpitchedFrequency; BaseDetuning* m_baseDetuning; - MidiTime m_songGlobalParentOffset; + TimePos m_songGlobalParentOffset; int m_midiChannel; Origin m_origin; diff --git a/include/Pattern.h b/include/Pattern.h index 5192da9fa..ab7c94230 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -128,7 +128,7 @@ protected slots: private: - MidiTime beatPatternLength() const; + TimePos beatPatternLength() const; void setType( PatternTypes _new_pattern_type ); void checkType(); diff --git a/include/PianoRoll.h b/include/PianoRoll.h index a876e03a0..5e0ea0762 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -187,9 +187,9 @@ protected slots: void pasteNotes(); bool deleteSelectedNotes(); - void updatePosition(const MidiTime & t ); - void updatePositionAccompany(const MidiTime & t ); - void updatePositionStepRecording(const MidiTime & t ); + void updatePosition(const TimePos & t ); + void updatePositionAccompany(const TimePos & t ); + void updatePositionStepRecording(const TimePos & t ); void zoomingChanged(); void zoomingYChanged(); @@ -266,9 +266,9 @@ private: PianoRoll( const PianoRoll & ); virtual ~PianoRoll(); - void autoScroll(const MidiTime & t ); + void autoScroll(const TimePos & t ); - MidiTime newNoteLen() const; + TimePos newNoteLen() const; void shiftPos(int amount); void shiftPos(NoteVector notes, int amount); @@ -331,7 +331,7 @@ private: QScrollBar * m_leftRightScroll; QScrollBar * m_topBottomScroll; - MidiTime m_currentPosition; + TimePos m_currentPosition; bool m_recording; QList m_recordingNotes; @@ -377,12 +377,12 @@ private: // remember these values to use them // for the next note that is set - MidiTime m_lenOfNewNotes; + TimePos m_lenOfNewNotes; volume_t m_lastNoteVolume; panning_t m_lastNotePanning; //When resizing several notes, we want to calculate a common minimum length - MidiTime m_minResizeLen; + TimePos m_minResizeLen; int m_startKey; // first key when drawing int m_lastKey; @@ -447,7 +447,7 @@ private: QBrush m_blackKeyInactiveBackground; signals: - void positionChanged( const MidiTime & ); + void positionChanged( const TimePos & ); } ; diff --git a/include/SampleRecordHandle.h b/include/SampleRecordHandle.h index fc40d0622..f2a6fd63b 100644 --- a/include/SampleRecordHandle.h +++ b/include/SampleRecordHandle.h @@ -29,8 +29,8 @@ #include #include -#include "MidiTime.h" #include "PlayHandle.h" +#include "TimePos.h" class BBTrack; class SampleBuffer; @@ -60,7 +60,7 @@ private: typedef QList > bufferList; bufferList m_buffers; f_cnt_t m_framesRecorded; - MidiTime m_minLength; + TimePos m_minLength; Track * m_track; BBTrack * m_bbTrack; diff --git a/include/SampleTrack.h b/include/SampleTrack.h index e944936b3..7a9c25ab2 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -50,7 +50,7 @@ public: SampleTCO( Track * _track ); virtual ~SampleTCO(); - void changeLength( const MidiTime & _length ) override; + void changeLength( const TimePos & _length ) override; const QString & sampleFile() const; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; @@ -65,7 +65,7 @@ public: return m_sampleBuffer; } - MidiTime sampleLength() const; + TimePos sampleLength() const; void setSampleStartFrame( f_cnt_t startFrame ); void setSamplePlayLength( f_cnt_t length ); TrackContentObjectView * createView( TrackView * _tv ) override; @@ -139,10 +139,10 @@ public: SampleTrack( TrackContainer* tc ); virtual ~SampleTrack(); - virtual bool play( const MidiTime & _start, const fpp_t _frames, + 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 MidiTime & pos) override; + TrackContentObject* createTCO(const TimePos & pos) override; virtual void saveTrackSpecificSettings( QDomDocument & _doc, diff --git a/include/Song.h b/include/Song.h index eeee01274..e06658f4c 100644 --- a/include/Song.h +++ b/include/Song.h @@ -81,11 +81,11 @@ public: bool hasErrors(); QString errorSummary(); - class PlayPos : public MidiTime + class PlayPos : public TimePos { public: PlayPos( const int abs = 0 ) : - MidiTime( abs ), + TimePos( abs ), m_timeLine( NULL ), m_currentFrame( 0.0f ) { @@ -131,27 +131,27 @@ public: return m_elapsedMilliSeconds[playMode]; } - inline void setToTime(MidiTime const & midiTime) + inline void setToTime(TimePos const & pos) { - m_elapsedMilliSeconds[m_playMode] = midiTime.getTimeInMilliseconds(getTempo()); - m_playPos[m_playMode].setTicks(midiTime.getTicks()); + m_elapsedMilliSeconds[m_playMode] = pos.getTimeInMilliseconds(getTempo()); + m_playPos[m_playMode].setTicks(pos.getTicks()); } - inline void setToTime(MidiTime const & midiTime, PlayModes playMode) + inline void setToTime(TimePos const & pos, PlayModes playMode) { - m_elapsedMilliSeconds[playMode] = midiTime.getTimeInMilliseconds(getTempo()); - m_playPos[playMode].setTicks(midiTime.getTicks()); + m_elapsedMilliSeconds[playMode] = pos.getTimeInMilliseconds(getTempo()); + m_playPos[playMode].setTicks(pos.getTicks()); } inline void setToTimeByTicks(tick_t ticks) { - m_elapsedMilliSeconds[m_playMode] = MidiTime::ticksToMilliseconds(ticks, getTempo()); + m_elapsedMilliSeconds[m_playMode] = TimePos::ticksToMilliseconds(ticks, getTempo()); m_playPos[m_playMode].setTicks(ticks); } inline void setToTimeByTicks(tick_t ticks, PlayModes playMode) { - m_elapsedMilliSeconds[playMode] = MidiTime::ticksToMilliseconds(ticks, getTempo()); + m_elapsedMilliSeconds[playMode] = TimePos::ticksToMilliseconds(ticks, getTempo()); m_playPos[playMode].setTicks(ticks); } @@ -162,7 +162,7 @@ public: inline int ticksPerBar() const { - return MidiTime::ticksPerBar(m_timeSigModel); + return TimePos::ticksPerBar(m_timeSigModel); } // Returns the beat position inside the bar, 0-based @@ -273,7 +273,7 @@ public: } //TODO: Add Q_DECL_OVERRIDE when Qt4 is dropped - AutomatedValueMap automatedValuesAt(MidiTime time, int tcoNum = -1) const override; + AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum = -1) const override; // file management void createNewProject(); @@ -409,7 +409,7 @@ private: void removeAllControllers(); - void processAutomations(const TrackList& tracks, MidiTime timeStart, fpp_t frames); + void processAutomations(const TrackList& tracks, TimePos timeStart, fpp_t frames); void setModified(bool value); @@ -462,11 +462,11 @@ private: int m_loopRenderCount; int m_loopRenderRemaining; - MidiTime m_exportSongBegin; - MidiTime m_exportLoopBegin; - MidiTime m_exportLoopEnd; - MidiTime m_exportSongEnd; - MidiTime m_exportEffectiveLength; + TimePos m_exportSongBegin; + TimePos m_exportLoopBegin; + TimePos m_exportLoopEnd; + TimePos m_exportSongEnd; + TimePos m_exportEffectiveLength; friend class LmmsCore; friend class SongEditor; diff --git a/include/SongEditor.h b/include/SongEditor.h index a4394fc56..8d279c594 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -80,7 +80,7 @@ public slots: void setEditModeSelect(); void toggleProportionalSnap(); - void updatePosition( const MidiTime & t ); + void updatePosition( const TimePos & t ); void updatePositionLine(); void selectAllTcos( bool select ); @@ -150,7 +150,7 @@ private: QPoint m_scrollPos; QPoint m_mousePos; int m_rubberBandStartTrackview; - MidiTime m_rubberbandStartMidipos; + TimePos m_rubberbandStartTimePos; int m_currentZoomingValue; int m_trackHeadWidth; bool m_selectRegion; diff --git a/include/StepRecorder.h b/include/StepRecorder.h index 8240cc41a..13b3577a8 100644 --- a/include/StepRecorder.h +++ b/include/StepRecorder.h @@ -41,14 +41,14 @@ class StepRecorder : public QObject StepRecorder(PianoRoll& pianoRoll, StepRecorderWidget& stepRecorderWidget); void initialize(); - void start(const MidiTime& currentPosition,const MidiTime& stepLength); + void start(const TimePos& currentPosition,const TimePos& stepLength); void stop(); void notePressed(const Note & n); void noteReleased(const Note & n); bool keyPressEvent(QKeyEvent* ke); bool mousePressEvent(QMouseEvent* ke); void setCurrentPattern(Pattern* newPattern); - void setStepsLength(const MidiTime& newLength); + void setStepsLength(const TimePos& newLength); QVector getCurStepNotes(); @@ -73,7 +73,7 @@ class StepRecorder : public QObject void dismissStep(); void prepareNewStep(); - MidiTime getCurStepEndPos(); + TimePos getCurStepEndPos(); void updateCurStepNotes(); void updateWidget(); @@ -84,11 +84,11 @@ class StepRecorder : public QObject StepRecorderWidget& m_stepRecorderWidget; bool m_isRecording = false; - MidiTime m_curStepStartPos = 0; - MidiTime m_curStepEndPos = 0; + TimePos m_curStepStartPos = 0; + TimePos m_curStepEndPos = 0; - MidiTime m_stepsLength; - MidiTime m_curStepLength; // current step length refers to the step currently recorded. it may defer from m_stepsLength + TimePos m_stepsLength; + TimePos m_curStepLength; // current step length refers to the step currently recorded. it may defer from m_stepsLength // since the user can make current step larger QTimer m_updateReleasedTimer; diff --git a/include/StepRecorderWidget.h b/include/StepRecorderWidget.h index 67f2a4b65..dfaeaed0a 100644 --- a/include/StepRecorderWidget.h +++ b/include/StepRecorderWidget.h @@ -44,15 +44,15 @@ public: //API used by PianoRoll void setPixelsPerBar(int ppb); - void setCurrentPosition(MidiTime currentPosition); + void setCurrentPosition(TimePos currentPosition); void setMargins(const QMargins &qm); void setBottomMargin(const int marginBottom); QMargins margins(); //API used by StepRecorder - void setStepsLength(MidiTime stepsLength); - void setStartPosition(MidiTime pos); - void setEndPosition(MidiTime pos); + void setStepsLength(TimePos stepsLength); + void setStartPosition(TimePos pos); + void setEndPosition(TimePos pos); void showHint(); @@ -62,16 +62,16 @@ private: int xCoordOfTick(int tick); void drawVerLine(QPainter* painter, int x, const QColor& color, int top, int bottom); - void drawVerLine(QPainter* painter, const MidiTime& pos, const QColor& color, int top, int bottom); + void drawVerLine(QPainter* painter, const TimePos& pos, const QColor& color, int top, int bottom); void updateBoundaries(); - MidiTime m_stepsLength; - MidiTime m_curStepStartPos; - MidiTime m_curStepEndPos; + TimePos m_stepsLength; + TimePos m_curStepStartPos; + TimePos m_curStepEndPos; int m_ppb; // pixels per bar - MidiTime m_currentPosition; // current position showed by on PianoRoll + TimePos m_currentPosition; // current position showed by on PianoRoll QColor m_colorLineStart; QColor m_colorLineEnd; @@ -88,7 +88,7 @@ private: const int m_marginRight; signals: - void positionChanged(const MidiTime & t); + void positionChanged(const TimePos & t); } ; #endif //STEP_RECOREDER_WIDGET_H diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index 8a9dc5044..c7ac0124c 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -73,7 +73,7 @@ public: TimeLineWidget(int xoff, int yoff, float ppb, Song::PlayPos & pos, - const MidiTime & begin, Song::PlayModes mode, QWidget * parent); + const TimePos & begin, Song::PlayModes mode, QWidget * parent); virtual ~TimeLineWidget(); inline QColor const & getBarLineColor() const { return m_barLineColor; } @@ -123,23 +123,23 @@ public: return m_loopPoints == LoopPointsEnabled; } - inline const MidiTime & loopBegin() const + inline const TimePos & loopBegin() const { return ( m_loopPos[0] < m_loopPos[1] ) ? m_loopPos[0] : m_loopPos[1]; } - inline const MidiTime & loopEnd() const + inline const TimePos & loopEnd() const { return ( m_loopPos[0] > m_loopPos[1] ) ? m_loopPos[0] : m_loopPos[1]; } - inline void savePos( const MidiTime & pos ) + inline void savePos( const TimePos & pos ) { m_savedPos = pos; } - inline const MidiTime & savedPos() const + inline const TimePos & savedPos() const { return m_savedPos; } @@ -162,10 +162,10 @@ public: return "timeline"; } - inline int markerX( const MidiTime & _t ) const + inline int markerX( const TimePos & _t ) const { return m_xOffset + static_cast( ( _t - m_begin ) * - m_ppb / MidiTime::ticksPerBar() ); + m_ppb / TimePos::ticksPerBar() ); } signals: @@ -175,10 +175,10 @@ signals: public slots: - void updatePosition( const MidiTime & ); + void updatePosition( const TimePos & ); void updatePosition() { - updatePosition( MidiTime() ); + updatePosition( TimePos() ); } void toggleAutoScroll( int _n ); void toggleLoopPoints( int _n ); @@ -218,11 +218,11 @@ private: int m_posMarkerX; float m_ppb; Song::PlayPos & m_pos; - const MidiTime & m_begin; + const TimePos & m_begin; const Song::PlayModes m_mode; - MidiTime m_loopPos[2]; + TimePos m_loopPos[2]; - MidiTime m_savedPos; + TimePos m_savedPos; TextFloat * m_hint; @@ -242,7 +242,7 @@ private: signals: - void positionChanged( const MidiTime & _t ); + void positionChanged( const TimePos & _t ); void loopPointStateLoaded( int _n ); void positionMarkerMoved(); void loadBehaviourAtStop( int _n ); diff --git a/include/MidiTime.h b/include/TimePos.h similarity index 74% rename from include/MidiTime.h rename to include/TimePos.h index 952b4b6d5..675416c42 100644 --- a/include/MidiTime.h +++ b/include/TimePos.h @@ -1,6 +1,6 @@ /* - * MidiTime.h - declaration of class MidiTime which provides data type for - * position- and length-variables + * TimePos.h - declaration of class TimePos which provides data type for + * position- and length-variables * * Copyright (c) 2004-2014 Tobias Doerffel @@ -40,13 +40,15 @@ const int DefaultBeatsPerBar = DefaultTicksPerBar / DefaultStepsPerBar; class MeterModel; +/** + Represents a time signature, in which the numerator is the number of beats + in a bar, while the denominator is the type of note representing a beat. + + Example: 6/8 means 6 beats in a bar with each beat having a duration of one 8th-note. +*/ class LMMS_EXPORT TimeSig { public: - // in a time signature, - // the numerator represents the number of beats in a measure. - // the denominator indicates which type of note represents a beat. - // example: 6/8 means 6 beats in a measure, where each beat has duration equal to one 8th-note. TimeSig( int num, int denom ); TimeSig( const MeterModel &model ); int numerator() const; @@ -57,17 +59,20 @@ private: }; -class LMMS_EXPORT MidiTime +/** + Represents a position in time or length of a note or event, in ticks, beats, and bars +*/ +class LMMS_EXPORT TimePos { public: - MidiTime( const bar_t bar, const tick_t ticks ); - MidiTime( const tick_t ticks = 0 ); + TimePos( const bar_t bar, const tick_t ticks ); + TimePos( const tick_t ticks = 0 ); - MidiTime quantize(float) const; - MidiTime toAbsoluteBar() const; + TimePos quantize(float) const; + TimePos toAbsoluteBar() const; - MidiTime& operator+=( const MidiTime& time ); - MidiTime& operator-=( const MidiTime& time ); + TimePos& operator+=( const TimePos& time ); + TimePos& operator-=( const TimePos& time ); // return the bar, rounded down and 0-based bar_t getBar() const; @@ -92,12 +97,12 @@ public: double getTimeInMilliseconds( bpm_t beatsPerMinute ) const; - static MidiTime fromFrames( const f_cnt_t frames, const float framesPerTick ); + static TimePos fromFrames( const f_cnt_t frames, const float framesPerTick ); static tick_t ticksPerBar(); static tick_t ticksPerBar( const TimeSig &sig ); static int stepsPerBar(); static void setTicksPerBar( tick_t tpt ); - static MidiTime stepPosition( int step ); + static TimePos stepPosition( int step ); static double ticksToMilliseconds( tick_t ticks, bpm_t beatsPerMinute ); static double ticksToMilliseconds( double ticks, bpm_t beatsPerMinute ); diff --git a/include/Track.h b/include/Track.h index dd6066986..9f609758c 100644 --- a/include/Track.h +++ b/include/Track.h @@ -34,7 +34,7 @@ #include #include "lmms_basics.h" -#include "MidiTime.h" +#include "TimePos.h" #include "Rubberband.h" #include "JournallingObject.h" #include "AutomatableModel.h" @@ -108,18 +108,18 @@ public: } - inline const MidiTime & startPosition() const + inline const TimePos & startPosition() const { return m_startPosition; } - inline MidiTime endPosition() const + inline TimePos endPosition() const { const int sp = m_startPosition; return sp + m_length; } - inline const MidiTime & length() const + inline const TimePos & length() const { return m_length; } @@ -153,8 +153,8 @@ public: return m_useCustomClipColor; } - virtual void movePosition( const MidiTime & pos ); - virtual void changeLength( const MidiTime & length ); + virtual void movePosition( const TimePos & pos ); + virtual void changeLength( const TimePos & length ); virtual TrackContentObjectView * createView( TrackView * tv ) = 0; @@ -171,8 +171,8 @@ public: /// Returns true if and only if a->startPosition() < b->startPosition() static bool comparePosition(const TrackContentObject* a, const TrackContentObject* b); - MidiTime startTimeOffset() const; - void setStartTimeOffset( const MidiTime &startTimeOffset ); + TimePos startTimeOffset() const; + void setStartTimeOffset( const TimePos &startTimeOffset ); void updateColor(); @@ -201,9 +201,9 @@ private: Track * m_track; QString m_name; - MidiTime m_startPosition; - MidiTime m_length; - MidiTime m_startTimeOffset; + TimePos m_startPosition; + TimePos m_length; + TimePos m_startTimeOffset; BoolModel m_mutedModel; BoolModel m_soloModel; @@ -360,9 +360,9 @@ private: Actions m_action; QPoint m_initialMousePos; QPoint m_initialMouseGlobalPos; - MidiTime m_initialTCOPos; - MidiTime m_initialTCOEnd; - QVector m_initialOffsets; + TimePos m_initialTCOPos; + TimePos m_initialTCOEnd; + QVector m_initialOffsets; TextFloat * m_hint; @@ -389,7 +389,7 @@ private: void setInitialOffsets(); bool mouseMovedDistance( QMouseEvent * me, int distance ); - MidiTime draggedTCOPos( QMouseEvent * me ); + TimePos draggedTCOPos( QMouseEvent * me ); } ; @@ -423,12 +423,12 @@ public: } } - bool canPasteSelection( MidiTime tcoPos, const QDropEvent *de ); - bool canPasteSelection( MidiTime tcoPos, const QMimeData *md, bool allowSameBar = false ); - bool pasteSelection( MidiTime tcoPos, QDropEvent * de ); - bool pasteSelection( MidiTime tcoPos, const QMimeData * md, bool skipSafetyCheck = false ); + 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 ); - MidiTime endPosition( const MidiTime & posStart ); + TimePos endPosition( const TimePos & posStart ); // qproperty access methods @@ -444,7 +444,7 @@ public: public slots: void update(); - void changePosition( const MidiTime & newPos = MidiTime( -1 ) ); + void changePosition( const TimePos & newPos = TimePos( -1 ) ); protected: enum ContextMenuAction @@ -479,7 +479,7 @@ protected: private: Track * getTrack(); - MidiTime getPosition( int mouseX ); + TimePos getPosition( int mouseX ); TrackView * m_trackView; @@ -584,12 +584,12 @@ public: return m_type; } - virtual bool play( const MidiTime & start, const fpp_t frames, + virtual bool play( const TimePos & start, const fpp_t frames, const f_cnt_t frameBase, int tcoNum = -1 ) = 0; virtual TrackView * createView( TrackContainerView * view ) = 0; - virtual TrackContentObject * createTCO( const MidiTime & pos ) = 0; + virtual TrackContentObject * createTCO( const TimePos & pos ) = 0; virtual void saveTrackSpecificSettings( QDomDocument & doc, QDomElement & parent ) = 0; @@ -618,15 +618,15 @@ public: { return m_trackContentObjects; } - void getTCOsInRange( tcoVector & tcoV, const MidiTime & start, - const MidiTime & end ); + void getTCOsInRange( tcoVector & tcoV, const TimePos & start, + const TimePos & end ); void swapPositionOfTCOs( int tcoNum1, int tcoNum2 ); void createTCOsForBB( int bb ); - void insertBar( const MidiTime & pos ); - void removeBar( const MidiTime & pos ); + void insertBar( const TimePos & pos ); + void removeBar( const TimePos & pos ); bar_t length() const; diff --git a/include/TrackContainer.h b/include/TrackContainer.h index af1e8187d..00b391e10 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -93,13 +93,13 @@ public: return m_TrackContainerType; } - virtual AutomatedValueMap automatedValuesAt(MidiTime time, int tcoNum = -1) const; + virtual AutomatedValueMap automatedValuesAt(TimePos time, int tcoNum = -1) const; signals: void trackAdded( Track * _track ); protected: - static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, MidiTime timeStart, int tcoNum = -1); + static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int tcoNum = -1); mutable QReadWriteLock m_tracksMutex; diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index 6e952189b..30e7ec0f6 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -57,7 +57,7 @@ public: return m_scrollArea; } - inline const MidiTime & currentPosition() const + inline const TimePos & currentPosition() const { return m_currentPosition; } @@ -143,7 +143,7 @@ protected: void resizeEvent( QResizeEvent * ) override; - MidiTime m_currentPosition; + TimePos m_currentPosition; private: @@ -182,7 +182,7 @@ private: signals: - void positionChanged( const MidiTime & _pos ); + void positionChanged( const TimePos & _pos ); } ; diff --git a/plugins/Lv2Instrument/Lv2Instrument.cpp b/plugins/Lv2Instrument/Lv2Instrument.cpp index d67e25492..3eba7cdcc 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.cpp +++ b/plugins/Lv2Instrument/Lv2Instrument.cpp @@ -134,7 +134,7 @@ void Lv2Instrument::loadFile(const QString &file) #ifdef LV2_INSTRUMENT_USE_MIDI bool Lv2Instrument::handleMidiEvent( - const MidiEvent &event, const MidiTime &time, f_cnt_t offset) + const MidiEvent &event, const TimePos &time, f_cnt_t offset) { // this function can be called from GUI threads while the plugin is running // handleMidiInputEvent will use a thread-safe ringbuffer diff --git a/plugins/Lv2Instrument/Lv2Instrument.h b/plugins/Lv2Instrument/Lv2Instrument.h index a35830952..60575d426 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.h +++ b/plugins/Lv2Instrument/Lv2Instrument.h @@ -66,7 +66,7 @@ public: bool hasNoteInput() const override { return Lv2ControlBase::hasNoteInput(); } #ifdef LV2_INSTRUMENT_USE_MIDI bool handleMidiEvent(const MidiEvent &event, - const MidiTime &time = MidiTime(), f_cnt_t offset = 0) override; + const TimePos &time = TimePos(), f_cnt_t offset = 0) override; #else void playNote(NotePlayHandle *nph, sampleFrame *) override; #endif diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index a93e1e41e..97c814604 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -43,7 +43,7 @@ #include "Instrument.h" #include "GuiApplication.h" #include "MainWindow.h" -#include "MidiTime.h" +#include "TimePos.h" #include "debug.h" #include "Song.h" @@ -160,7 +160,7 @@ public: AutomationTrack * at; AutomationPattern * ap; - MidiTime lastPos; + TimePos lastPos; smfMidiCC & create( TrackContainer* tc, QString tn ) { @@ -187,11 +187,11 @@ public: } - smfMidiCC & putValue( MidiTime time, AutomatableModel * objModel, float value ) + smfMidiCC & putValue( TimePos time, AutomatableModel * objModel, float value ) { if( !ap || time > lastPos + DefaultTicksPerBar ) { - MidiTime pPos = MidiTime( time.getBar(), 0 ); + TimePos pPos = TimePos( time.getBar(), 0 ); ap = dynamic_cast( at->createTCO(pPos)); ap->addObject( objModel ); @@ -200,7 +200,7 @@ public: lastPos = time; time = time - ap->startPosition(); ap->putValue( time, value, false ); - ap->changeLength( MidiTime( time.getBar() + 1, 0 ) ); + ap->changeLength( TimePos( time.getBar() + 1, 0 ) ); return *this; } @@ -278,14 +278,14 @@ public: void splitPatterns() { Pattern * newPattern = nullptr; - MidiTime lastEnd(0); + TimePos lastEnd(0); p->rearrangeAllNotes(); for (auto n : p->notes()) { if (!newPattern || n->pos() > lastEnd + DefaultTicksPerBar) { - MidiTime pPos = MidiTime(n->pos().getBar(), 0); + TimePos pPos = TimePos(n->pos().getBar(), 0); newPattern = dynamic_cast(it->createTCO(pPos)); } lastEnd = n->pos() + n->length(); diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index 8ab635b4f..de3cce9ce 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -293,7 +293,7 @@ int OpulenzInstrument::pushVoice(int v) { return i; } -bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset ) { emulatorMutex.lock(); int key, vel, voice, tmp_pb; diff --git a/plugins/OpulenZ/OpulenZ.h b/plugins/OpulenZ/OpulenZ.h index 2273b355a..1776df93f 100644 --- a/plugins/OpulenZ/OpulenZ.h +++ b/plugins/OpulenZ/OpulenZ.h @@ -56,7 +56,7 @@ public: return IsSingleStreamed | IsMidiBased; } - virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset = 0 ); + virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ); virtual void play( sampleFrame * _working_buffer ); void saveSettings( QDomDocument & _doc, QDomElement & _this ); diff --git a/plugins/carlabase/carla.cpp b/plugins/carlabase/carla.cpp index a01ee625a..728a6d804 100644 --- a/plugins/carlabase/carla.cpp +++ b/plugins/carlabase/carla.cpp @@ -355,7 +355,7 @@ void CarlaInstrument::play(sampleFrame* workingBuffer) instrumentTrack()->processAudioBuffer(workingBuffer, bufsize, NULL); } -bool CarlaInstrument::handleMidiEvent(const MidiEvent& event, const MidiTime&, f_cnt_t offset) +bool CarlaInstrument::handleMidiEvent(const MidiEvent& event, const TimePos&, f_cnt_t offset) { const QMutexLocker ml(&fMutex); diff --git a/plugins/carlabase/carla.h b/plugins/carlabase/carla.h index 2c683add9..7efecf681 100644 --- a/plugins/carlabase/carla.h +++ b/plugins/carlabase/carla.h @@ -72,7 +72,7 @@ public: virtual void saveSettings(QDomDocument& doc, QDomElement& parent); virtual void loadSettings(const QDomElement& elem); virtual void play(sampleFrame* workingBuffer); - virtual bool handleMidiEvent(const MidiEvent& event, const MidiTime& time, f_cnt_t offset); + virtual bool handleMidiEvent(const MidiEvent& event, const TimePos& time, f_cnt_t offset); virtual PluginView* instantiateView(QWidget* parent); signals: diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 08d418836..1cd58eef4 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -48,7 +48,6 @@ float frnd(float range) #include "ToolTip.h" #include "Song.h" #include "MidiEvent.h" -#include "MidiTime.h" #include "Mixer.h" #include "embed.h" diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index b2c158594..d76ac37f6 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -411,7 +411,7 @@ void vestigeInstrument::play( sampleFrame * _buf ) -bool vestigeInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +bool vestigeInstrument::handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset ) { m_pluginMutex.lock(); if( m_plugin != NULL ) diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index ae4f803cf..48c89f14d 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -67,7 +67,7 @@ public: return IsSingleStreamed | IsMidiBased; } - virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset = 0 ); + virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ); virtual PluginView * instantiateView( QWidget * _parent ); diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 8446d36f6..94f480ce0 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -351,7 +351,7 @@ void ZynAddSubFxInstrument::play( sampleFrame * _buf ) -bool ZynAddSubFxInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +bool ZynAddSubFxInstrument::handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset ) { // do not forward external MIDI Control Change events if the according // LED is not checked diff --git a/plugins/zynaddsubfx/ZynAddSubFx.h b/plugins/zynaddsubfx/ZynAddSubFx.h index 6f5bc754d..10243e373 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.h +++ b/plugins/zynaddsubfx/ZynAddSubFx.h @@ -70,7 +70,7 @@ public: virtual void play( sampleFrame * _working_buffer ); - virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ); + virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ); virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 8328e5cb9..f66706a3b 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -708,7 +708,7 @@ void AutomatableModel::reset() -float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) +float AutomatableModel::globalAutomationValueAt( const TimePos& time ) { // get patterns that connect to this model QVector patterns = AutomationPattern::patternsForModel( this ); @@ -720,7 +720,7 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) else { // of those patterns: - // find the patterns which overlap with the miditime position + // find the patterns which overlap with the time position QVector patternsInRange; for( QVector::ConstIterator it = patterns.begin(); it != patterns.end(); it++ ) { @@ -738,7 +738,7 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) latestPattern = patternsInRange[0]; } else - // if we find no patterns at the exact miditime, we need to search for the last pattern before time and use that + // if we find no patterns at the exact time, we need to search for the last pattern before time and use that { int latestPosition = 0; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 8886d7ea5..3c6aa3e9c 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -51,7 +51,7 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : m_isRecording( false ), m_lastRecordedValue( 0 ) { - changeLength( MidiTime( 1, 0 ) ); + changeLength( TimePos( 1, 0 ) ); if( getTrack() ) { switch( getTrack()->trackContainer()->type() ) @@ -110,7 +110,7 @@ bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) if( m_objects.isEmpty() && hasAutomation() == false ) { // then initialize first value - putValue( MidiTime(0), _obj->inverseScaledValue( _obj->value() ), false ); + putValue( TimePos(0), _obj->inverseScaledValue( _obj->value() ), false ); } m_objects += _obj; @@ -176,9 +176,9 @@ const AutomationPattern::objectVector& AutomationPattern::objects() const -MidiTime AutomationPattern::timeMapLength() const +TimePos AutomationPattern::timeMapLength() const { - MidiTime one_bar = MidiTime(1, 0); + TimePos one_bar = TimePos(1, 0); if (m_timeMap.isEmpty()) { return one_bar; } timeMap::const_iterator it = m_timeMap.end(); @@ -187,7 +187,7 @@ MidiTime AutomationPattern::timeMapLength() const // return length as a whole bar to prevent disappearing TCO if (last_tick == 0) { return one_bar; } - return MidiTime(last_tick); + return TimePos(last_tick); } @@ -202,14 +202,14 @@ void AutomationPattern::updateLength() -MidiTime AutomationPattern::putValue( const MidiTime & time, +TimePos AutomationPattern::putValue( const TimePos & time, const float value, const bool quantPos, const bool ignoreSurroundingPoints ) { cleanObjects(); - MidiTime newTime = quantPos ? + TimePos newTime = quantPos ? Note::quantized( time, quantization() ) : time; @@ -241,7 +241,7 @@ MidiTime AutomationPattern::putValue( const MidiTime & time, -void AutomationPattern::removeValue( const MidiTime & time ) +void AutomationPattern::removeValue( const TimePos & time ) { cleanObjects(); @@ -261,7 +261,7 @@ void AutomationPattern::removeValue( const MidiTime & time ) -void AutomationPattern::recordValue(MidiTime time, float value) +void AutomationPattern::recordValue(TimePos time, float value) { if( value != m_lastRecordedValue ) { @@ -286,14 +286,14 @@ void AutomationPattern::recordValue(MidiTime time, float value) * @param true to snip x position * @return */ -MidiTime AutomationPattern::setDragValue( const MidiTime & time, +TimePos AutomationPattern::setDragValue( const TimePos & time, const float value, const bool quantPos, const bool controlKey ) { if( m_dragging == false ) { - MidiTime newTime = quantPos ? + TimePos newTime = quantPos ? Note::quantized( time, quantization() ) : time; this->removeValue( newTime ); @@ -327,7 +327,7 @@ void AutomationPattern::applyDragValue() -float AutomationPattern::valueAt( const MidiTime & _time ) const +float AutomationPattern::valueAt( const TimePos & _time ) const { if( m_timeMap.isEmpty() ) { @@ -395,7 +395,7 @@ float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const -float *AutomationPattern::valuesAfter( const MidiTime & _time ) const +float *AutomationPattern::valuesAfter( const TimePos & _time ) const { timeMap::ConstIterator v = m_timeMap.lowerBound( _time ); if( v == m_timeMap.end() || (v+1) == m_timeMap.end() ) @@ -436,12 +436,12 @@ void AutomationPattern::flipY( int min, int max ) if ( min < 0 ) { tempValue = valueAt( ( iterate + i ).key() ) * -1; - putValue( MidiTime( (iterate + i).key() ) , tempValue, false); + putValue( TimePos( (iterate + i).key() ) , tempValue, false); } else { tempValue = max - valueAt( ( iterate + i ).key() ); - putValue( MidiTime( (iterate + i).key() ) , tempValue, false); + putValue( TimePos( (iterate + i).key() ) , tempValue, false); } } @@ -480,12 +480,12 @@ void AutomationPattern::flipX( int length ) if ( realLength < length ) { tempValue = valueAt( ( iterate + numPoints ).key() ); - putValue( MidiTime( length ) , tempValue, false); + putValue( TimePos( length ) , tempValue, false); numPoints++; for( int i = 0; i <= numPoints; i++ ) { tempValue = valueAt( ( iterate + i ).key() ); - MidiTime newTime = MidiTime( length - ( iterate + i ).key() ); + TimePos newTime = TimePos( length - ( iterate + i ).key() ); tempMap[newTime] = tempValue; } } @@ -494,15 +494,15 @@ void AutomationPattern::flipX( int length ) for( int i = 0; i <= numPoints; i++ ) { tempValue = valueAt( ( iterate + i ).key() ); - MidiTime newTime; + TimePos newTime; if ( ( iterate + i ).key() <= length ) { - newTime = MidiTime( length - ( iterate + i ).key() ); + newTime = TimePos( length - ( iterate + i ).key() ); } else { - newTime = MidiTime( ( iterate + i ).key() ); + newTime = TimePos( ( iterate + i ).key() ); } tempMap[newTime] = tempValue; } @@ -514,7 +514,7 @@ void AutomationPattern::flipX( int length ) { tempValue = valueAt( ( iterate + i ).key() ); cleanObjects(); - MidiTime newTime = MidiTime( realLength - ( iterate + i ).key() ); + TimePos newTime = TimePos( realLength - ( iterate + i ).key() ); tempMap[newTime] = tempValue; } } diff --git a/src/core/BBTrackContainer.cpp b/src/core/BBTrackContainer.cpp index ac4b6cb1a..a374ad29a 100644 --- a/src/core/BBTrackContainer.cpp +++ b/src/core/BBTrackContainer.cpp @@ -53,7 +53,7 @@ BBTrackContainer::~BBTrackContainer() -bool BBTrackContainer::play( MidiTime _start, fpp_t _frames, +bool BBTrackContainer::play( TimePos _start, fpp_t _frames, f_cnt_t _offset, int _tco_num ) { bool played_a_note = false; @@ -62,7 +62,7 @@ bool BBTrackContainer::play( MidiTime _start, fpp_t _frames, return false; } - _start = _start % ( lengthOfBB( _tco_num ) * MidiTime::ticksPerBar() ); + _start = _start % ( lengthOfBB( _tco_num ) * TimePos::ticksPerBar() ); TrackList tl = tracks(); for( TrackList::iterator it = tl.begin(); it != tl.end(); ++it ) @@ -92,7 +92,7 @@ void BBTrackContainer::updateAfterTrackAdd() bar_t BBTrackContainer::lengthOfBB( int _bb ) const { - MidiTime max_length = MidiTime::ticksPerBar(); + TimePos max_length = TimePos::ticksPerBar(); const TrackList & tl = tracks(); for (Track* t : tl) @@ -168,7 +168,7 @@ void BBTrackContainer::fixIncorrectPositions() { for( int i = 0; i < numOfBBs(); ++i ) { - ( *it )->getTCO( i )->movePosition( MidiTime( i, 0 ) ); + ( *it )->getTCO( i )->movePosition( TimePos( i, 0 ) ); } } } @@ -242,18 +242,18 @@ void BBTrackContainer::createTCOsForBB( int _bb ) } } -AutomatedValueMap BBTrackContainer::automatedValuesAt(MidiTime time, int tcoNum) const +AutomatedValueMap BBTrackContainer::automatedValuesAt(TimePos time, int tcoNum) const { Q_ASSERT(tcoNum >= 0); Q_ASSERT(time.getTicks() >= 0); auto length_bars = lengthOfBB(tcoNum); - auto length_ticks = length_bars * MidiTime::ticksPerBar(); + auto length_ticks = length_bars * TimePos::ticksPerBar(); if (time > length_ticks) { time = length_ticks; } - return TrackContainer::automatedValuesAt(time + (MidiTime::ticksPerBar() * tcoNum), tcoNum); + return TrackContainer::automatedValuesAt(time + (TimePos::ticksPerBar() * tcoNum), tcoNum); } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 22bb11951..7b38c6c39 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -67,6 +67,7 @@ set(LMMS_SRCS core/SerializingObject.cpp core/Song.cpp core/TempoSyncKnobModel.cpp + core/TimePos.cpp core/ToolPlugin.cpp core/Track.cpp core/TrackContainer.cpp @@ -112,7 +113,6 @@ set(LMMS_SRCS core/midi/MidiSndio.cpp core/midi/MidiApple.cpp core/midi/MidiPort.cpp - core/midi/MidiTime.cpp core/midi/MidiWinMM.cpp PARENT_SCOPE diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 42ad3f0a3..09854220d 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -506,7 +506,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) NotePlayHandleManager::acquire( _n->instrumentTrack(), frames_processed, gated_frames, - Note( MidiTime( 0 ), MidiTime( 0 ), sub_note_key, _n->getVolume(), + Note( TimePos( 0 ), TimePos( 0 ), sub_note_key, _n->getVolume(), _n->getPanning(), _n->detuning() ), _n, -1, NotePlayHandle::OriginArpeggio ) ); diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 1a317e21f..573951ea9 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -361,7 +361,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer() // Stop crash with metronome if empty project Engine::getSong()->countTracks() ) { - tick_t ticksPerBar = MidiTime::ticksPerBar(); + tick_t ticksPerBar = TimePos::ticksPerBar(); if ( p.getTicks() % ( ticksPerBar / 1 ) == 0 ) { addPlayHandle( new SamplePlayHandle( "misc/metronome02.ogg" ) ); diff --git a/src/core/Note.cpp b/src/core/Note.cpp index 389526bb9..080a555b5 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -31,7 +31,7 @@ #include "DetuningHelper.h" -Note::Note( const MidiTime & length, const MidiTime & pos, +Note::Note( const TimePos & length, const TimePos & pos, int key, volume_t volume, panning_t panning, DetuningHelper * detuning ) : m_selected( false ), @@ -93,7 +93,7 @@ Note::~Note() -void Note::setLength( const MidiTime & length ) +void Note::setLength( const TimePos & length ) { m_length = length; } @@ -101,7 +101,7 @@ void Note::setLength( const MidiTime & length ) -void Note::setPos( const MidiTime & pos ) +void Note::setPos( const TimePos & pos ) { m_pos = pos; } @@ -136,7 +136,7 @@ void Note::setPanning( panning_t panning ) -MidiTime Note::quantized( const MidiTime & m, const int qGrid ) +TimePos Note::quantized( const TimePos & m, const int qGrid ) { float p = ( (float) m / qGrid ); if( p - floorf( p ) < 0.5f ) diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index d540792c0..a80b8f0c8 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -211,7 +211,7 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) // send MidiNoteOn event m_instrumentTrack->processOutEvent( MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ), - MidiTime::fromFrames( offset(), Engine::framesPerTick() ), + TimePos::fromFrames( offset(), Engine::framesPerTick() ), offset() ); } @@ -374,7 +374,7 @@ void NotePlayHandle::noteOff( const f_cnt_t _s ) // send MidiNoteOff event m_instrumentTrack->processOutEvent( MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ), - MidiTime::fromFrames( _s, Engine::framesPerTick() ), + TimePos::fromFrames( _s, Engine::framesPerTick() ), _s ); } @@ -383,7 +383,7 @@ void NotePlayHandle::noteOff( const f_cnt_t _s ) { if( m_origin == OriginMidiInput ) { - setLength( MidiTime( static_cast( totalFramesPlayed() / Engine::framesPerTick() ) ) ); + setLength( TimePos( static_cast( totalFramesPlayed() / Engine::framesPerTick() ) ) ); m_instrumentTrack->midiNoteOff( *this ); } } @@ -519,7 +519,7 @@ void NotePlayHandle::updateFrequency() -void NotePlayHandle::processMidiTime( const MidiTime& time ) +void NotePlayHandle::processTimePos( const TimePos& time ) { if( detuning() && time >= songGlobalParentOffset()+pos() ) { diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index cf9342b9e..c8f688a96 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -73,7 +73,7 @@ void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ ) writeBuffer( recbuf, frames ); m_framesRecorded += frames; - MidiTime len = (tick_t)( m_framesRecorded / Engine::framesPerTick() ); + TimePos len = (tick_t)( m_framesRecorded / Engine::framesPerTick() ); if( len > m_minLength ) { // m_tco->changeLength( len ); diff --git a/src/core/Song.cpp b/src/core/Song.cpp index bb2e937d0..0ae0cc887 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -57,7 +57,7 @@ #include "PeakController.h" -tick_t MidiTime::s_ticksPerBar = DefaultTicksPerBar; +tick_t TimePos::s_ticksPerBar = DefaultTicksPerBar; @@ -166,7 +166,7 @@ void Song::setTempo() void Song::setTimeSignature() { - MidiTime::setTicksPerBar( ticksPerBar() ); + TimePos::setTicksPerBar( ticksPerBar() ); emit timeSignatureChanged( m_oldTicksPerBar, ticksPerBar() ); emit dataChanged(); m_oldTicksPerBar = ticksPerBar(); @@ -240,7 +240,7 @@ void Song::processNextBuffer() // If the playback position is outside of the range [begin, end), move it to // begin and inform interested parties. // Returns true if the playback position was moved, else false. - const auto enforceLoop = [this](const MidiTime& begin, const MidiTime& end) + const auto enforceLoop = [this](const TimePos& begin, const TimePos& end) { if (getPlayPos() < begin || getPlayPos() >= end) { @@ -287,11 +287,11 @@ void Song::processNextBuffer() // loop back to the beginning when we reach the end if (m_playMode == Mode_PlayBB) { - enforceLoop(MidiTime{0}, MidiTime{Engine::getBBTrackContainer()->lengthOfCurrentBB(), 0}); + enforceLoop(TimePos{0}, TimePos{Engine::getBBTrackContainer()->lengthOfCurrentBB(), 0}); } else if (m_playMode == Mode_PlayPattern && m_loopPattern && !loopEnabled) { - enforceLoop(MidiTime{0}, m_patternToPlay->length()); + enforceLoop(TimePos{0}, m_patternToPlay->length()); } // Handle loop points, and inform VST plugins of the loop status @@ -343,14 +343,14 @@ void Song::processNextBuffer() frameOffsetInPeriod += framesToPlay; frameOffsetInTick += framesToPlay; getPlayPos().setCurrentFrame(frameOffsetInTick); - m_elapsedMilliSeconds[m_playMode] += MidiTime::ticksToMilliseconds(framesToPlay / framesPerTick, getTempo()); + m_elapsedMilliSeconds[m_playMode] += TimePos::ticksToMilliseconds(framesToPlay / framesPerTick, getTempo()); m_elapsedBars = m_playPos[Mode_PlaySong].getBar(); m_elapsedTicks = (m_playPos[Mode_PlaySong].getTicks() % ticksPerBar()) / 48; } } -void Song::processAutomations(const TrackList &tracklist, MidiTime timeStart, fpp_t) +void Song::processAutomations(const TrackList &tracklist, TimePos timeStart, fpp_t) { AutomatedValueMap values; @@ -392,7 +392,7 @@ void Song::processAutomations(const TrackList &tracklist, MidiTime timeStart, fp for (TrackContentObject* tco : tcos) { auto p = dynamic_cast(tco); - MidiTime relTime = timeStart - p->startPosition(); + TimePos relTime = timeStart - p->startPosition(); if (p->isRecording() && relTime >= 0 && relTime < p->length()) { const AutomatableModel* recordedModel = p->firstObject(); @@ -428,7 +428,7 @@ bool Song::isExportDone() const int Song::getExportProgress() const { - MidiTime pos = m_playPos[m_playMode]; + TimePos pos = m_playPos[m_playMode]; if (pos >= m_exportSongEnd) { @@ -572,7 +572,7 @@ void Song::setPlayPos( tick_t ticks, PlayModes playMode ) { tick_t ticksFromPlayMode = m_playPos[playMode].getTicks(); m_elapsedTicks += ticksFromPlayMode - ticks; - m_elapsedMilliSeconds[playMode] += MidiTime::ticksToMilliseconds( ticks - ticksFromPlayMode, getTempo() ); + m_elapsedMilliSeconds[playMode] += TimePos::ticksToMilliseconds( ticks - ticksFromPlayMode, getTempo() ); m_playPos[playMode].setTicks( ticks ); m_playPos[playMode].setCurrentFrame( 0.0f ); m_playPos[playMode].setJumped( true ); @@ -690,7 +690,7 @@ void Song::startExport() } else { - m_exportSongEnd = MidiTime(m_length, 0); + m_exportSongEnd = TimePos(m_length, 0); // Handle potentially ridiculous loop points gracefully. if (m_loopRenderCount > 1 && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() > m_exportSongEnd) @@ -699,18 +699,18 @@ void Song::startExport() } if (!m_exportLoop) - m_exportSongEnd += MidiTime(1,0); + m_exportSongEnd += TimePos(1,0); - m_exportSongBegin = MidiTime(0,0); + m_exportSongBegin = TimePos(0,0); // FIXME: remove this check once we load timeline in headless mode if (m_playPos[Mode_PlaySong].m_timeLine) { m_exportLoopBegin = m_playPos[Mode_PlaySong].m_timeLine->loopBegin() < m_exportSongEnd && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() <= m_exportSongEnd ? - m_playPos[Mode_PlaySong].m_timeLine->loopBegin() : MidiTime(0,0); + m_playPos[Mode_PlaySong].m_timeLine->loopBegin() : TimePos(0,0); m_exportLoopEnd = m_playPos[Mode_PlaySong].m_timeLine->loopBegin() < m_exportSongEnd && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() <= m_exportSongEnd ? - m_playPos[Mode_PlaySong].m_timeLine->loopEnd() : MidiTime(0,0); + m_playPos[Mode_PlaySong].m_timeLine->loopEnd() : TimePos(0,0); } m_playPos[Mode_PlaySong].setTicks( 0 ); @@ -806,7 +806,7 @@ AutomationPattern * Song::tempoAutomationPattern() } -AutomatedValueMap Song::automatedValuesAt(MidiTime time, int tcoNum) const +AutomatedValueMap Song::automatedValuesAt(TimePos time, int tcoNum) const { return TrackContainer::automatedValuesFromTracks(TrackList{m_globalAutomationTrack} << tracks(), time, tcoNum); } diff --git a/src/core/StepRecorder.cpp b/src/core/StepRecorder.cpp index e107c5818..1413d5050 100644 --- a/src/core/StepRecorder.cpp +++ b/src/core/StepRecorder.cpp @@ -43,7 +43,7 @@ void StepRecorder::initialize() connect(&m_updateReleasedTimer, SIGNAL(timeout()), this, SLOT(removeNotesReleasedForTooLong())); } -void StepRecorder::start(const MidiTime& currentPosition, const MidiTime& stepLength) +void StepRecorder::start(const TimePos& currentPosition, const TimePos& stepLength) { m_isRecording = true; @@ -53,7 +53,7 @@ void StepRecorder::start(const MidiTime& currentPosition, const MidiTime& stepLe const int q = m_pianoRoll.quantization(); const int curPosTicks = currentPosition.getTicks(); const int QuantizedPosTicks = (curPosTicks / q) * q; - const MidiTime& QuantizedPos = MidiTime(QuantizedPosTicks); + const TimePos& QuantizedPos = TimePos(QuantizedPosTicks); m_curStepStartPos = QuantizedPos; m_curStepLength = 0; @@ -154,7 +154,7 @@ bool StepRecorder::keyPressEvent(QKeyEvent* ke) return event_handled; } -void StepRecorder::setStepsLength(const MidiTime& newLength) +void StepRecorder::setStepsLength(const TimePos& newLength) { if(m_isStepInProgress) { @@ -319,7 +319,7 @@ void StepRecorder::removeNotesReleasedForTooLong() } } -MidiTime StepRecorder::getCurStepEndPos() +TimePos StepRecorder::getCurStepEndPos() { return m_curStepStartPos + m_curStepLength; } diff --git a/src/core/midi/MidiTime.cpp b/src/core/TimePos.cpp similarity index 64% rename from src/core/midi/MidiTime.cpp rename to src/core/TimePos.cpp index 4e718a1d8..9d25b9ce1 100644 --- a/src/core/midi/MidiTime.cpp +++ b/src/core/TimePos.cpp @@ -1,5 +1,5 @@ /* - * MidiTime.cpp - Class that encapsulates the position of a note/event in terms of + * TimePos.cpp - Class that encapsulates the position of a note/event in terms of * its bar, beat and tick. * * Copyright (c) 2004-2014 Tobias Doerffel = 0 ) { @@ -160,53 +160,53 @@ f_cnt_t MidiTime::frames( const float framesPerTick ) const return 0; } -double MidiTime::getTimeInMilliseconds( bpm_t beatsPerMinute ) const +double TimePos::getTimeInMilliseconds( bpm_t beatsPerMinute ) const { return ticksToMilliseconds( getTicks(), beatsPerMinute ); } -MidiTime MidiTime::fromFrames( const f_cnt_t frames, const float framesPerTick ) +TimePos TimePos::fromFrames( const f_cnt_t frames, const float framesPerTick ) { - return MidiTime( static_cast( frames / framesPerTick ) ); + return TimePos( static_cast( frames / framesPerTick ) ); } -tick_t MidiTime::ticksPerBar() +tick_t TimePos::ticksPerBar() { return s_ticksPerBar; } -tick_t MidiTime::ticksPerBar( const TimeSig &sig ) +tick_t TimePos::ticksPerBar( const TimeSig &sig ) { return DefaultTicksPerBar * sig.numerator() / sig.denominator(); } -int MidiTime::stepsPerBar() +int TimePos::stepsPerBar() { int steps = ticksPerBar() / DefaultBeatsPerBar; return qMax( 1, steps ); } -void MidiTime::setTicksPerBar( tick_t tpb ) +void TimePos::setTicksPerBar( tick_t tpb ) { s_ticksPerBar = tpb; } -MidiTime MidiTime::stepPosition( int step ) +TimePos TimePos::stepPosition( int step ) { return step * ticksPerBar() / stepsPerBar(); } -double MidiTime::ticksToMilliseconds( tick_t ticks, bpm_t beatsPerMinute ) +double TimePos::ticksToMilliseconds( tick_t ticks, bpm_t beatsPerMinute ) { - return MidiTime::ticksToMilliseconds( static_cast(ticks), beatsPerMinute ); + return TimePos::ticksToMilliseconds( static_cast(ticks), beatsPerMinute ); } -double MidiTime::ticksToMilliseconds(double ticks, bpm_t beatsPerMinute) +double TimePos::ticksToMilliseconds(double ticks, bpm_t beatsPerMinute) { // 60 * 1000 / 48 = 1250 return ( ticks * 1250 ) / beatsPerMinute; diff --git a/src/core/Track.cpp b/src/core/Track.cpp index c63e863bf..c2178d3be 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -149,9 +149,9 @@ TrackContentObject::~TrackContentObject() * * \param _pos The new position of the track content object. */ -void TrackContentObject::movePosition( const MidiTime & pos ) +void TrackContentObject::movePosition( const TimePos & pos ) { - MidiTime newPos = qMax(0, pos.getTicks()); + TimePos newPos = qMax(0, pos.getTicks()); if (m_startPosition != newPos) { Engine::mixer()->requestChangeInModel(); @@ -172,7 +172,7 @@ void TrackContentObject::movePosition( const MidiTime & pos ) * * \param _length The new length of the track content object. */ -void TrackContentObject::changeLength( const MidiTime & length ) +void TrackContentObject::changeLength( const TimePos & length ) { m_length = length; Engine::getSong()->updateLength(); @@ -202,7 +202,7 @@ void TrackContentObject::copyStateTo( TrackContentObject *src, TrackContentObjec QDomElement parent = doc.createElement( "StateCopy" ); src->saveState( doc, parent ); - const MidiTime pos = dst->startPosition(); + const TimePos pos = dst->startPosition(); dst->restoreState( parent.firstChild().toElement() ); dst->movePosition( pos ); @@ -231,7 +231,7 @@ void TrackContentObject::toggleMute() -MidiTime TrackContentObject::startTimeOffset() const +TimePos TrackContentObject::startTimeOffset() const { return m_startTimeOffset; } @@ -239,7 +239,7 @@ MidiTime TrackContentObject::startTimeOffset() const -void TrackContentObject::setStartTimeOffset( const MidiTime &startTimeOffset ) +void TrackContentObject::setStartTimeOffset( const TimePos &startTimeOffset ) { m_startTimeOffset = startTimeOffset; } @@ -290,9 +290,9 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, m_action( NoAction ), m_initialMousePos( QPoint( 0, 0 ) ), m_initialMouseGlobalPos( QPoint( 0, 0 ) ), - m_initialTCOPos( MidiTime(0) ), - m_initialTCOEnd( MidiTime(0) ), - m_initialOffsets( QVector() ), + m_initialTCOPos( TimePos(0) ), + m_initialTCOEnd( TimePos(0) ), + m_initialOffsets( QVector() ), m_hint( NULL ), m_mutedColor( 0, 0, 0 ), m_mutedBackgroundColor( 0, 0, 0 ), @@ -514,7 +514,7 @@ void TrackContentObjectView::updateLength() { setFixedWidth( static_cast( m_tco->length() * pixelsPerBar() / - MidiTime::ticksPerBar() ) + 1 /*+ + TimePos::ticksPerBar() ) + 1 /*+ TCO_BORDER_WIDTH * 2-1*/ ); } m_trackView->trackContainerView()->update(); @@ -577,7 +577,7 @@ void TrackContentObjectView::useTrackColor() void TrackContentObjectView::dragEnterEvent( QDragEnterEvent * dee ) { TrackContentWidget * tcw = getTrackView()->getTrackContentWidget(); - MidiTime tcoPos = MidiTime( m_tco->startPosition() ); + TimePos tcoPos = TimePos( m_tco->startPosition() ); if( tcw->canPasteSelection( tcoPos, dee ) == false ) { @@ -617,7 +617,7 @@ void TrackContentObjectView::dropEvent( QDropEvent * de ) if( m_trackView->trackContainerView()->allowRubberband() == true ) { TrackContentWidget * tcw = getTrackView()->getTrackContentWidget(); - MidiTime tcoPos = MidiTime( m_tco->startPosition() ); + TimePos tcoPos = TimePos( m_tco->startPosition() ); if( tcw->pasteSelection( tcoPos, de ) == true ) { @@ -636,7 +636,7 @@ void TrackContentObjectView::dropEvent( QDropEvent * de ) // Copy state into existing tco DataFile dataFile( value.toUtf8() ); - MidiTime pos = m_tco->startPosition(); + TimePos pos = m_tco->startPosition(); QDomElement tcos = dataFile.content().firstChildElement( "tcos" ); m_tco->restoreState( tcos.firstChildElement().firstChildElement() ); m_tco->movePosition( pos ); @@ -830,7 +830,7 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) s_textFloat->setText( QString( "%1:%2" ). arg( m_tco->startPosition().getBar() + 1 ). arg( m_tco->startPosition().getTicks() % - MidiTime::ticksPerBar() ) ); + TimePos::ticksPerBar() ) ); } else if( m_action == Resize || m_action == ResizeLeft ) { @@ -838,13 +838,13 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me ) s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ). arg( m_tco->length().getBar() ). arg( m_tco->length().getTicks() % - MidiTime::ticksPerBar() ). + TimePos::ticksPerBar() ). arg( m_tco->startPosition().getBar() + 1 ). arg( m_tco->startPosition().getTicks() % - MidiTime::ticksPerBar() ). + TimePos::ticksPerBar() ). arg( m_tco->endPosition().getBar() + 1 ). arg( m_tco->endPosition().getTicks() % - MidiTime::ticksPerBar() ) ); + TimePos::ticksPerBar() ) ); } // s_textFloat->reparent( this ); // setup text-float as if TCO was already moved/resized @@ -954,7 +954,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); if( m_action == Move ) { - MidiTime newPos = draggedTCOPos( me ); + TimePos newPos = draggedTCOPos( me ); m_tco->movePosition(newPos); newPos = m_tco->startPosition(); // Get the real position the TCO was dragged to for the label @@ -962,13 +962,13 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) s_textFloat->setText( QString( "%1:%2" ). arg( newPos.getBar() + 1 ). arg( newPos.getTicks() % - MidiTime::ticksPerBar() ) ); + TimePos::ticksPerBar() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2 ) ); } else if( m_action == MoveSelection ) { // 1: Find the position we want to move the grabbed TCO to - MidiTime newPos = draggedTCOPos( me ); + TimePos newPos = draggedTCOPos( me ); // 2: Handle moving the other selected TCOs the same distance QVector so = @@ -1002,12 +1002,12 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) const bool unquantized = (me->modifiers() & Qt::ControlModifier) || (me->modifiers() & Qt::AltModifier); const float snapSize = gui->songEditor()->m_editor->getSnapSize(); // Length in ticks of one snap increment - const MidiTime snapLength = MidiTime( (int)(snapSize * MidiTime::ticksPerBar()) ); + const TimePos snapLength = TimePos( (int)(snapSize * TimePos::ticksPerBar()) ); if( m_action == Resize ) { // The clip's new length - MidiTime l = static_cast( me->x() * MidiTime::ticksPerBar() / ppb ); + TimePos l = static_cast( me->x() * TimePos::ticksPerBar() / ppb ); if ( unquantized ) { // We want to preserve this adjusted offset, @@ -1018,18 +1018,18 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) } else if ( me->modifiers() & Qt::ShiftModifier ) { // If shift is held, quantize clip's end position - MidiTime end = MidiTime( m_initialTCOPos + l ).quantize( snapSize ); + TimePos end = TimePos( m_initialTCOPos + l ).quantize( snapSize ); // The end position has to be after the clip's start - MidiTime min = m_initialTCOPos.quantize( snapSize ); + TimePos min = m_initialTCOPos.quantize( snapSize ); if ( min <= m_initialTCOPos ) min += snapLength; m_tco->changeLength( qMax(min - m_initialTCOPos, end - m_initialTCOPos) ); } else { // Otherwise, resize in fixed increments - MidiTime initialLength = m_initialTCOEnd - m_initialTCOPos; - MidiTime offset = MidiTime( l - initialLength ).quantize( snapSize ); + TimePos initialLength = m_initialTCOEnd - m_initialTCOPos; + TimePos offset = TimePos( l - initialLength ).quantize( snapSize ); // Don't resize to less than 1 tick - MidiTime min = MidiTime( initialLength % snapLength ); + TimePos min = TimePos( initialLength % snapLength ); if (min < 1) min += snapLength; m_tco->changeLength( qMax( min, initialLength + offset) ); } @@ -1041,9 +1041,9 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) { const int x = mapToParent( me->pos() ).x() - m_initialMousePos.x(); - MidiTime t = qMax( 0, (int) + TimePos t = qMax( 0, (int) m_trackView->trackContainerView()->currentPosition() + - static_cast( x * MidiTime::ticksPerBar() / ppb ) ); + static_cast( x * TimePos::ticksPerBar() / ppb ) ); if( unquantized ) { // We want to preserve this adjusted offset, @@ -1055,21 +1055,21 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) 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 - MidiTime max = m_initialTCOEnd.quantize( snapSize ); + TimePos max = m_initialTCOEnd.quantize( snapSize ); if ( max >= m_initialTCOEnd ) max -= snapLength; t = qMin( max, t.quantize( snapSize ) ); } else { // Otherwise, resize in fixed increments // Don't resize to less than 1 tick - MidiTime initialLength = m_initialTCOEnd - m_initialTCOPos; - MidiTime minLength = MidiTime( initialLength % snapLength ); + TimePos initialLength = m_initialTCOEnd - m_initialTCOPos; + TimePos minLength = TimePos( initialLength % snapLength ); if (minLength < 1) minLength += snapLength; - MidiTime offset = MidiTime(t - m_initialTCOPos).quantize( snapSize ); + TimePos offset = TimePos(t - m_initialTCOPos).quantize( snapSize ); t = qMin( m_initialTCOEnd - minLength, m_initialTCOPos + offset ); } - MidiTime oldPos = m_tco->startPosition(); + TimePos oldPos = m_tco->startPosition(); if( m_tco->length() + ( oldPos - t ) >= 1 ) { m_tco->movePosition( t ); @@ -1081,13 +1081,13 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ). arg( m_tco->length().getBar() ). arg( m_tco->length().getTicks() % - MidiTime::ticksPerBar() ). + TimePos::ticksPerBar() ). arg( m_tco->startPosition().getBar() + 1 ). arg( m_tco->startPosition().getTicks() % - MidiTime::ticksPerBar() ). + TimePos::ticksPerBar() ). arg( m_tco->endPosition().getBar() + 1 ). arg( m_tco->endPosition().getTicks() % - MidiTime::ticksPerBar() ) ); + TimePos::ticksPerBar() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2) ); } else @@ -1300,8 +1300,8 @@ void TrackContentObjectView::paste() // For getMimeData() using namespace Clipboard; - // If possible, paste the selection on the MidiTime of the selected Track and remove it - MidiTime tcoPos = MidiTime( m_tco->startPosition() ); + // If possible, paste the selection on the TimePos of the selected Track and remove it + TimePos tcoPos = TimePos( m_tco->startPosition() ); TrackContentWidget *tcw = getTrackView()->getTrackContentWidget(); @@ -1338,7 +1338,7 @@ float TrackContentObjectView::pixelsPerBar() void TrackContentObjectView::setInitialOffsets() { QVector so = m_trackView->trackContainerView()->selectedObjects(); - QVector offsets; + QVector offsets; for( QVector::iterator it = so.begin(); it != so.end(); ++it ) { @@ -1376,14 +1376,14 @@ bool TrackContentObjectView::mouseMovedDistance( QMouseEvent * me, int distance * * \param me The QMouseEvent */ -MidiTime TrackContentObjectView::draggedTCOPos( QMouseEvent * me ) +TimePos TrackContentObjectView::draggedTCOPos( 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(); - MidiTime newPos = m_initialTCOPos + mouseOff * MidiTime::ticksPerBar() / ppb; - MidiTime offset = newPos - m_initialTCOPos; + TimePos newPos = m_initialTCOPos + mouseOff * TimePos::ticksPerBar() / ppb; + TimePos offset = newPos - m_initialTCOPos; // If the user is holding alt, or pressed ctrl after beginning the drag, don't quantize if ( me->button() != Qt::NoButton || (me->modifiers() & Qt::ControlModifier) @@ -1396,9 +1396,9 @@ MidiTime TrackContentObjectView::draggedTCOPos( QMouseEvent * me ) else if ( me->modifiers() & Qt::ShiftModifier ) { // If shift is held, quantize position (Default in 1.2.0 and earlier) // or end position, whichever is closest to the actual position - MidiTime startQ = newPos.quantize( gui->songEditor()->m_editor->getSnapSize() ); + TimePos startQ = newPos.quantize( gui->songEditor()->m_editor->getSnapSize() ); // Find start position that gives snapped clip end position - MidiTime endQ = ( newPos + m_tco->length() ); + TimePos endQ = ( newPos + m_tco->length() ); endQ = endQ.quantize( gui->songEditor()->m_editor->getSnapSize() ); endQ = endQ - m_tco->length(); // Select the position closest to actual position @@ -1482,8 +1482,8 @@ TrackContentWidget::TrackContentWidget( TrackView * parent ) : setAcceptDrops( true ); connect( parent->trackContainerView(), - SIGNAL( positionChanged( const MidiTime & ) ), - this, SLOT( changePosition( const MidiTime & ) ) ); + SIGNAL( positionChanged( const TimePos & ) ), + this, SLOT( changePosition( const TimePos & ) ) ); setStyle( QApplication::style() ); @@ -1611,7 +1611,7 @@ void TrackContentWidget::update() * * \param newPos The MIDI time to move to. */ -void TrackContentWidget::changePosition( const MidiTime & newPos ) +void TrackContentWidget::changePosition( const TimePos & newPos ) { if( m_trackView->trackContainerView() == gui->getBBEditor()->trackContainerView() ) { @@ -1648,7 +1648,7 @@ void TrackContentWidget::changePosition( const MidiTime & newPos ) return; } - MidiTime pos = newPos; + TimePos pos = newPos; if( pos < 0 ) { pos = m_trackView->trackContainerView()->currentPosition(); @@ -1674,7 +1674,7 @@ void TrackContentWidget::changePosition( const MidiTime & newPos ) ( ts <= begin && te >= end ) ) { tcov->move( static_cast( ( ts - begin ) * ppb / - MidiTime::ticksPerBar() ), + TimePos::ticksPerBar() ), tcov->y() ); if( !tcov->isVisible() ) { @@ -1699,12 +1699,12 @@ void TrackContentWidget::changePosition( const MidiTime & newPos ) * * \param mouseX the mouse's current X position in pixels. */ -MidiTime TrackContentWidget::getPosition( int mouseX ) +TimePos TrackContentWidget::getPosition( int mouseX ) { TrackContainerView * tv = m_trackView->trackContainerView(); - return MidiTime( tv->currentPosition() + + return TimePos( tv->currentPosition() + mouseX * - MidiTime::ticksPerBar() / + TimePos::ticksPerBar() / static_cast( tv->pixelsPerBar() ) ); } @@ -1717,7 +1717,7 @@ MidiTime TrackContentWidget::getPosition( int mouseX ) */ void TrackContentWidget::dragEnterEvent( QDragEnterEvent * dee ) { - MidiTime tcoPos = getPosition( dee->pos().x() ); + TimePos tcoPos = getPosition( dee->pos().x() ); if( canPasteSelection( tcoPos, dee ) == false ) { dee->ignore(); @@ -1737,7 +1737,7 @@ void TrackContentWidget::dragEnterEvent( QDragEnterEvent * dee ) * \param tcoPos the position of the TCO slot being pasted on * \param de the DropEvent generated */ -bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QDropEvent* de ) +bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QDropEvent* de ) { const QMimeData * mimeData = de->mimeData(); @@ -1749,7 +1749,7 @@ bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QDropEvent* d } // Overloaded method to make it possible to call this method without a Drag&Drop event -bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QMimeData* md , bool allowSameBar ) +bool TrackContentWidget::canPasteSelection( TimePos tcoPos, const QMimeData* md , bool allowSameBar ) { // For decodeKey() and decodeValue() using namespace Clipboard; @@ -1771,8 +1771,8 @@ bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QMimeData* md // Extract the metadata and which TCO was grabbed QDomElement metadata = dataFile.content().firstChildElement( "copyMetadata" ); QDomAttr tcoPosAttr = metadata.attributeNode( "grabbedTCOPos" ); - MidiTime grabbedTCOPos = tcoPosAttr.value().toInt(); - MidiTime grabbedTCOBar = MidiTime( grabbedTCOPos.getBar(), 0 ); + TimePos grabbedTCOPos = tcoPosAttr.value().toInt(); + TimePos grabbedTCOBar = TimePos( grabbedTCOPos.getBar(), 0 ); // Extract the track index that was originally clicked QDomAttr tiAttr = metadata.attributeNode( "initialTrackIndex" ); @@ -1824,7 +1824,7 @@ bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QMimeData* md * \param tcoPos the position of the TCO slot being pasted on * \param de the DropEvent generated */ -bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de ) +bool TrackContentWidget::pasteSelection( TimePos tcoPos, QDropEvent * de ) { const QMimeData * mimeData = de->mimeData(); @@ -1838,7 +1838,7 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de ) } // Overloaded method so we can call it without a Drag&Drop event -bool TrackContentWidget::pasteSelection( MidiTime tcoPos, const QMimeData * md, bool skipSafetyCheck ) +bool TrackContentWidget::pasteSelection( TimePos tcoPos, const QMimeData * md, bool skipSafetyCheck ) { // For decodeKey() and decodeValue() using namespace Clipboard; @@ -1866,7 +1866,7 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, const QMimeData * md, QDomAttr tiAttr = metadata.attributeNode( "initialTrackIndex" ); int initialTrackIndex = tiAttr.value().toInt(); QDomAttr tcoPosAttr = metadata.attributeNode( "grabbedTCOPos" ); - MidiTime grabbedTCOPos = tcoPosAttr.value().toInt(); + TimePos grabbedTCOPos = tcoPosAttr.value().toInt(); // Snap the mouse position to the beginning of the dropped bar, in ticks const TrackContainer::TrackList tracks = getTrack()->trackContainer()->tracks(); @@ -1889,20 +1889,20 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, const QMimeData * md, float snapSize = gui->songEditor()->m_editor->getSnapSize(); // All patterns should be offset the same amount as the grabbed pattern - MidiTime offset = MidiTime(tcoPos - grabbedTCOPos); + TimePos offset = TimePos(tcoPos - grabbedTCOPos); // Users expect clips to "fall" backwards, so bias the offset - offset = offset - MidiTime::ticksPerBar() * snapSize / 2; + 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 - MidiTime leftmostPos = grabbedTCOPos; + TimePos leftmostPos = grabbedTCOPos; for(int i = 0; i < tcoNodes.length(); ++i) { QDomElement outerTCOElement = tcoNodes.item(i).toElement(); QDomElement tcoElement = outerTCOElement.firstChildElement(); - MidiTime pos = tcoElement.attributeNode("pos").value().toInt(); + TimePos pos = tcoElement.attributeNode("pos").value().toInt(); if(pos < leftmostPos) { leftmostPos = pos; } } @@ -1919,9 +1919,9 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, const QMimeData * md, Track * t = tracks.at( finalTrackIndex ); // The new position is the old position plus the offset. - MidiTime pos = tcoElement.attributeNode( "pos" ).value().toInt() + offset; + TimePos pos = tcoElement.attributeNode( "pos" ).value().toInt() + offset; // If we land on ourselves, offset by one snap - MidiTime shift = MidiTime::ticksPerBar() * gui->songEditor()->m_editor->getSnapSize(); + TimePos shift = TimePos::ticksPerBar() * gui->songEditor()->m_editor->getSnapSize(); if (offset == 0) { pos += shift; } TrackContentObject * tco = t->createTCO( pos ); @@ -1945,7 +1945,7 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, const QMimeData * md, */ void TrackContentWidget::dropEvent( QDropEvent * de ) { - MidiTime tcoPos = MidiTime( getPosition( de->pos().x() ) ); + TimePos tcoPos = TimePos( getPosition( de->pos().x() ) ); if( pasteSelection( tcoPos, de ) == true ) { de->accept(); @@ -1978,8 +1978,8 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me ) so.at( i )->setSelected( false); } getTrack()->addJournalCheckPoint(); - const MidiTime pos = getPosition( me->x() ).getBar() * - MidiTime::ticksPerBar(); + const TimePos pos = getPosition( me->x() ).getBar() * + TimePos::ticksPerBar(); getTrack()->createTCO(pos); } } @@ -2038,11 +2038,11 @@ Track * TrackContentWidget::getTrack() * * \param posStart the starting position of the Widget (from getPosition()) */ -MidiTime TrackContentWidget::endPosition( const MidiTime & posStart ) +TimePos TrackContentWidget::endPosition( const TimePos & posStart ) { const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); const int w = width(); - return posStart + static_cast( w * MidiTime::ticksPerBar() / ppb ); + return posStart + static_cast( w * TimePos::ticksPerBar() / ppb ); } void TrackContentWidget::contextMenuEvent( QContextMenuEvent * cme ) @@ -2079,8 +2079,8 @@ void TrackContentWidget::contextMenuAction( QContextMenuEvent * cme, ContextMenu switch( action ) { case Paste: - // Paste the selection on the MidiTime of the context menu event - MidiTime tcoPos = getPosition( cme->x() ); + // Paste the selection on the TimePos of the context menu event + TimePos tcoPos = getPosition( cme->x() ); pasteSelection( tcoPos, getMimeData() ); break; @@ -2707,7 +2707,7 @@ void Track::loadSettings( const QDomElement & element ) && !node.toElement().attribute( "metadata" ).toInt() ) { TrackContentObject * tco = createTCO( - MidiTime( 0 ) ); + TimePos( 0 ) ); tco->restoreState( node.toElement() ); } } @@ -2803,7 +2803,7 @@ TrackContentObject * Track::getTCO( int tcoNum ) } printf( "called Track::getTCO( %d ), " "but TCO %d doesn't exist\n", tcoNum, tcoNum ); - return createTCO( tcoNum * MidiTime::ticksPerBar() ); + return createTCO( tcoNum * TimePos::ticksPerBar() ); } @@ -2847,8 +2847,8 @@ int Track::getTCONum( const TrackContentObject * tco ) * \param start The MIDI start time of the range. * \param end The MIDI endi time of the range. */ -void Track::getTCOsInRange( tcoVector & tcoV, const MidiTime & start, - const MidiTime & end ) +void Track::getTCOsInRange( tcoVector & tcoV, const TimePos & start, + const TimePos & end ) { for( TrackContentObject* tco : m_trackContentObjects ) { @@ -2880,7 +2880,7 @@ void Track::swapPositionOfTCOs( int tcoNum1, int tcoNum2 ) qSwap( m_trackContentObjects[tcoNum1], m_trackContentObjects[tcoNum2] ); - const MidiTime pos = m_trackContentObjects[tcoNum1]->startPosition(); + const TimePos pos = m_trackContentObjects[tcoNum1]->startPosition(); m_trackContentObjects[tcoNum1]->movePosition( m_trackContentObjects[tcoNum2]->startPosition() ); @@ -2894,9 +2894,9 @@ void Track::createTCOsForBB( int bb ) { while( numOfTCOs() < bb + 1 ) { - MidiTime position = MidiTime( numOfTCOs(), 0 ); + TimePos position = TimePos( numOfTCOs(), 0 ); TrackContentObject * tco = createTCO( position ); - tco->changeLength( MidiTime( 1, 0 ) ); + tco->changeLength( TimePos( 1, 0 ) ); } } @@ -2910,7 +2910,7 @@ void Track::createTCOsForBB( int bb ) * in ascending order by TCO time, once we hit a TCO that was earlier * than the insert time, we could fall out of the loop early. */ -void Track::insertBar( const MidiTime & pos ) +void Track::insertBar( const TimePos & pos ) { // we'll increase the position of every TCO, positioned behind pos, by // one bar @@ -2920,7 +2920,7 @@ void Track::insertBar( const MidiTime & pos ) if( ( *it )->startPosition() >= pos ) { ( *it )->movePosition( (*it)->startPosition() + - MidiTime::ticksPerBar() ); + TimePos::ticksPerBar() ); } } } @@ -2932,7 +2932,7 @@ void Track::insertBar( const MidiTime & pos ) * * \param pos The time at which we want to remove the bar. */ -void Track::removeBar( const MidiTime & pos ) +void Track::removeBar( const TimePos & pos ) { // we'll decrease the position of every TCO, positioned behind pos, by // one bar @@ -2941,7 +2941,7 @@ void Track::removeBar( const MidiTime & pos ) { if( ( *it )->startPosition() >= pos ) { - (*it)->movePosition((*it)->startPosition() - MidiTime::ticksPerBar()); + (*it)->movePosition((*it)->startPosition() - TimePos::ticksPerBar()); } } } @@ -2975,7 +2975,7 @@ bar_t Track::length() const } } - return last / MidiTime::ticksPerBar(); + return last / TimePos::ticksPerBar(); } diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index eac40ea6f..84846a77c 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -248,13 +248,13 @@ bool TrackContainer::isEmpty() const -AutomatedValueMap TrackContainer::automatedValuesAt(MidiTime time, int tcoNum) const +AutomatedValueMap TrackContainer::automatedValuesAt(TimePos time, int tcoNum) const { return automatedValuesFromTracks(tracks(), time, tcoNum); } -AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tracks, MidiTime time, int tcoNum) +AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tracks, TimePos time, int tcoNum) { Track::tcoVector tcos; @@ -295,7 +295,7 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra if (! p->hasAutomation()) { continue; } - MidiTime relTime = time - p->startPosition(); + TimePos relTime = time - p->startPosition(); if (! p->getAutoResize()) { relTime = qMin(relTime, p->length()); } @@ -311,9 +311,9 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra auto bbIndex = dynamic_cast(bb->getTrack())->index(); auto bbContainer = Engine::getBBTrackContainer(); - MidiTime bbTime = time - tco->startPosition(); + TimePos bbTime = time - tco->startPosition(); bbTime = std::min(bbTime, tco->length()); - bbTime = bbTime % (bbContainer->lengthOfBB(bbIndex) * MidiTime::ticksPerBar()); + bbTime = bbTime % (bbContainer->lengthOfBB(bbIndex) * TimePos::ticksPerBar()); auto bbValues = bbContainer->automatedValuesAt(bbTime, bbIndex); for (auto it=bbValues.begin(); it != bbValues.end(); it++) diff --git a/src/core/lv2/Lv2ControlBase.cpp b/src/core/lv2/Lv2ControlBase.cpp index e7ede9dd6..98fe7b13b 100644 --- a/src/core/lv2/Lv2ControlBase.cpp +++ b/src/core/lv2/Lv2ControlBase.cpp @@ -206,7 +206,7 @@ bool Lv2ControlBase::hasNoteInput() const void Lv2ControlBase::handleMidiInputEvent(const MidiEvent &event, - const MidiTime &time, f_cnt_t offset) + const TimePos &time, f_cnt_t offset) { for (auto& c : m_procs) { c->handleMidiInputEvent(event, time, offset); } } diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 0ab204ae9..2190a6f1d 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -50,7 +50,7 @@ struct MidiInputEvent { MidiEvent ev; - MidiTime time; + TimePos time; f_cnt_t offset; }; @@ -320,7 +320,7 @@ void Lv2Proc::run(fpp_t frames) // in case there will be a PR which removes this callback and instead adds a // `ringbuffer_t` to `class Instrument`, this // function (and the ringbuffer and its reader in `Lv2Proc`) will simply vanish -void Lv2Proc::handleMidiInputEvent(const MidiEvent &event, const MidiTime &time, f_cnt_t offset) +void Lv2Proc::handleMidiInputEvent(const MidiEvent &event, const TimePos &time, f_cnt_t offset) { if(m_midiIn) { diff --git a/src/core/midi/MidiAlsaSeq.cpp b/src/core/midi/MidiAlsaSeq.cpp index 56fd956d4..70c5a40c8 100644 --- a/src/core/midi/MidiAlsaSeq.cpp +++ b/src/core/midi/MidiAlsaSeq.cpp @@ -157,7 +157,7 @@ QString MidiAlsaSeq::probeDevice() -void MidiAlsaSeq::processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port ) +void MidiAlsaSeq::processOutEvent( const MidiEvent& event, const TimePos& time, const MidiPort* port ) { // HACK!!! - need a better solution which isn't that easy since we // cannot store const-ptrs in our map because we need to call non-const @@ -536,7 +536,7 @@ void MidiAlsaSeq::run() ev->data.note.velocity, source ), - MidiTime( ev->time.tick ) ); + TimePos( ev->time.tick ) ); break; case SND_SEQ_EVENT_NOTEOFF: @@ -547,7 +547,7 @@ void MidiAlsaSeq::run() ev->data.note.velocity, source ), - MidiTime( ev->time.tick) ); + TimePos( ev->time.tick) ); break; case SND_SEQ_EVENT_KEYPRESS: @@ -558,7 +558,7 @@ void MidiAlsaSeq::run() KeysPerOctave, ev->data.note.velocity, source - ), MidiTime() ); + ), TimePos() ); break; case SND_SEQ_EVENT_CONTROLLER: @@ -567,7 +567,7 @@ void MidiAlsaSeq::run() ev->data.control.channel, ev->data.control.param, ev->data.control.value, source ), - MidiTime() ); + TimePos() ); break; case SND_SEQ_EVENT_PGMCHANGE: @@ -576,7 +576,7 @@ void MidiAlsaSeq::run() ev->data.control.channel, ev->data.control.value, 0, source ), - MidiTime() ); + TimePos() ); break; case SND_SEQ_EVENT_CHANPRESS: @@ -585,14 +585,14 @@ void MidiAlsaSeq::run() ev->data.control.channel, ev->data.control.param, ev->data.control.value, source ), - MidiTime() ); + TimePos() ); break; case SND_SEQ_EVENT_PITCHBEND: dest->processInEvent( MidiEvent( MidiPitchBend, ev->data.control.channel, ev->data.control.value + 8192, 0, source ), - MidiTime() ); + TimePos() ); break; case SND_SEQ_EVENT_SENSING: diff --git a/src/core/midi/MidiApple.cpp b/src/core/midi/MidiApple.cpp index 0575b76ae..67e2084cf 100644 --- a/src/core/midi/MidiApple.cpp +++ b/src/core/midi/MidiApple.cpp @@ -57,7 +57,7 @@ MidiApple::~MidiApple() -void MidiApple::processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port ) +void MidiApple::processOutEvent( const MidiEvent& event, const TimePos& time, const MidiPort* port ) { qDebug("MidiApple:processOutEvent displayName:'%s'",port->displayName().toLatin1().constData()); diff --git a/src/core/midi/MidiClient.cpp b/src/core/midi/MidiClient.cpp index e37f59c06..b3d7e6363 100644 --- a/src/core/midi/MidiClient.cpp +++ b/src/core/midi/MidiClient.cpp @@ -266,7 +266,7 @@ void MidiClientRaw::processParsedEvent() -void MidiClientRaw::processOutEvent( const MidiEvent& event, const MidiTime & , const MidiPort* port ) +void MidiClientRaw::processOutEvent( const MidiEvent& event, const TimePos & , const MidiPort* port ) { // TODO: also evaluate _time and queue event if necessary switch( event.type() ) diff --git a/src/core/midi/MidiController.cpp b/src/core/midi/MidiController.cpp index 72128e184..93cea4a00 100644 --- a/src/core/midi/MidiController.cpp +++ b/src/core/midi/MidiController.cpp @@ -80,7 +80,7 @@ void MidiController::updateName() -void MidiController::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +void MidiController::processInEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset ) { unsigned char controllerNum; switch( event.type() ) diff --git a/src/core/midi/MidiPort.cpp b/src/core/midi/MidiPort.cpp index 4e97a6713..84d9cc8d1 100644 --- a/src/core/midi/MidiPort.cpp +++ b/src/core/midi/MidiPort.cpp @@ -120,7 +120,7 @@ void MidiPort::setMode( Mode mode ) -void MidiPort::processInEvent( const MidiEvent& event, const MidiTime& time ) +void MidiPort::processInEvent( const MidiEvent& event, const TimePos& time ) { // mask event if( isInputEnabled() && @@ -149,7 +149,7 @@ void MidiPort::processInEvent( const MidiEvent& event, const MidiTime& time ) -void MidiPort::processOutEvent( const MidiEvent& event, const MidiTime& time ) +void MidiPort::processOutEvent( const MidiEvent& event, const TimePos& time ) { // When output is enabled, route midi events if the selected channel matches // the event channel or if there's no selected channel (value 0, represented by "--") diff --git a/src/core/midi/MidiWinMM.cpp b/src/core/midi/MidiWinMM.cpp index ef60f3015..dbbc06ae1 100644 --- a/src/core/midi/MidiWinMM.cpp +++ b/src/core/midi/MidiWinMM.cpp @@ -49,7 +49,7 @@ MidiWinMM::~MidiWinMM() -void MidiWinMM::processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port ) +void MidiWinMM::processOutEvent( const MidiEvent& event, const TimePos& time, const MidiPort* port ) { const DWORD shortMsg = ( event.type() + event.channel() ) + ( ( event.param( 0 ) & 0xff ) << 8 ) + diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 1c9ac03a4..454121994 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -285,7 +285,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) const float y_scale = max - min; const float h = ( height() - 2 * TCO_BORDER_WIDTH ) / y_scale; - const float ppTick = ppb / MidiTime::ticksPerBar(); + const float ppTick = ppb / TimePos::ticksPerBar(); p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH ); p.scale( 1.0f, -h ); diff --git a/src/gui/ControllerConnectionDialog.cpp b/src/gui/ControllerConnectionDialog.cpp index 6b6527b33..e15b5aead 100644 --- a/src/gui/ControllerConnectionDialog.cpp +++ b/src/gui/ControllerConnectionDialog.cpp @@ -63,7 +63,7 @@ public: } - void processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset = 0 ) override + void processInEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ) override { if( event.type() == MidiControlChange && ( m_midiPort.inputChannel() == 0 || m_midiPort.inputChannel() == event.channel() + 1 ) ) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 7828dcfbc..b1de8e1a4 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1671,7 +1671,7 @@ void MainWindow::onSongStopped() { if(songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) ) { - songEditor->m_editor->updatePosition( MidiTime(tl->savedPos().getTicks() ) ); + songEditor->m_editor->updatePosition( TimePos(tl->savedPos().getTicks() ) ); } tl->savePos( -1 ); } diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index 070ac0a40..e7e7ca113 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -43,7 +43,7 @@ QPixmap * TimeLineWidget::s_posMarkerPixmap = NULL; TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, - Song::PlayPos & pos, const MidiTime & begin, Song::PlayModes mode, + Song::PlayPos & pos, const TimePos & begin, Song::PlayModes mode, QWidget * parent ) : QWidget( parent ), m_inactiveLoopColor( 52, 63, 53, 64 ), @@ -189,7 +189,7 @@ void TimeLineWidget::loadSettings( const QDomElement & _this ) -void TimeLineWidget::updatePosition( const MidiTime & ) +void TimeLineWidget::updatePosition( const TimePos & ) { const int new_x = markerX( m_pos ); @@ -266,14 +266,14 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) bar_t barNumber = m_begin.getBar(); int const x = m_xOffset + s_posMarkerPixmap->width() / 2 - - ( ( static_cast( m_begin * m_ppb ) / MidiTime::ticksPerBar() ) % static_cast( m_ppb ) ); + ( ( static_cast( m_begin * m_ppb ) / TimePos::ticksPerBar() ) % static_cast( m_ppb ) ); for( int i = 0; x + i * m_ppb < width(); ++i ) { ++barNumber; if( ( barNumber - 1 ) % qMax( 1, qRound( 1.0f / 3.0f * - MidiTime::ticksPerBar() / m_ppb ) ) == 0 ) + TimePos::ticksPerBar() / m_ppb ) ) == 0 ) { const int cx = x + qRound( i * m_ppb ); p.setPen( barLineColor ); @@ -330,8 +330,8 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) else if( event->button() == Qt::RightButton ) { m_moveXOff = s_posMarkerPixmap->width() / 2; - const MidiTime t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerBar() / m_ppb ); - const MidiTime loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2; + const TimePos t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb ); + const TimePos loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2; if( t < loopMid ) { @@ -366,7 +366,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) { parentWidget()->update(); // essential for widgets that this timeline had taken their mouse move event from. - const MidiTime t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerBar() / m_ppb ); + const TimePos t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb ); switch( m_action ) { @@ -405,13 +405,13 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) // Note, swap 1 and 0 below and the behavior "skips" the other // marking instead of pushing it. if( m_action == MoveLoopBegin ) - { - m_loopPos[0] -= MidiTime::ticksPerBar(); - } + { + m_loopPos[0] -= TimePos::ticksPerBar(); + } else - { - m_loopPos[1] += MidiTime::ticksPerBar(); - } + { + m_loopPos[1] += TimePos::ticksPerBar(); + } } update(); break; diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp index 9b51c76f2..fe73de1b1 100644 --- a/src/gui/TrackContainerView.cpp +++ b/src/gui/TrackContainerView.cpp @@ -122,9 +122,9 @@ TrackView * TrackContainerView::addTrackView( TrackView * _tv ) { m_trackViews.push_back( _tv ); m_scrollLayout->addWidget( _tv ); - connect( this, SIGNAL( positionChanged( const MidiTime & ) ), + connect( this, SIGNAL( positionChanged( const TimePos & ) ), _tv->getTrackContentWidget(), - SLOT( changePosition( const MidiTime & ) ) ); + SLOT( changePosition( const TimePos & ) ) ); realignTracks(); return( _tv ); } diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index b64cea0f5..c5116b928 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -150,10 +150,10 @@ AutomationEditor::AutomationEditor() : Song::Mode_PlayAutomationPattern ), m_currentPosition, Song::Mode_PlayAutomationPattern, this ); - connect( this, SIGNAL( positionChanged( const MidiTime & ) ), - m_timeLine, SLOT( updatePosition( const MidiTime & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ), - this, SLOT( updatePosition( const MidiTime & ) ) ); + connect( this, SIGNAL( positionChanged( const TimePos & ) ), + m_timeLine, SLOT( updatePosition( const TimePos & ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), + this, SLOT( updatePosition( const TimePos & ) ) ); removeSelection(); @@ -482,8 +482,8 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) x += xstep; i += 1; - m_pattern->removeValue( MidiTime( x ) ); - m_pattern->putValue( MidiTime( x ), y ); + m_pattern->removeValue( TimePos( x ) ); + m_pattern->putValue( TimePos( x ), y ); } } @@ -510,7 +510,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) x -= VALUES_WIDTH; // get tick in which the user clicked - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; // get time map of current pattern @@ -527,7 +527,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) if( pos_ticks >= it.key() && ( it+1==time_map.end() || pos_ticks <= (it+1).key() ) && - ( pos_ticks<= it.key() + MidiTime::ticksPerBar() *4 / m_ppb ) && + ( pos_ticks<= it.key() + TimePos::ticksPerBar() *4 / m_ppb ) && ( level == it.value() || mouseEvent->button() == Qt::RightButton ) ) { break; @@ -565,9 +565,9 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) if( it == time_map.end() ) { // then set new value - MidiTime value_pos( pos_ticks ); + TimePos value_pos( pos_ticks ); - MidiTime new_time = + TimePos new_time = m_pattern->setDragValue( value_pos, level, true, mouseEvent->modifiers() & @@ -584,7 +584,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) int aligned_x = (int)( (float)( ( it.key() - m_currentPosition ) * - m_ppb ) / MidiTime::ticksPerBar() ); + m_ppb ) / TimePos::ticksPerBar() ); m_moveXOffset = x - aligned_x - 1; // set move-cursor QCursor c( Qt::SizeAllCursor ); @@ -717,7 +717,7 @@ void AutomationEditor::removePoints( int x0, int x1 ) int i = 0; while( i <= deltax ) { - m_pattern->removeValue( MidiTime( x ) ); + m_pattern->removeValue( TimePos( x ) ); x += xstep; i += 1; } @@ -746,7 +746,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) x -= m_moveXOffset; } - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; // m_mouseDownLeft used to prevent drag when drawing line if (m_mouseDownLeft && m_editMode == DRAW) @@ -768,7 +768,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // we moved the value so the value has to be // moved properly according to new starting- // time in the time map of pattern - m_pattern->setDragValue( MidiTime( pos_ticks ), + m_pattern->setDragValue( TimePos( pos_ticks ), level, true, mouseEvent->modifiers() & Qt::ControlModifier ); @@ -879,7 +879,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } // get tick in which the cursor is posated - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; m_selectedTick = pos_ticks - m_selectStartTick; @@ -900,7 +900,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // move selection + selected values // do horizontal move-stuff - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; int ticks_diff = pos_ticks - m_moveStartTick; @@ -925,8 +925,8 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } m_selectStartTick += ticks_diff; - int bar_diff = ticks_diff / MidiTime::ticksPerBar(); - ticks_diff = ticks_diff % MidiTime::ticksPerBar(); + int bar_diff = ticks_diff / TimePos::ticksPerBar(); + ticks_diff = ticks_diff % TimePos::ticksPerBar(); // do vertical move-stuff @@ -971,27 +971,27 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) for( timeMap::iterator it = m_selValuesForMove.begin(); it != m_selValuesForMove.end(); ++it ) { - MidiTime new_value_pos; + TimePos new_value_pos; if( it.key() ) { int value_bar = ( it.key() / - MidiTime::ticksPerBar() ) + TimePos::ticksPerBar() ) + bar_diff; int value_ticks = ( it.key() % - MidiTime::ticksPerBar() ) + TimePos::ticksPerBar() ) + ticks_diff; // ensure value_ticks range - if( value_ticks / MidiTime::ticksPerBar() ) + if( value_ticks / TimePos::ticksPerBar() ) { value_bar += value_ticks - / MidiTime::ticksPerBar(); + / TimePos::ticksPerBar(); value_ticks %= - MidiTime::ticksPerBar(); + TimePos::ticksPerBar(); } m_pattern->removeValue( it.key() ); - new_value_pos = MidiTime( value_bar, + new_value_pos = TimePos( value_bar, value_ticks ); } new_selValuesForMove[ @@ -1039,7 +1039,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } // get tick in which the cursor is posated - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; m_selectedTick = pos_ticks - @@ -1295,7 +1295,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) / static_cast( Engine::getSong()->getTimeSigModel().getDenominator() ); float zoomFactor = m_zoomXLevels[m_zoomingXModel.value()]; //the bars which disappears at the left side by scrolling - int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerBar(); + int leftBars = m_currentPosition * zoomFactor / TimePos::ticksPerBar(); //iterates the visible bars and draw the shading on uneven bars for( int x = VALUES_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppb, ++barCount ) @@ -1321,10 +1321,10 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) } // and finally bars - for( tick = m_currentPosition - m_currentPosition % MidiTime::ticksPerBar(), + for( tick = m_currentPosition - m_currentPosition % TimePos::ticksPerBar(), x = xCoordOfTick( tick ); x<=width(); - tick += MidiTime::ticksPerBar(), x = xCoordOfTick( tick ) ) + tick += TimePos::ticksPerBar(), x = xCoordOfTick( tick ) ) { p.setPen( barLineColor() ); p.drawLine( x, grid_bottom, x, x_line_end ); @@ -1460,8 +1460,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // now draw selection-frame int x = ( sel_pos_start - m_currentPosition ) * m_ppb / - MidiTime::ticksPerBar(); - int w = ( sel_pos_end - sel_pos_start ) * m_ppb / MidiTime::ticksPerBar(); + TimePos::ticksPerBar(); + int w = ( sel_pos_end - sel_pos_start ) * m_ppb / TimePos::ticksPerBar(); int y, h; if( m_y_auto ) { @@ -1533,7 +1533,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) int AutomationEditor::xCoordOfTick(int tick ) { return VALUES_WIDTH + ( ( tick - m_currentPosition ) - * m_ppb / MidiTime::ticksPerBar() ); + * m_ppb / TimePos::ticksPerBar() ); } @@ -1717,7 +1717,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) } x = qBound( 0, x, m_zoomingXModel.size() - 1 ); - int mouseX = (position( we ).x() - VALUES_WIDTH)* MidiTime::ticksPerBar(); + int mouseX = (position( we ).x() - VALUES_WIDTH)* TimePos::ticksPerBar(); // ticks based on the mouse x-position where the scroll wheel was used int ticks = mouseX / m_ppb; // what would be the ticks in the new zoom level on the very same mouse x @@ -1994,7 +1994,7 @@ void AutomationEditor::getSelectedValues( timeMap & selected_values ) ++it ) { //TODO: Add constant - tick_t len_ticks = MidiTime::ticksPerBar() / 16; + tick_t len_ticks = TimePos::ticksPerBar() / 16; float level = it.value(); tick_t pos_ticks = it.key(); @@ -2123,7 +2123,7 @@ void AutomationEditor::deleteSelectedValues() -void AutomationEditor::updatePosition(const MidiTime & t ) +void AutomationEditor::updatePosition(const TimePos & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == @@ -2131,17 +2131,17 @@ void AutomationEditor::updatePosition(const MidiTime & t ) m_scrollBack == true ) { const int w = width() - VALUES_WIDTH; - if( t > m_currentPosition + w * MidiTime::ticksPerBar() / m_ppb ) + if( t > m_currentPosition + w * TimePos::ticksPerBar() / m_ppb ) { m_leftRightScroll->setValue( t.getBar() * - MidiTime::ticksPerBar() ); + TimePos::ticksPerBar() ); } else if( t < m_currentPosition ) { - MidiTime t_ = qMax( t - w * MidiTime::ticksPerBar() * - MidiTime::ticksPerBar() / m_ppb, 0 ); + TimePos t_ = qMax( t - w * TimePos::ticksPerBar() * + TimePos::ticksPerBar() / m_ppb, 0 ); m_leftRightScroll->setValue( t_.getBar() * - MidiTime::ticksPerBar() ); + TimePos::ticksPerBar() ); } m_scrollBack = false; } diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index ffafc4577..1406e683d 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -260,7 +260,7 @@ void BBTrackContainerView::dropEvent(QDropEvent* de) hasValidBBTCOs = true; for (int i = 0; i < t->getTCOs().size(); ++i) { - if (t->getTCOs()[i]->startPosition() != MidiTime(i, 0)) + if (t->getTCOs()[i]->startPosition() != TimePos(i, 0)) { hasValidBBTCOs = false; break; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 194867ce4..c99176cc7 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -174,7 +174,7 @@ PianoRoll::PianoRoll() : m_whiteKeySmallHeight(qFloor(m_keyLineHeight * 1.5)), m_whiteKeyBigHeight(m_keyLineHeight * 2), m_blackKeyHeight(m_keyLineHeight), - m_lenOfNewNotes( MidiTime( 0, DefaultTicksPerBar/4 ) ), + m_lenOfNewNotes( TimePos( 0, DefaultTicksPerBar/4 ) ), m_lastNoteVolume( DefaultVolume ), m_lastNotePanning( DefaultPanning ), m_minResizeLen( 0 ), @@ -285,28 +285,28 @@ PianoRoll::PianoRoll() : Song::Mode_PlayPattern ), m_currentPosition, Song::Mode_PlayPattern, this ); - connect( this, SIGNAL( positionChanged( const MidiTime & ) ), - m_timeLine, SLOT( updatePosition( const MidiTime & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ), - this, SLOT( updatePosition( const MidiTime & ) ) ); + connect( this, SIGNAL( positionChanged( const TimePos & ) ), + m_timeLine, SLOT( updatePosition( const TimePos & ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), + this, SLOT( updatePosition( const TimePos & ) ) ); // white position line follows timeline marker m_positionLine = new PositionLine(this); //update timeline when in step-recording mode - connect( &m_stepRecorderWidget, SIGNAL( positionChanged( const MidiTime & ) ), - this, SLOT( updatePositionStepRecording( const MidiTime & ) ) ); + connect( &m_stepRecorderWidget, SIGNAL( positionChanged( const TimePos & ) ), + this, SLOT( updatePositionStepRecording( const TimePos & ) ) ); // update timeline when in record-accompany mode connect( Engine::getSong()->getPlayPos( Song::Mode_PlaySong ).m_timeLine, - SIGNAL( positionChanged( const MidiTime & ) ), + SIGNAL( positionChanged( const TimePos & ) ), this, - SLOT( updatePositionAccompany( const MidiTime & ) ) ); + SLOT( updatePositionAccompany( const TimePos & ) ) ); // TODO /* connect( engine::getSong()->getPlayPos( Song::Mode_PlayBB ).m_timeLine, - SIGNAL( positionChanged( const MidiTime & ) ), + SIGNAL( positionChanged( const TimePos & ) ), this, - SLOT( updatePositionAccompany( const MidiTime & ) ) );*/ + SLOT( updatePositionAccompany( const TimePos & ) ) );*/ removeSelection(); @@ -686,10 +686,10 @@ void PianoRoll::glueNotes() // position or next in sequence. if ((*note)->key() == (*nextNote)->key() && (*nextNote)->pos() <= (*note)->pos() - + qMax(MidiTime(0), (*note)->length())) + + qMax(TimePos(0), (*note)->length())) { (*note)->setLength(qMax((*note)->length(), - MidiTime((*nextNote)->endPos() - (*note)->pos()))); + TimePos((*nextNote)->endPos() - (*note)->pos()))); noteToRemove.push_back(*nextNote); ++nextNote; } @@ -827,7 +827,7 @@ void PianoRoll::selectRegionFromPixels( int xStart, int xEnd ) xEnd -= m_whiteKeyWidth; // select an area of notes - int posTicks = xStart * MidiTime::ticksPerBar() / m_ppb + + int posTicks = xStart * TimePos::ticksPerBar() / m_ppb + m_currentPosition; int keyNum = 0; m_selectStartTick = posTicks; @@ -837,7 +837,7 @@ void PianoRoll::selectRegionFromPixels( int xStart, int xEnd ) // change size of selection // get tick in which the cursor is posated - posTicks = xEnd * MidiTime::ticksPerBar() / m_ppb + + posTicks = xEnd * TimePos::ticksPerBar() / m_ppb + m_currentPosition; keyNum = 120; @@ -987,7 +987,7 @@ void PianoRoll::drawDetuningInfo( QPainter & _p, const Note * _n, int _x, for( timeMap::ConstIterator it = map.begin(); it != map.end(); ++it ) { int pos_ticks = it.key(); - int pos_x = _x + pos_ticks * m_ppb / MidiTime::ticksPerBar(); + int pos_x = _x + pos_ticks * m_ppb / TimePos::ticksPerBar(); const float level = it.value(); @@ -1200,7 +1200,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) // Move selected notes by one bar to the left if (hasValidPattern()) { - shiftPos( direction * MidiTime::ticksPerBar() ); + shiftPos( direction * TimePos::ticksPerBar() ); } } else if( ke->modifiers() & Qt::ShiftModifier && m_action == ActionNone) @@ -1498,7 +1498,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) x -= m_whiteKeyWidth; // get tick in which the user clicked - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; @@ -1512,7 +1512,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) for( int i = 0; i < notes.size(); ++i ) { Note *note = *it; - MidiTime len = note->length(); + TimePos len = note->length(); if( len < 0 ) { len = 4; @@ -1528,7 +1528,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) || ( edit_note && pos_ticks <= note->pos() + - NOTE_EDIT_LINE_WIDTH * MidiTime::ticksPerBar() / m_ppb ) + NOTE_EDIT_LINE_WIDTH * TimePos::ticksPerBar() / m_ppb ) ) ) { @@ -1569,8 +1569,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) // +32 to quanitize the note correctly when placing notes with // the mouse. We do this here instead of in note.quantized // because live notes should still be quantized at the half. - MidiTime note_pos( pos_ticks - ( quantization() / 2 ) ); - MidiTime note_len( newNoteLen() ); + TimePos note_pos( pos_ticks - ( quantization() / 2 ) ); + TimePos note_len( newNoteLen() ); Note new_note( note_len, note_pos, key_num ); new_note.setSelected( true ); @@ -1649,8 +1649,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } // clicked at the "tail" of the note? - if( pos_ticks * m_ppb / MidiTime::ticksPerBar() > - m_currentNote->endPos() * m_ppb / MidiTime::ticksPerBar() - RESIZE_AREA_WIDTH + if( pos_ticks * m_ppb / TimePos::ticksPerBar() > + m_currentNote->endPos() * m_ppb / TimePos::ticksPerBar() - RESIZE_AREA_WIDTH && m_currentNote->length() > 0 ) { m_pattern->addJournalCheckPoint(); @@ -1807,10 +1807,10 @@ void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me ) int pixel_range = 4; int x = me->x() - m_whiteKeyWidth; const int ticks_start = ( x-pixel_range/2 ) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; const int ticks_end = ( x+pixel_range/2 ) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; - const int ticks_middle = x * MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; + const int ticks_middle = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; // go through notes to figure out which one we want to change bool altPressed = me->modifiers() & Qt::AltModifier; @@ -2218,9 +2218,9 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) // convert to ticks so that we can check which notes // are in the range int ticks_start = ( x-pixel_range/2 ) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; int ticks_end = ( x+pixel_range/2 ) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; // get note-vector of current pattern const NoteVector & notes = m_pattern->notes(); @@ -2316,7 +2316,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) // set move- or resize-cursor // get tick in which the cursor is posated - int pos_ticks = ( x * MidiTime::ticksPerBar() ) / + int pos_ticks = ( x * TimePos::ticksPerBar() ) / m_ppb + m_currentPosition; // get note-vector of current pattern @@ -2349,7 +2349,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) Note *note = *it; // x coordinate of the right edge of the note int noteRightX = ( note->pos() + note->length() - - m_currentPosition) * m_ppb/MidiTime::ticksPerBar(); + m_currentPosition) * m_ppb/TimePos::ticksPerBar(); // cursor at the "tail" of the note? bool atTail = note->length() > 0 && x > noteRightX - RESIZE_AREA_WIDTH; @@ -2370,7 +2370,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) // change size of selection // get tick in which the cursor is posated - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; m_selectedTick = pos_ticks - m_selectStartTick; @@ -2392,7 +2392,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) // any key if in erase mode // get tick in which the user clicked - int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb + + int pos_ticks = x * TimePos::ticksPerBar() / m_ppb + m_currentPosition; @@ -2406,7 +2406,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) while( it != notes.end() ) { Note *note = *it; - MidiTime len = note->length(); + TimePos len = note->length(); if( len < 0 ) { len = 4; @@ -2423,7 +2423,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) ( edit_note && pos_ticks <= note->pos() + NOTE_EDIT_LINE_WIDTH * - MidiTime::ticksPerBar() / + TimePos::ticksPerBar() / m_ppb ) ) ) @@ -2479,7 +2479,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) } // get tick in which the cursor is posated - int pos_ticks = x * MidiTime::ticksPerBar()/ m_ppb + + int pos_ticks = x * TimePos::ticksPerBar()/ m_ppb + m_currentPosition; m_selectedTick = pos_ticks - @@ -2540,7 +2540,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) // convert pixels to ticks and keys int off_x = x - m_moveStartX; - int off_ticks = off_x * MidiTime::ticksPerBar() / m_ppb; + int off_ticks = off_x * TimePos::ticksPerBar() / m_ppb; int off_key = getKey( y ) - getKey( m_moveStartY ); // handle scroll changes while dragging @@ -2588,7 +2588,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) { ticks_new = 1; } - note->setLength( MidiTime( ticks_new ) ); + note->setLength( TimePos( ticks_new ) ); m_lenOfNewNotes = note->length(); } else @@ -2603,7 +2603,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) key_num = qMax(0, key_num); key_num = qMin(key_num, NumKeys); - note->setPos( MidiTime( pos_ticks ) ); + note->setPos( TimePos( pos_ticks ) ); note->setKey( key_num ); } } @@ -2680,8 +2680,8 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) posteriorDeltaThisFrame = (newStart+newLength) - (note->pos().getTicks() + note->length().getTicks()); } - note->setLength( MidiTime(newLength) ); - note->setPos( MidiTime(newStart) ); + note->setLength( TimePos(newLength) ); + note->setPos( TimePos(newStart) ); m_lenOfNewNotes = note->length(); } @@ -2693,7 +2693,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) if (!note->selected() && note->pos().getTicks() >= posteriorEndTick) { int newStart = note->pos().getTicks() + posteriorDeltaThisFrame; - note->setPos( MidiTime(newStart) ); + note->setPos( TimePos(newStart) ); } } } @@ -2706,7 +2706,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) for (Note *note : selectedNotes) { int newLength = qMax(minLength, note->oldLength() + off_ticks); - note->setLength(MidiTime(newLength)); + note->setLength(TimePos(newLength)); m_lenOfNewNotes = note->length(); } @@ -2821,7 +2821,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } auto xCoordOfTick = [=](int tick) { return m_whiteKeyWidth + ( - (tick - m_currentPosition) * m_ppb / MidiTime::ticksPerBar() + (tick - m_currentPosition) * m_ppb / TimePos::ticksPerBar() ); }; p.setPen(m_lineColor); @@ -2987,7 +2987,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) static_cast(Engine::getSong()->getTimeSigModel().getDenominator()); float zoomFactor = m_zoomLevels[m_zoomingModel.value()]; //the bars which disappears at the left side by scrolling - int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerBar(); + int leftBars = m_currentPosition * zoomFactor / TimePos::ticksPerBar(); //iterates the visible bars and draw the shading on uneven bars for (int x = m_whiteKeyWidth, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; @@ -3017,10 +3017,10 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // draw vertical bar lines p.setPen(m_barLineColor); - for(tick = m_currentPosition - m_currentPosition % MidiTime::ticksPerBar(), + for(tick = m_currentPosition - m_currentPosition % TimePos::ticksPerBar(), x = xCoordOfTick( tick ); x <= width(); - tick += MidiTime::ticksPerBar(), x = xCoordOfTick(tick)) + tick += TimePos::ticksPerBar(), x = xCoordOfTick(tick)) { p.drawLine(x, PR_TOP_MARGIN, x, noteEditBottom()); } @@ -3117,9 +3117,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) int pos_ticks = note->pos(); - int note_width = len_ticks * m_ppb / MidiTime::ticksPerBar(); + int note_width = len_ticks * m_ppb / TimePos::ticksPerBar(); const int x = ( pos_ticks - m_currentPosition ) * - m_ppb / MidiTime::ticksPerBar(); + m_ppb / TimePos::ticksPerBar(); // skip this note if not in visible area at all if (!(x + note_width >= 0 && x <= width() - m_whiteKeyWidth)) { @@ -3158,9 +3158,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) int pos_ticks = note->pos(); - int note_width = len_ticks * m_ppb / MidiTime::ticksPerBar(); + int note_width = len_ticks * m_ppb / TimePos::ticksPerBar(); const int x = ( pos_ticks - m_currentPosition ) * - m_ppb / MidiTime::ticksPerBar(); + m_ppb / TimePos::ticksPerBar(); // skip this note if not in visible area at all if (!(x + note_width >= 0 && x <= width() - m_whiteKeyWidth)) { @@ -3245,9 +3245,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) int pos_ticks = note->pos(); - int note_width = len_ticks * m_ppb / MidiTime::ticksPerBar(); + int note_width = len_ticks * m_ppb / TimePos::ticksPerBar(); const int x = ( pos_ticks - m_currentPosition ) * - m_ppb / MidiTime::ticksPerBar(); + m_ppb / TimePos::ticksPerBar(); // skip this note if not in visible area at all if (!(x + note_width >= 0 && x <= width() - m_whiteKeyWidth)) { @@ -3290,9 +3290,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // now draw selection-frame int x = ( ( sel_pos_start - m_currentPosition ) * m_ppb ) / - MidiTime::ticksPerBar(); + TimePos::ticksPerBar(); int w = ( ( ( sel_pos_end - m_currentPosition ) * m_ppb ) / - MidiTime::ticksPerBar() ) - x; + TimePos::ticksPerBar() ) - x; int y = (int) y_base - sel_key_start * m_keyLineHeight; int h = (int) y_base - sel_key_end * m_keyLineHeight - y; p.setPen(m_selectedNoteColor); @@ -3414,9 +3414,9 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) int pixel_range = 8; int x = position(we).x() - m_whiteKeyWidth; int ticks_start = ( x - pixel_range / 2 ) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; int ticks_end = ( x + pixel_range / 2 ) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; // When alt is pressed we only edit the note under the cursor bool altPressed = we->modifiers() & Qt::AltModifier; @@ -3517,7 +3517,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) } z = qBound( 0, z, m_zoomingModel.size() - 1 ); - int x = (position(we).x() - m_whiteKeyWidth) * MidiTime::ticksPerBar(); + int x = (position(we).x() - m_whiteKeyWidth) * TimePos::ticksPerBar(); // ticks based on the mouse x-position where the scroll wheel was used int ticks = x / m_ppb; // what would be the ticks in the new zoom level on the very same mouse x @@ -3728,7 +3728,7 @@ void PianoRoll::startRecordNote(const Note & n ) (Engine::getSong()->playMode() == desiredPlayModeForAccompany() || Engine::getSong()->playMode() == Song::Mode_PlayPattern )) { - MidiTime sub; + TimePos sub; if( Engine::getSong()->playMode() == Song::Mode_PlaySong ) { sub = m_pattern->startPosition(); @@ -3977,7 +3977,7 @@ void PianoRoll::copyToClipboard( const NoteVector & notes ) const QDomElement note_list = dataFile.createElement( "note-list" ); dataFile.content().appendChild( note_list ); - MidiTime start_pos( notes.front()->pos().getBar(), 0 ); + TimePos start_pos( notes.front()->pos().getBar(), 0 ); for( const Note *note : notes ) { Note clip_note( *note ); @@ -4108,18 +4108,18 @@ bool PianoRoll::deleteSelectedNotes() -void PianoRoll::autoScroll( const MidiTime & t ) +void PianoRoll::autoScroll( const TimePos & t ) { const int w = width() - m_whiteKeyWidth; - if( t > m_currentPosition + w * MidiTime::ticksPerBar() / m_ppb ) + if( t > m_currentPosition + w * TimePos::ticksPerBar() / m_ppb ) { - m_leftRightScroll->setValue( t.getBar() * MidiTime::ticksPerBar() ); + m_leftRightScroll->setValue( t.getBar() * TimePos::ticksPerBar() ); } else if( t < m_currentPosition ) { - MidiTime t2 = qMax( t - w * MidiTime::ticksPerBar() * - MidiTime::ticksPerBar() / m_ppb, (tick_t) 0 ); - m_leftRightScroll->setValue( t2.getBar() * MidiTime::ticksPerBar() ); + TimePos t2 = qMax( t - w * TimePos::ticksPerBar() * + TimePos::ticksPerBar() / m_ppb, (tick_t) 0 ); + m_leftRightScroll->setValue( t2.getBar() * TimePos::ticksPerBar() ); } m_scrollBack = false; } @@ -4127,7 +4127,7 @@ void PianoRoll::autoScroll( const MidiTime & t ) -void PianoRoll::updatePosition( const MidiTime & t ) +void PianoRoll::updatePosition( const TimePos & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == Song::Mode_PlayPattern @@ -4136,7 +4136,7 @@ void PianoRoll::updatePosition( const MidiTime & t ) { autoScroll( t ); } - const int pos = m_timeLine->pos() * m_ppb / MidiTime::ticksPerBar(); + const int pos = m_timeLine->pos() * m_ppb / TimePos::ticksPerBar(); if (pos >= m_currentPosition && pos <= m_currentPosition + width() - m_whiteKeyWidth) { m_positionLine->show(); @@ -4157,14 +4157,14 @@ void PianoRoll::updatePositionLineHeight() -void PianoRoll::updatePositionAccompany( const MidiTime & t ) +void PianoRoll::updatePositionAccompany( const TimePos & t ) { Song * s = Engine::getSong(); if( m_recording && hasValidPattern() && s->playMode() != Song::Mode_PlayPattern ) { - MidiTime pos = t; + TimePos pos = t; if( s->playMode() != Song::Mode_PlayBB ) { pos -= m_pattern->startPosition(); @@ -4178,7 +4178,7 @@ void PianoRoll::updatePositionAccompany( const MidiTime & t ) } -void PianoRoll::updatePositionStepRecording( const MidiTime & t ) +void PianoRoll::updatePositionStepRecording( const TimePos & t ) { if( m_stepRecorder.isRecording() ) { @@ -4269,7 +4269,7 @@ void PianoRoll::quantizeNotes() for( Note* n : notes ) { - if( n->length() == MidiTime( 0 ) ) + if( n->length() == TimePos( 0 ) ) { continue; } @@ -4304,7 +4304,7 @@ void PianoRoll::updateSemiToneMarkerMenu() -MidiTime PianoRoll::newNoteLen() const +TimePos PianoRoll::newNoteLen() const { if( m_noteLenModel.value() == 0 ) { @@ -4340,7 +4340,7 @@ Note * PianoRoll::noteUnderMouse() int key_num = getKey( pos.y() ); int pos_ticks = (pos.x() - m_whiteKeyWidth) * - MidiTime::ticksPerBar() / m_ppb + m_currentPosition; + TimePos::ticksPerBar() / m_ppb + m_currentPosition; // loop through whole note-vector... for( Note* const& note : m_pattern->notes() ) diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 8829bedfd..39fa1f627 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -69,7 +69,7 @@ SongEditor::SongEditor( Song * song ) : m_scrollPos(), m_mousePos(), m_rubberBandStartTrackview(0), - m_rubberbandStartMidipos(0), + m_rubberbandStartTimePos(0), m_currentZoomingValue(m_zoomingModel->value()), m_trackHeadWidth(ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt()==1 ? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT @@ -83,11 +83,11 @@ SongEditor::SongEditor( Song * song ) : m_song->m_playPos[Song::Mode_PlaySong], m_currentPosition, Song::Mode_PlaySong, this ); - connect( this, SIGNAL( positionChanged( const MidiTime & ) ), + connect( this, SIGNAL( positionChanged( const TimePos & ) ), m_song->m_playPos[Song::Mode_PlaySong].m_timeLine, - SLOT( updatePosition( const MidiTime & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ), - this, SLOT( updatePosition( const MidiTime & ) ) ); + SLOT( updatePosition( const TimePos & ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), + this, SLOT( updatePosition( const TimePos & ) ) ); connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ), this, SLOT( selectRegionFromPixels( int, int ) ) ); connect( m_timeLine, SIGNAL( selectionFinished() ), @@ -339,7 +339,7 @@ void SongEditor::setHighQuality( bool hq ) void SongEditor::scrolled( int new_pos ) { update(); - emit positionChanged( m_currentPosition = MidiTime( new_pos, 0 ) ); + emit positionChanged( m_currentPosition = TimePos( new_pos, 0 ) ); } @@ -363,8 +363,8 @@ void SongEditor::selectRegionFromPixels(int xStart, int xEnd) m_currentZoomingValue = zoomingModel()->value(); //calculate the song position where the mouse was clicked - m_rubberbandStartMidipos = MidiTime((xStart - m_trackHeadWidth) - / pixelsPerBar() * MidiTime::ticksPerBar()) + m_rubberbandStartTimePos = TimePos((xStart - m_trackHeadWidth) + / pixelsPerBar() * TimePos::ticksPerBar()) + m_currentPosition; m_rubberBandStartTrackview = 0; } @@ -413,9 +413,9 @@ void SongEditor::updateRubberband() //the index of the TrackView the mouse is hover int rubberBandTrackview = trackIndexFromSelectionPoint(m_mousePos.y()); - //the miditime the mouse is hover - MidiTime rubberbandMidipos = MidiTime((qMin(m_mousePos.x(), width()) - m_trackHeadWidth) - / pixelsPerBar() * MidiTime::ticksPerBar()) + //the time position the mouse is hover + TimePos rubberbandTimePos = TimePos((qMin(m_mousePos.x(), width()) - m_trackHeadWidth) + / pixelsPerBar() * TimePos::ticksPerBar()) + m_currentPosition; //are tcos in the rect of selection? @@ -427,9 +427,9 @@ void SongEditor::updateRubberband() auto indexOfTrackView = trackViews().indexOf(tco->getTrackView()); bool isBeetweenRubberbandViews = indexOfTrackView >= qMin(m_rubberBandStartTrackview, rubberBandTrackview) && indexOfTrackView <= qMax(m_rubberBandStartTrackview, rubberBandTrackview); - bool isBeetweenRubberbandMidiPos = tco->getTrackContentObject()->endPosition() >= qMin(m_rubberbandStartMidipos, rubberbandMidipos) - && tco->getTrackContentObject()->startPosition() <= qMax(m_rubberbandStartMidipos, rubberbandMidipos); - it->setSelected(isBeetweenRubberbandViews && isBeetweenRubberbandMidiPos); + bool isBeetweenRubberbandTimePos = tco->getTrackContentObject()->endPosition() >= qMin(m_rubberbandStartTimePos, rubberbandTimePos) + && tco->getTrackContentObject()->startPosition() <= qMax(m_rubberbandStartTimePos, rubberbandTimePos); + it->setSelected(isBeetweenRubberbandViews && isBeetweenRubberbandTimePos); } } } @@ -476,7 +476,7 @@ void SongEditor::keyPressEvent( QKeyEvent * ke ) } else if( ke->key() == Qt::Key_Left ) { - tick_t t = m_song->currentTick() - MidiTime::ticksPerBar(); + tick_t t = m_song->currentTick() - TimePos::ticksPerBar(); if( t >= 0 ) { m_song->setPlayPos( t, Song::Mode_PlaySong ); @@ -484,7 +484,7 @@ void SongEditor::keyPressEvent( QKeyEvent * ke ) } else if( ke->key() == Qt::Key_Right ) { - tick_t t = m_song->currentTick() + MidiTime::ticksPerBar(); + tick_t t = m_song->currentTick() + TimePos::ticksPerBar(); if( t < MaxSongLength ) { m_song->setPlayPos( t, Song::Mode_PlaySong ); @@ -608,10 +608,10 @@ void SongEditor::mousePressEvent(QMouseEvent *me) rubberBand()->setGeometry(QRect(m_origin, QSize())); rubberBand()->show(); - //the trackView(index) and the miditime where the mouse was clicked + //the trackView(index) and the time position where the mouse was clicked m_rubberBandStartTrackview = trackIndexFromSelectionPoint(me->y()); - m_rubberbandStartMidipos = MidiTime((me->x() - m_trackHeadWidth) - / pixelsPerBar() * MidiTime::ticksPerBar()) + m_rubberbandStartTimePos = TimePos((me->x() - m_trackHeadWidth) + / pixelsPerBar() * TimePos::ticksPerBar()) + m_currentPosition; } QWidget::mousePressEvent(me); @@ -766,7 +766,7 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth -void SongEditor::updatePosition( const MidiTime & t ) +void SongEditor::updatePosition( const TimePos & t ) { int widgetWidth, trackOpWidth; if( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() ) @@ -788,7 +788,7 @@ void SongEditor::updatePosition( const MidiTime & t ) const int w = width() - widgetWidth - trackOpWidth - contentWidget()->verticalScrollBar()->width(); // width of right scrollbar - if( t > m_currentPosition + w * MidiTime::ticksPerBar() / + if( t > m_currentPosition + w * TimePos::ticksPerBar() / pixelsPerBar() ) { animateScroll( m_leftRightScroll, t.getBar(), m_smoothScroll ); diff --git a/src/gui/widgets/StepRecorderWidget.cpp b/src/gui/widgets/StepRecorderWidget.cpp index d2157ef66..65deb0d0a 100644 --- a/src/gui/widgets/StepRecorderWidget.cpp +++ b/src/gui/widgets/StepRecorderWidget.cpp @@ -53,7 +53,7 @@ void StepRecorderWidget::setPixelsPerBar(int ppb) m_ppb = ppb; } -void StepRecorderWidget::setCurrentPosition(MidiTime currentPosition) +void StepRecorderWidget::setCurrentPosition(TimePos currentPosition) { m_currentPosition = currentPosition; } @@ -76,12 +76,12 @@ void StepRecorderWidget::setBottomMargin(const int marginBottom) m_marginBottom = marginBottom; } -void StepRecorderWidget::setStartPosition(MidiTime pos) +void StepRecorderWidget::setStartPosition(TimePos pos) { m_curStepStartPos = pos; } -void StepRecorderWidget::setEndPosition(MidiTime pos) +void StepRecorderWidget::setEndPosition(TimePos pos) { m_curStepEndPos = pos; emit positionChanged(m_curStepEndPos); @@ -93,7 +93,7 @@ void StepRecorderWidget::showHint() embed::getIconPixmap("hint")); } -void StepRecorderWidget::setStepsLength(MidiTime stepsLength) +void StepRecorderWidget::setStepsLength(TimePos stepsLength) { m_stepsLength = stepsLength; } @@ -109,7 +109,7 @@ void StepRecorderWidget::paintEvent(QPaintEvent * pe) //draw steps ruler painter.setPen(m_colorLineEnd); - MidiTime curPos = m_curStepEndPos; + TimePos curPos = m_curStepEndPos; int x = xCoordOfTick(curPos); while(x <= m_right) { @@ -138,7 +138,7 @@ void StepRecorderWidget::paintEvent(QPaintEvent * pe) int StepRecorderWidget::xCoordOfTick(int tick) { - return m_marginLeft + ((tick - m_currentPosition) * m_ppb / MidiTime::ticksPerBar()); + return m_marginLeft + ((tick - m_currentPosition) * m_ppb / TimePos::ticksPerBar()); } @@ -151,7 +151,7 @@ void StepRecorderWidget::drawVerLine(QPainter* painter, int x, const QColor& col } } -void StepRecorderWidget::drawVerLine(QPainter* painter, const MidiTime& pos, const QColor& color, int top, int bottom) +void StepRecorderWidget::drawVerLine(QPainter* painter, const TimePos& pos, const QColor& color, int top, int bottom) { drawVerLine(painter, xCoordOfTick(pos), color, top, bottom); } diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index fe3622921..dfb0df480 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -40,7 +40,7 @@ AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : setName( tr( "Automation track" ) ); } -bool AutomationTrack::play( const MidiTime & time_start, const fpp_t _frames, +bool AutomationTrack::play( const TimePos & time_start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num ) { return false; @@ -57,7 +57,7 @@ TrackView * AutomationTrack::createView( TrackContainerView* tcv ) -TrackContentObject* AutomationTrack::createTCO(const MidiTime & pos) +TrackContentObject* AutomationTrack::createTCO(const TimePos & pos) { AutomationPattern* p = new AutomationPattern(this); p->movePosition(pos); @@ -119,11 +119,11 @@ void AutomationTrackView::dropEvent( QDropEvent * _de ) journallingObject( val.toInt() ) ); if( mod != NULL ) { - MidiTime pos = MidiTime( trackContainerView()-> + TimePos pos = TimePos( trackContainerView()-> currentPosition() + ( _de->pos().x() - getTrackContentWidget()->x() ) * - MidiTime::ticksPerBar() / + TimePos::ticksPerBar() / static_cast( trackContainerView()->pixelsPerBar() ) ) .toAbsoluteBar(); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 5ec03db30..8de8437ab 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -52,7 +52,7 @@ BBTCO::BBTCO( Track * _track ) : if( t > 0 ) { saveJournallingState( false ); - changeLength( MidiTime( t, 0 ) ); + changeLength( TimePos( t, 0 ) ); restoreJournallingState(); } setAutoResize( false ); @@ -208,7 +208,7 @@ void BBTCOView::paintEvent( QPaintEvent * ) p.setPen( c.darker( 200 ) ); bar_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() ); - if( m_bbTCO->length() > MidiTime::ticksPerBar() && t > 0 ) + if( m_bbTCO->length() > TimePos::ticksPerBar() && t > 0 ) { for( int x = static_cast( t * pixelsPerBar() ); x < width() - 2; @@ -331,7 +331,7 @@ BBTrack::~BBTrack() // play _frames frames of given TCO within starting with _start -bool BBTrack::play( const MidiTime & _start, const fpp_t _frames, +bool BBTrack::play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _offset, int _tco_num ) { if( isMuted() ) @@ -352,8 +352,8 @@ bool BBTrack::play( const MidiTime & _start, const fpp_t _frames, return false; } - MidiTime lastPosition; - MidiTime lastLen; + TimePos lastPosition; + TimePos lastLen; for( tcoVector::iterator it = tcos.begin(); it != tcos.end(); ++it ) { if( !( *it )->isMuted() && @@ -382,7 +382,7 @@ TrackView * BBTrack::createView( TrackContainerView* tcv ) -TrackContentObject* BBTrack::createTCO(const MidiTime & pos) +TrackContentObject* BBTrack::createTCO(const TimePos & pos) { BBTCO* bbtco = new BBTCO(this); bbtco->movePosition(pos); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 4333627e8..a8c1343aa 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -244,7 +244,7 @@ MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event ) -void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset ) { if( Engine::getSong()->isExporting() ) { @@ -267,7 +267,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti NotePlayHandleManager::acquire( this, offset, typeInfo::max() / 2, - Note( MidiTime(), MidiTime(), event.key(), event.volume( midiPort()->baseVelocity() ) ), + Note( TimePos(), TimePos(), event.key(), event.volume( midiPort()->baseVelocity() ) ), NULL, event.channel(), NotePlayHandle::OriginMidiInput ); m_notes[event.key()] = nph; @@ -332,7 +332,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti nph->OriginMidiInput) { nph->setLength( - MidiTime( static_cast( + TimePos( static_cast( nph->totalFramesPlayed() / Engine::framesPerTick() ) ) ); midiNoteOff( *nph ); @@ -385,7 +385,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti -void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +void InstrumentTrack::processOutEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset ) { // do nothing if we do not have an instrument instance (e.g. when loading settings) if( m_instrument == NULL ) @@ -608,7 +608,7 @@ void InstrumentTrack::removeMidiPortNode( DataFile & _dataFile ) -bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames, +bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _offset, int _tco_num ) { if( ! m_instrument || ! tryLock() ) @@ -638,7 +638,7 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames, for( NotePlayHandleList::Iterator it = m_processHandles.begin(); it != m_processHandles.end(); ++it ) { - ( *it )->processMidiTime( _start ); + ( *it )->processTimePos( _start ); } if ( tcos.size() == 0 ) @@ -660,7 +660,7 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames, { continue; } - MidiTime cur_start = _start; + TimePos cur_start = _start; if( _tco_num < 0 ) { cur_start -= p->startPosition(); @@ -713,7 +713,7 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames, -TrackContentObject* InstrumentTrack::createTCO(const MidiTime & pos) +TrackContentObject* InstrumentTrack::createTCO(const TimePos & pos) { Pattern* p = new Pattern(this); p->movePosition(pos); diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 69d575813..ded78ffa8 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -56,7 +56,7 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) : TrackContentObject( _instrument_track ), m_instrumentTrack( _instrument_track ), m_patternType( BeatPattern ), - m_steps( MidiTime::stepsPerBar() ) + m_steps( TimePos::stepsPerBar() ) { if( _instrument_track->trackContainer() == Engine::getBBTrackContainer() ) @@ -160,7 +160,7 @@ void Pattern::updateLength() return; } - tick_t max_length = MidiTime::ticksPerBar(); + tick_t max_length = TimePos::ticksPerBar(); for( NoteVector::ConstIterator it = m_notes.begin(); it != m_notes.end(); ++it ) @@ -171,17 +171,17 @@ void Pattern::updateLength() ( *it )->endPos() ); } } - changeLength( MidiTime( max_length ).nextFullBar() * - MidiTime::ticksPerBar() ); + changeLength( TimePos( max_length ).nextFullBar() * + TimePos::ticksPerBar() ); updateBBTrack(); } -MidiTime Pattern::beatPatternLength() const +TimePos Pattern::beatPatternLength() const { - tick_t max_length = MidiTime::ticksPerBar(); + tick_t max_length = TimePos::ticksPerBar(); for( NoteVector::ConstIterator it = m_notes.begin(); it != m_notes.end(); ++it ) @@ -193,13 +193,13 @@ MidiTime Pattern::beatPatternLength() const } } - if( m_steps != MidiTime::stepsPerBar() ) + if( m_steps != TimePos::stepsPerBar() ) { - max_length = m_steps * MidiTime::ticksPerBar() / - MidiTime::stepsPerBar(); + max_length = m_steps * TimePos::ticksPerBar() / + TimePos::stepsPerBar(); } - return MidiTime( max_length ).nextFullBar() * MidiTime::ticksPerBar(); + return TimePos( max_length ).nextFullBar() * TimePos::ticksPerBar(); } @@ -258,7 +258,7 @@ Note * Pattern::noteAtStep( int _step ) for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); ++it ) { - if( ( *it )->pos() == MidiTime::stepPosition( _step ) + if( ( *it )->pos() == TimePos::stepPosition( _step ) && ( *it )->length() < 0 ) { return *it; @@ -297,8 +297,8 @@ void Pattern::clearNotes() Note * Pattern::addStepNote( int step ) { - return addNote( Note( MidiTime( -DefaultTicksPerBar ), - MidiTime::stepPosition( step ) ), false ); + return addNote( Note( TimePos( -DefaultTicksPerBar ), + TimePos::stepPosition( step ) ), false ); } @@ -428,7 +428,7 @@ void Pattern::loadSettings( const QDomElement & _this ) m_steps = _this.attribute( "steps" ).toInt(); if( m_steps == 0 ) { - m_steps = MidiTime::stepsPerBar(); + m_steps = TimePos::stepsPerBar(); } checkType(); @@ -477,7 +477,7 @@ void Pattern::clear() void Pattern::addSteps() { - m_steps += MidiTime::stepsPerBar(); + m_steps += TimePos::stepsPerBar(); updateLength(); emit dataChanged(); } @@ -508,7 +508,7 @@ void Pattern::cloneSteps() void Pattern::removeSteps() { - int n = MidiTime::stepsPerBar(); + int n = TimePos::stepsPerBar(); if( n < m_steps ) { for( int i = m_steps - n; i < m_steps; ++i ) @@ -566,19 +566,19 @@ bool Pattern::empty() void Pattern::changeTimeSignature() { - MidiTime last_pos = MidiTime::ticksPerBar() - 1; + TimePos last_pos = TimePos::ticksPerBar() - 1; for( NoteVector::ConstIterator cit = m_notes.begin(); cit != m_notes.end(); ++cit ) { if( ( *cit )->length() < 0 && ( *cit )->pos() > last_pos ) { - last_pos = ( *cit )->pos()+MidiTime::ticksPerBar() / - MidiTime::stepsPerBar(); + last_pos = ( *cit )->pos()+TimePos::ticksPerBar() / + TimePos::stepsPerBar(); } } - last_pos = last_pos.nextFullBar() * MidiTime::ticksPerBar(); - m_steps = qMax( MidiTime::stepsPerBar(), - last_pos.getBar() * MidiTime::stepsPerBar() ); + last_pos = last_pos.nextFullBar() * TimePos::ticksPerBar(); + m_steps = qMax( TimePos::stepsPerBar(), + last_pos.getBar() * TimePos::stepsPerBar() ); updateLength(); } @@ -923,7 +923,7 @@ void PatternView::paintEvent( QPaintEvent * ) // 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 / MidiTime::ticksPerBar(); + const float tickLength = barLength / TimePos::ticksPerBar(); const int x_base = TCO_BORDER_WIDTH; diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 197e3fcf1..31768de75 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -123,7 +123,7 @@ SampleTCO::~SampleTCO() -void SampleTCO::changeLength( const MidiTime & _length ) +void SampleTCO::changeLength( const TimePos & _length ) { TrackContentObject::changeLength( qMax( static_cast( _length ), 1 ) ); } @@ -231,7 +231,7 @@ void SampleTCO::updateLength() -MidiTime SampleTCO::sampleLength() const +TimePos SampleTCO::sampleLength() const { return (int)( m_sampleBuffer->frames() / Engine::framesPerTick() ); } @@ -681,7 +681,7 @@ SampleTrack::~SampleTrack() -bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames, +bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _offset, int _tco_num ) { m_audioPort.effects()->startRunning(); @@ -788,7 +788,7 @@ TrackView * SampleTrack::createView( TrackContainerView* tcv ) -TrackContentObject * SampleTrack::createTCO(const MidiTime & pos) +TrackContentObject * SampleTrack::createTCO(const TimePos & pos) { SampleTCO * sTco = new SampleTCO(this); sTco->movePosition(pos); @@ -1023,10 +1023,10 @@ void SampleTrackView::dropEvent(QDropEvent *de) ? trackHeadWidth : de->pos().x(); - MidiTime tcoPos = trackContainerView()->fixedTCOs() - ? MidiTime(0) - : MidiTime(((xPos - trackHeadWidth) / trackContainerView()->pixelsPerBar() - * MidiTime::ticksPerBar()) + trackContainerView()->currentPosition() + TimePos tcoPos = trackContainerView()->fixedTCOs() + ? TimePos(0) + : TimePos(((xPos - trackHeadWidth) / trackContainerView()->pixelsPerBar() + * TimePos::ticksPerBar()) + trackContainerView()->currentPosition() ).quantize(1.0); SampleTCO * sTco = static_cast(getTrack()->createTCO(tcoPos)); diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index 291ae293e..f86bfe44d 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -141,20 +141,20 @@ private slots: dynamic_cast(Track::create(Track::InstrumentTrack, song)); Pattern* notePattern = dynamic_cast(instrumentTrack->createTCO(0)); - notePattern->changeLength(MidiTime(4, 0)); - Note* note = notePattern->addNote(Note(MidiTime(4, 0)), false); + notePattern->changeLength(TimePos(4, 0)); + Note* note = notePattern->addNote(Note(TimePos(4, 0)), false); note->createDetuning(); DetuningHelper* dh = note->detuning(); auto pattern = dh->automationPattern(); pattern->setProgressionType( AutomationPattern::LinearProgression ); - pattern->putValue(MidiTime(0, 0), 0.0); - pattern->putValue(MidiTime(4, 0), 1.0); + pattern->putValue(TimePos(0, 0), 0.0); + pattern->putValue(TimePos(4, 0), 1.0); - QCOMPARE(pattern->valueAt(MidiTime(0, 0)), 0.0f); - QCOMPARE(pattern->valueAt(MidiTime(1, 0)), 0.25f); - QCOMPARE(pattern->valueAt(MidiTime(2, 0)), 0.5f); - QCOMPARE(pattern->valueAt(MidiTime(4, 0)), 1.0f); + QCOMPARE(pattern->valueAt(TimePos(0, 0)), 0.0f); + QCOMPARE(pattern->valueAt(TimePos(1, 0)), 0.25f); + QCOMPARE(pattern->valueAt(TimePos(2, 0)), 0.5f); + QCOMPARE(pattern->valueAt(TimePos(4, 0)), 1.0f); } void testBBTrack() @@ -186,12 +186,12 @@ private slots: QVERIFY(! bbContainer->automatedValuesAt(5, bbTrack2.index()).size()); BBTCO tco(&bbTrack); - tco.changeLength(MidiTime::ticksPerBar() * 2); + tco.changeLength(TimePos::ticksPerBar() * 2); tco.movePosition(0); QCOMPARE(song->automatedValuesAt(0)[&model], 0.0f); QCOMPARE(song->automatedValuesAt(5)[&model], 0.5f); - QCOMPARE(song->automatedValuesAt(MidiTime::ticksPerBar() + 5)[&model], 0.5f); + QCOMPARE(song->automatedValuesAt(TimePos::ticksPerBar() + 5)[&model], 0.5f); } void testGlobalAutomation()