hydrogen 1.1.1
Timeline Class Reference

Timeline class storing and handling all TempoMarkers and Tags. More...

#include <Timeline.h>

Inheritance diagram for Timeline:
Object

Data Structures

struct  Tag
 Tag specifies a note added to a certain position in the Song. More...
 
struct  TagComparator
 
struct  TempoMarker
 TempoMarker specifies a change in speed during the Song. More...
 
struct  TempoMarkerComparator
 

Public Member Functions

 Timeline ()
 
 ~Timeline ()
 
void addTempoMarker (int nBar, float fBpm)
 
void deleteTempoMarker (int nBar)
 
void deleteAllTempoMarkers ()
 
float getTempoAtBar (int nBar, bool bSticky) const
 Returns the tempo of the Song at a given bar. More...
 
const std::vector< std::shared_ptr< const TempoMarker > > getAllTempoMarkers () const
 
void addTag (int nBar, QString sTag)
 
void deleteTag (int nBar)
 
void deleteAllTags ()
 
const QString getTagAtBar (int nBar, bool bSticky) const
 Returns the tag of the Song at a given bar. More...
 
const std::vector< std::shared_ptr< const Tag > > getAllTags () const
 
- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 

Private Member Functions

void sortTempoMarkers ()
 
void sortTags ()
 

Private Attributes

std::vector< std::shared_ptr< const TempoMarker > > m_tempoMarkers
 
std::vector< std::shared_ptr< const Tag > > m_tags
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 
- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Timeline class storing and handling all TempoMarkers and Tags.

All methods altering the TempoMarker and Tag are members of this class and the former are added as const structs to m_tempoMarkers or m_tags. To alter one of them, one has to delete it and add a new, altered version.

Constructor & Destructor Documentation

◆ Timeline()

Timeline ( )

◆ ~Timeline()

~Timeline ( )

Member Function Documentation

◆ addTag()

void addTag ( int  nBar,
QString  sTag 
)
Parameters
nBarPosition of the Timeline to query for a tag.
sTagNew tag in beats per minute.

◆ addTempoMarker()

void addTempoMarker ( int  nBar,
float  fBpm 
)
Parameters
nBarPosition of the Timeline to query for a tempo marker.
fBpmNew tempo in beats per minute. All values below 30 and above 500 will be cut.

◆ deleteAllTags()

void deleteAllTags ( )
inline

◆ deleteAllTempoMarkers()

void deleteAllTempoMarkers ( )
inline

◆ deleteTag()

void deleteTag ( int  nBar)
Parameters
nBarPosition of the Timeline to delete the tag at (if one is present).

◆ deleteTempoMarker()

void deleteTempoMarker ( int  nBar)
Parameters
nBarPosition of the Timeline to delete the tempo marker at (if one is present).

◆ getAllTags()

const std::vector< std::shared_ptr< const Timeline::Tag > > getAllTags ( ) const
inline
Returns
std::vector<std::shared_ptr<const Tag>> Provides read-only access to m_tags.

◆ getAllTempoMarkers()

const std::vector< std::shared_ptr< const Timeline::TempoMarker > > getAllTempoMarkers ( ) const
inline
Returns
std::vector<std::shared_ptr<const TempoMarker>> Provides read-only access to m_tempoMarker.

◆ getTagAtBar()

const QString getTagAtBar ( int  nBar,
bool  bSticky 
) const

Returns the tag of the Song at a given bar.

Parameters
nBarPosition of the Timeline to query for a tag.
bStickyIf set to true either the tag at nBar or - if none is present - the nearest previous tag is returned. If set to false, only the precise position nBar is taken into account.

The function returns "" if the bar is positioned before the first tag or none is present at all.

◆ getTempoAtBar()

float getTempoAtBar ( int  nBar,
bool  bSticky 
) const

Returns the tempo of the Song at a given bar.

Parameters
nBarPosition of the Timeline to query for a tempo marker.
bStickyIf set to true either the tempo marker at nBar or - if none is present - the nearest previous tempo marker is returned. If set to false, only the precise position nBar is taken into account.

TODO: For now the function returns 0 if the bar is positioned before the first tempo marker. The calling routine Hydrogen::getTimelineBpm() will take care of this and replaces it with pSong->__bpm. This will be taken care of with #854.

◆ sortTags()

void sortTags ( )
private

◆ sortTempoMarkers()

void sortTempoMarkers ( )
private

Field Documentation

◆ m_tags

std::vector<std::shared_ptr<const Tag> > m_tags
private

◆ m_tempoMarkers

std::vector<std::shared_ptr<const TempoMarker> > m_tempoMarkers
private