LMMS
Loading...
Searching...
No Matches
lmms::Track Class Referenceabstract

Base-class for all tracks. More...

#include <Track.h>

Inheritance diagram for lmms::Track:
lmms::Model lmms::JournallingObject lmms::SerializingObject lmms::AutomationTrack lmms::InstrumentTrack lmms::PatternTrack lmms::SampleTrack

Public Types

enum class  Type {
  Instrument , Pattern , Sample , Event ,
  Video , Automation , HiddenAutomation , Count
}
using clipVector = std::vector<Clip*>

Public Slots

virtual void setName (const QString &newName)
void setMutedBeforeSolo (const bool muted)
void toggleSolo ()
 Invert the track's solo state.

Signals

void destroyedTrack ()
void nameChanged ()
void clipAdded (lmms::Clip *)
void colorChanged ()
void dataChanged ()
Signals inherited from lmms::Model
void dataChanged ()
void dataUnchanged ()
void propertiesChanged ()

Public Member Functions

 Track (Type type, TrackContainer *tc)
 Create a new (empty) track object.
 ~Track () override
 Destroy this track.
Trackclone ()
 Clone a track from this track.
Type type () const
virtual bool play (const TimePos &start, const f_cnt_t frames, const f_cnt_t frameBase, int clipNum=-1)=0
virtual gui::TrackViewcreateView (gui::TrackContainerView *view)=0
virtual ClipcreateClip (const TimePos &pos)=0
virtual void saveTrackSpecificSettings (QDomDocument &doc, QDomElement &parent, bool presetMode)=0
virtual void loadTrackSpecificSettings (const QDomElement &element)=0
void savePreset (QDomDocument &doc, QDomElement &element)
void loadPreset (const QDomElement &element)
void saveSettings (QDomDocument &doc, QDomElement &element) override
void loadSettings (const QDomElement &element) override
ClipaddClip (Clip *clip)
 Add another Clip into this track.
void removeClip (Clip *clip)
 Remove a given Clip from this track.
void deleteClips ()
 Remove all Clips from this track.
int numOfClips ()
 Return the number of clips we contain.
auto getClip (std::size_t clipNum) -> Clip *
 Get a Clip by number.
int getClipNum (const Clip *clip)
 Determine the given Clip's number in our array.
const clipVectorgetClips () const
void getClipsInRange (clipVector &clipV, const TimePos &start, const TimePos &end)
 Retrieve a list of clips that fall within a period.
void swapPositionOfClips (int clipNum1, int clipNum2)
 Swap the position of two clips.
void createClipsForPattern (int pattern)
void insertBar (const TimePos &pos)
 Move all the clips after a certain time later by one bar.
void removeBar (const TimePos &pos)
 Move all the clips after a certain time earlier by one bar.
bar_t length () const
 Return the length of the entire track in bars.
TrackContainertrackContainer () const
virtual const QString & name () const
QString displayName () const override
int getHeight ()
void setHeight (int height)
void lock ()
void unlock ()
bool tryLock ()
auto color () const -> const std::optional< QColor > &
void setColor (const std::optional< QColor > &color)
bool isMutedBeforeSolo () const
BoolModelgetMutedModel ()
Public Member Functions inherited from lmms::Model
 Model (Model *parent, QString displayName=QString(), bool defaultConstructed=false)
 ~Model () override=default
bool isDefaultConstructed () const
ModelparentModel () const
virtual void setDisplayName (const QString &displayName)
virtual QString fullDisplayName () const
Public Member Functions inherited from lmms::JournallingObject
 JournallingObject ()
 ~JournallingObject () override
jo_id_t id () const
void saveJournallingState (const bool newState)
void restoreJournallingState ()
void addJournalCheckPoint ()
QDomElement saveState (QDomDocument &_doc, QDomElement &_parent) override
void restoreState (const QDomElement &_this) override
bool isJournalling () const
void setJournalling (const bool _sr)
bool testAndSetJournalling (const bool newState)
bool isJournallingStateStackEmpty () const
Public Member Functions inherited from lmms::SerializingObject
 SerializingObject ()
virtual ~SerializingObject ()
virtual QString nodeName () const =0
void setHook (SerializingObjectHook *_hook)
SerializingObjectHookhook ()

Static Public Member Functions

static Trackcreate (Type tt, TrackContainer *tc)
 Create a track based on the given track type and container.
static Trackcreate (const QDomElement &element, TrackContainer *tc)
 Create a track inside TrackContainer from track type in a QDomElement and restore state from XML.

Protected Attributes

BoolModel m_mutedModel
BoolModel m_soloModel

Private Member Functions

 mapPropertyFromModel (bool, isMuted, setMuted, m_mutedModel)
 mapPropertyFromModel (bool, isSolo, setSolo, m_soloModel)
void saveTrack (QDomDocument &doc, QDomElement &element, bool presetMode)
 Save this track's settings to file.
void loadTrack (const QDomElement &element, bool presetMode)
 Load the settings from a file.

Private Attributes

TrackContainerm_trackContainer
Type m_type
QString m_name
int m_height
bool m_mutedBeforeSolo
clipVector m_clips
QMutex m_processingLock
std::optional< QColor > m_color

Friends

class gui::TrackView

Additional Inherited Members

Protected Member Functions inherited from lmms::JournallingObject
void changeID (jo_id_t _id)

Detailed Description

Base-class for all tracks.

Member Typedef Documentation

◆ clipVector

using lmms::Track::clipVector = std::vector<Clip*>

Member Enumeration Documentation

◆ Type

enum class lmms::Track::Type
strong
Enumerator
Instrument 
Pattern 
Sample 
Event 
Video 
Automation 
HiddenAutomation 
Count 

Constructor & Destructor Documentation

◆ Track()

lmms::Track::Track ( Type type,
TrackContainer * tc )

Create a new (empty) track object.

The track object is the whole track, linking its contents, its automation, name, type, and so forth.

Parameters
typeThe type of track (Song Editor or Pattern Editor)
tcThe track Container object to encapsulate in this track.
Todo
check the definitions of all the properties - are they OK?

< The track Model

< The track container object

< The track type

< The track's name

< For controlling track muting

< For controlling track soloing

< The clips (segments)

◆ ~Track()

lmms::Track::~Track ( )
override

Destroy this track.

Delete the clips and remove this track from the track container.

Member Function Documentation

◆ addClip()

Clip * lmms::Track::addClip ( Clip * clip)

Add another Clip into this track.

Parameters
clipThe Clip to attach to this track.

◆ clipAdded

void lmms::Track::clipAdded ( lmms::Clip * )
signal

◆ clone()

Track * lmms::Track::clone ( )

Clone a track from this track.

◆ color()

auto lmms::Track::color ( ) const -> const std::optional< QColor > &
inline

◆ colorChanged

void lmms::Track::colorChanged ( )
signal

◆ create() [1/2]

Track * lmms::Track::create ( const QDomElement & element,
TrackContainer * tc )
static

Create a track inside TrackContainer from track type in a QDomElement and restore state from XML.

Parameters
elementThe QDomElement containing the type of track to create
tcThe track container to attach to

◆ create() [2/2]

Track * lmms::Track::create ( Type tt,
TrackContainer * tc )
static

Create a track based on the given track type and container.

Parameters
ttThe type of track to create
tcThe track container to attach to

◆ createClip()

virtual Clip * lmms::Track::createClip ( const TimePos & pos)
pure virtual

◆ createClipsForPattern()

void lmms::Track::createClipsForPattern ( int pattern)

◆ createView()

virtual gui::TrackView * lmms::Track::createView ( gui::TrackContainerView * view)
pure virtual

◆ dataChanged

◆ deleteClips()

void lmms::Track::deleteClips ( )

Remove all Clips from this track.

◆ destroyedTrack

void lmms::Track::destroyedTrack ( )
signal

◆ displayName()

QString lmms::Track::displayName ( ) const
inlineoverridevirtual

Reimplemented from lmms::Model.

◆ getClip()

auto lmms::Track::getClip ( std::size_t clipNum) -> Clip *

Get a Clip by number.

If the Clip number is less than our Clip array size then fetch that numbered object from the array. Otherwise we warn the user that we've somehow requested a Clip that is too large, and create a new Clip for them.

Parameters
clipNumThe number of the Clip to fetch.
Returns
the given Clip or a new one if out of range.
Todo

reject Clip numbers less than zero.

if we create a Clip here, should we somehow attach it to the track?

◆ getClipNum()

int lmms::Track::getClipNum ( const Clip * clip)

Determine the given Clip's number in our array.

Parameters
clipThe Clip to search for.
Returns
its number in our array.

◆ getClips()

const clipVector & lmms::Track::getClips ( ) const
inline

◆ getClipsInRange()

void lmms::Track::getClipsInRange ( clipVector & clipV,
const TimePos & start,
const TimePos & end )

Retrieve a list of clips that fall within a period.

Here we're interested in a range of clips that intersect the given time period.

We return the Clips we find in order by time, earliest Clips first.

Parameters
clipVThe list to contain the found clips.
startThe MIDI start time of the range.
endThe MIDI endi time of the range.

◆ getHeight()

int lmms::Track::getHeight ( )
inline

◆ getMutedModel()

BoolModel * lmms::Track::getMutedModel ( )

◆ insertBar()

void lmms::Track::insertBar ( const TimePos & pos)

Move all the clips after a certain time later by one bar.

Parameters
posThe time at which we want to insert the bar.
Todo
if we stepped through this list last to first, and the list was in ascending order by Clip time, once we hit a Clip that was earlier than the insert time, we could fall out of the loop early.

◆ isMutedBeforeSolo()

bool lmms::Track::isMutedBeforeSolo ( ) const
inline

◆ length()

bar_t lmms::Track::length ( ) const

Return the length of the entire track in bars.

We step through our list of Clips and determine their end position, keeping track of the latest time found in ticks. Then we return that in bars by dividing by the number of ticks per bar.

◆ loadPreset()

void lmms::Track::loadPreset ( const QDomElement & element)

◆ loadSettings()

void lmms::Track::loadSettings ( const QDomElement & element)
overridevirtual

◆ loadTrack()

void lmms::Track::loadTrack ( const QDomElement & element,
bool presetMode )
private

Load the settings from a file.

We load the track's type and muted state and solo state, then clear out our current Clip.

Then we step through the QDomElement's children and load the track-specific settings and clip states from it one at a time.

Parameters
elementthe QDomElement to load track settings from
presetModeIndicates if a preset or a full track is loaded
Todo
Load the track height.

◆ loadTrackSpecificSettings()

virtual void lmms::Track::loadTrackSpecificSettings ( const QDomElement & element)
pure virtual

◆ lock()

void lmms::Track::lock ( )
inline

◆ mapPropertyFromModel() [1/2]

lmms::Track::mapPropertyFromModel ( bool ,
isMuted ,
setMuted ,
m_mutedModel  )
private

◆ mapPropertyFromModel() [2/2]

lmms::Track::mapPropertyFromModel ( bool ,
isSolo ,
setSolo ,
m_soloModel  )
private

◆ name()

virtual const QString & lmms::Track::name ( ) const
inlinevirtual

◆ nameChanged

void lmms::Track::nameChanged ( )
signal

◆ numOfClips()

int lmms::Track::numOfClips ( )

Return the number of clips we contain.

Returns
the number of clips we currently contain.

◆ play()

virtual bool lmms::Track::play ( const TimePos & start,
const f_cnt_t frames,
const f_cnt_t frameBase,
int clipNum = -1 )
pure virtual

◆ removeBar()

void lmms::Track::removeBar ( const TimePos & pos)

Move all the clips after a certain time earlier by one bar.

Parameters
posThe time at which we want to remove the bar.

◆ removeClip()

void lmms::Track::removeClip ( Clip * clip)

Remove a given Clip from this track.

Parameters
clipThe Clip to remove from this track.

◆ savePreset()

void lmms::Track::savePreset ( QDomDocument & doc,
QDomElement & element )

◆ saveSettings()

void lmms::Track::saveSettings ( QDomDocument & doc,
QDomElement & element )
overridevirtual

◆ saveTrack()

void lmms::Track::saveTrack ( QDomDocument & doc,
QDomElement & element,
bool presetMode )
private

Save this track's settings to file.

We save the track type and its muted state and solo state, then append the track- specific settings. Then we iterate through the clips and save all their states in turn.

Parameters
docThe QDomDocument to use to save
elementThe The QDomElement to save into
presetModeDescribes whether to save the track as a preset or not.
Todo

Does this accurately describe the parameters? I think not!?

Save the track height

◆ saveTrackSpecificSettings()

virtual void lmms::Track::saveTrackSpecificSettings ( QDomDocument & doc,
QDomElement & parent,
bool presetMode )
pure virtual

◆ setColor()

void lmms::Track::setColor ( const std::optional< QColor > & color)

◆ setHeight()

void lmms::Track::setHeight ( int height)
inline

◆ setMutedBeforeSolo

void lmms::Track::setMutedBeforeSolo ( const bool muted)
inlineslot

◆ setName

void lmms::Track::setName ( const QString & newName)
virtualslot

Reimplemented in lmms::InstrumentTrack.

◆ swapPositionOfClips()

void lmms::Track::swapPositionOfClips ( int clipNum1,
int clipNum2 )

Swap the position of two clips.

First, we arrange to swap the positions of the two Clips in the clips list. Then we swap their start times as well.

Parameters
clipNum1The first Clip to swap.
clipNum2The second Clip to swap.

◆ toggleSolo

void lmms::Track::toggleSolo ( )
slot

Invert the track's solo state.

We have to go through all the tracks determining if any other track is already soloed. Then we have to save the mute state of all tracks, and set our mute state to on and all the others to off.

◆ trackContainer()

TrackContainer * lmms::Track::trackContainer ( ) const
inline

◆ tryLock()

bool lmms::Track::tryLock ( )
inline

◆ type()

Type lmms::Track::type ( ) const
inline

◆ unlock()

void lmms::Track::unlock ( )
inline

◆ gui::TrackView

friend class gui::TrackView
friend

Member Data Documentation

◆ m_clips

clipVector lmms::Track::m_clips
private

◆ m_color

std::optional<QColor> lmms::Track::m_color
private

◆ m_height

int lmms::Track::m_height
private

◆ m_mutedBeforeSolo

bool lmms::Track::m_mutedBeforeSolo
private

◆ m_mutedModel

BoolModel lmms::Track::m_mutedModel
protected

◆ m_name

QString lmms::Track::m_name
private

◆ m_processingLock

QMutex lmms::Track::m_processingLock
private

◆ m_soloModel

BoolModel lmms::Track::m_soloModel
protected

◆ m_trackContainer

TrackContainer* lmms::Track::m_trackContainer
private

◆ m_type

Type lmms::Track::m_type
private

The documentation for this class was generated from the following files: