|
hydrogen 1.2.6
|
Timeline class storing and handling all TempoMarkers and Tags. More...
#include <Timeline.h>
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 | activate () |
| Registers the current playback tempo to m_fDefaultBpm. | |
| void | addTag (int nColumn, QString sTag) |
| Adds a Tag to the Timeline. | |
| void | addTempoMarker (int nColumn, float fBpm) |
| Adds a TempoMarker to the Timeline. | |
| void | deactivate () |
| Convencience function in order to create a symmetric pair with activate. | |
| void | deleteAllTags () |
| void | deleteAllTempoMarkers () |
| Deletes all TempoMarkers set by the user. | |
| void | deleteTag (int nColumn) |
| void | deleteTempoMarker (int nColumn) |
| Delete all tempo markers except for the first one and mark the tempo of the Timeline m_bUnset. | |
| const std::vector< std::shared_ptr< const Tag > > | getAllTags () const |
| const std::vector< std::shared_ptr< const TempoMarker > > | getAllTempoMarkers () const |
| const QString | getTagAtColumn (int nColumn) const |
| Returns the tag of the Song at a given column. | |
| float | getTempoAtColumn (int nColumn) const |
| Returns the tempo of the Song at a given column. | |
| std::shared_ptr< const Timeline::TempoMarker > | getTempoMarkerAtColumn (int nColumn) const |
| bool | hasColumnTag (int nColumn) const |
| bool | hasColumnTempoMarker (int nColumn) const |
| bool | isFirstTempoMarkerSpecial () const |
| Whether there is a TempoMarker introduced by the user at the first column. | |
| void | setDefaultBpm (float fDefaultBpm) |
| QString | toQString (const QString &sPrefix="", bool bShort=true) const override |
| Formatted string version for debugging purposes. | |
Public Member Functions inherited from Object< Timeline > | |
| Object () | |
| Object (const Object< Timeline > &other) | |
Public Member Functions inherited from Base | |
| Base () | |
| Base (const Base &other) | |
| virtual const char * | class_name () const |
| void | logBacktrace () const |
| Print the current stack at point into the debug log. | |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. | |
Private Member Functions | |
| void | sortTags () |
| void | sortTempoMarkers () |
Private Attributes | |
| float | m_fDefaultBpm |
| Tempo used for the special tempo marker. | |
| std::vector< std::shared_ptr< const Tag > > | m_tags |
| std::vector< std::shared_ptr< const TempoMarker > > | m_tempoMarkers |
Additional Inherited Members | |
Static Public Member Functions inherited from Base | |
| static const char * | _class_name () |
| return the class name | |
| static QString | base_clock (const QString &sMsg) |
| Measures the current time and stores it in __last_clock. | |
| static QString | base_clock_in (const QString &sMsg) |
| static int | bootstrap (Logger *logger, bool count=false) |
| must be called before any Object instantiation ! | |
| static bool | count_active () |
| static int | getAliveObjectCount () |
| static object_map_t | getObjectMap () |
| static Logger * | logger () |
| return the logger instance | |
| static int | objects_count () |
| static void | printObjectMapDiff (object_map_t map) |
| Creates the difference between a snapshot of the object map and its current state and prints it to std::cout. | |
| static void | set_count (bool flag) |
| enable/disable class instances counting | |
| static void | write_objects_map_to (std::ostream &out, object_map_t *map=nullptr) |
| output the full objects map to a given ostream | |
| static void | write_objects_map_to_cerr () |
| output objects map to stderr | |
Static Public Attributes inherited from Base | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. | |
Protected Member Functions inherited from Object< Timeline > | |
| ~Object () | |
Protected Member Functions inherited from Base | |
| ~Base () | |
Static Protected Member Functions inherited from Base | |
| static void | registerClass (const char *name, const atomic_obj_cpt_t *counters) |
Static Protected Attributes inherited from Base | |
| static bool | __count = false |
| should we count class instances | |
| static timeval | __last_clock = { 0, 0 } |
| static Logger * | __logger = nullptr |
| static bool | bLogColors = true |
Timeline class storing and handling all TempoMarkers and Tags.
The design of the Timeline is a little bit involved and needs a couple of words to explain it. As soon as the Timeline is activated, it is required to yield a tempo for each column which solely depends on the TempoMarkers set by the user. Since a TempoMarker determines the tempo for all columns equal or bigger its own, there always needs a be one present at the very beginning of the Song.
For a more convenient UX the user shouldn't bother about the first one too much as a TempoMarker is usually put after the first column to indicate a change in tempo. Therefore, when a TempoMarker is added to an empty Timeline (to any location but the first column), the Timeline pretends to have a tempo marker in the beginning holding the current Song::m_fBpm (the tempo set via the BPM widget). This special first marker can only be "removed" by the user by adding a TempoMarker to the first column. In addition, it's tempo gets updated when toggling the Timeline. This, it does not immediately respond to changes of the song tempo (using the BPM widget or MIDI/OSC commands). The special tempo marker is prepended in the getAllTempoMarkers() functions.
The calling function will not notice any difference between the provided TempoMarkers and has to use isFirstTempoMarkerSpecial() instead.
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.
Definition at line 67 of file Timeline.h.
| Timeline | ( | ) |
Definition at line 32 of file Timeline.cpp.
| ~Timeline | ( | ) |
Definition at line 36 of file Timeline.cpp.
| void activate | ( | ) |
Registers the current playback tempo to m_fDefaultBpm.
Definition at line 41 of file Timeline.cpp.
| void addTag | ( | int | nColumn, |
| QString | sTag ) |
| void addTempoMarker | ( | int | nColumn, |
| float | fBpm ) |
Adds a TempoMarker to the Timeline.
Fails if there is already a TempoMarker present at nColumn.
| nColumn | Position of the Timeline to query for a tempo marker. |
| fBpm | New tempo in beats per minute. All values below 30 and above 500 will be cut. |
Definition at line 52 of file Timeline.cpp.
| void deactivate | ( | ) |
Convencience function in order to create a symmetric pair with activate.
Definition at line 45 of file Timeline.cpp.
|
inline |
Definition at line 239 of file Timeline.h.
|
inline |
Deletes all TempoMarkers set by the user.
But not the special one.
Definition at line 236 of file Timeline.h.
| void deleteTag | ( | int | nColumn | ) |
| nColumn | Position of the Timeline to delete the tag at (if one is present). |
Definition at line 196 of file Timeline.cpp.
| void deleteTempoMarker | ( | int | nColumn | ) |
Delete all tempo markers except for the first one and mark the tempo of the Timeline m_bUnset.
| nColumn | Position of the Timeline to delete the tempo marker at (if one is present). |
Definition at line 77 of file Timeline.cpp.
|
inline |
Definition at line 242 of file Timeline.h.
| const std::vector< std::shared_ptr< const Timeline::TempoMarker > > getAllTempoMarkers | ( | ) | const |
Definition at line 150 of file Timeline.cpp.
| const QString getTagAtColumn | ( | int | nColumn | ) | const |
Returns the tag of the Song at a given column.
| nColumn | Position of the Timeline to query for a tag. |
The function returns "" if the column is positioned before the first tag or none is present at all.
Definition at line 210 of file Timeline.cpp.
| float getTempoAtColumn | ( | int | nColumn | ) | const |
Returns the tempo of the Song at a given column.
There does not have to be a TempoMarker present at nColumn as the function takes all preceding ones into account as well.
| nColumn | Position of the Timeline to query for a tempo marker. |
Definition at line 90 of file Timeline.cpp.
| std::shared_ptr< const Timeline::TempoMarker > getTempoMarkerAtColumn | ( | int | nColumn | ) | const |
Definition at line 133 of file Timeline.cpp.
| bool hasColumnTag | ( | int | nColumn | ) | const |
Definition at line 224 of file Timeline.cpp.
| bool hasColumnTempoMarker | ( | int | nColumn | ) | const |
Definition at line 124 of file Timeline.cpp.
| bool isFirstTempoMarkerSpecial | ( | ) | const |
Whether there is a TempoMarker introduced by the user at the first column.
If not, the Timeline pretends that there is one by returning the current Song's tempo. The latter is referred to by "special tempo marker".
Definition at line 116 of file Timeline.cpp.
| void setDefaultBpm | ( | float | fDefaultBpm | ) |
Definition at line 48 of file Timeline.cpp.
|
private |
Definition at line 233 of file Timeline.cpp.
|
private |
Definition at line 175 of file Timeline.cpp.
|
overridevirtual |
Formatted string version for debugging purposes.
| sPrefix | String prefix which will be added in front of every new line |
| bShort | Instead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks. |
Reimplemented from Base.
Definition at line 239 of file Timeline.cpp.
|
private |
Tempo used for the special tempo marker.
It's the task of the calling function to ensure this is set to the last Song::m_fBpm when activating the Timeline.
Definition at line 218 of file Timeline.h.
|
private |
Definition at line 210 of file Timeline.h.
|
private |
Definition at line 209 of file Timeline.h.