33 , m_fDefaultBpm( 120 ) {
51 WARNINGLOG( QString(
"Provided bpm %1 is too low. Assigning lower bound %2 instead" )
55 WARNINGLOG( QString(
"Provided bpm %1 is too high. Assigning upper bound %2 instead" )
60 ERRORLOG( QString(
"There is already a tempo marker present in column %1. Please remove it first." )
65 std::shared_ptr<TempoMarker> pTempoMarker = std::make_shared<TempoMarker>();
66 pTempoMarker->nColumn = nColumn;
67 pTempoMarker->fBpm = fBpm;
96 if ( nColumn == -1 ) {
102 for (
int ii = 0; ii < static_cast<int>(
m_tempoMarkers.size()); ii++) {
122 if ( tt->nColumn == nColumn ) {
132 std::shared_ptr<TempoMarker> pTempoMarker = std::make_shared<TempoMarker>();
133 pTempoMarker->nColumn = 0;
139 if ( tt->nColumn == nColumn ) {
149 std::shared_ptr<TempoMarker> pTempoMarker = std::make_shared<TempoMarker>();
150 pTempoMarker->nColumn = 0;
154 std::vector<std::shared_ptr<const TempoMarker>> tmpVector;
155 tmpVector.resize( nNumberOfTempoMarkers + 1 );
156 tmpVector[ 0 ] = pTempoMarker;
158 if ( nNumberOfTempoMarkers != 0 ) {
159 for (
int ii = 0; ii < nNumberOfTempoMarkers; ++ii ) {
179 ERRORLOG( QString(
"There is already a tag present in column %1. Please remove it first." )
184 std::shared_ptr<Tag> pTag(
new Tag );
185 pTag->nColumn = nColumn;
188 m_tags.push_back( std::move( pTag ) );
195 if (
m_tags.size() >= 1 ){
196 for (
int t = 0; t <
m_tags.size(); t++ ){
197 if (
m_tags[t]->nColumn == nColumn ) {
208 QString sCurrentTag(
"");
210 for (
int t = 0; t < static_cast<int>(
m_tags.size()); t++ ){
211 if (
m_tags[t]->nColumn > nColumn ){
214 sCurrentTag =
m_tags[t]->sTag;
221 for (
const auto& tt :
m_tags ){
222 if ( tt->nColumn == nColumn ) {
239 sOutput = QString(
"%1[Timeline]\n" ).arg( sPrefix )
240 .append( QString(
"%1%2m_fDefaultBpm: %3\n" ).arg( sPrefix ).arg( s ).arg(
m_fDefaultBpm ) )
241 .append( QString(
"%1%2m_tempoMarkers:\n" ).arg( sPrefix ).arg( s ) );
243 if ( tt !=
nullptr ) {
244 sOutput.append( QString(
"%1[column: %2 , bpm: %3]\n" ).arg( sPrefix + s + s ).arg( tt->nColumn ).arg( tt->fBpm ) );
247 sOutput.append( QString(
"%1%2m_tags:\n" ).arg( sPrefix ).arg( s ) );
248 for (
auto const& tt :
m_tags ) {
249 if ( tt !=
nullptr ) {
250 sOutput.append( QString(
"%1[column: %2 , tag: %3]\n" ).arg( sPrefix + s + s ).arg( tt->nColumn ).arg( tt->sTag ) );
255 sOutput = QString(
"%1[Timeline] " ).arg( sPrefix )
256 .append( QString(
"m_fDefaultBpm: %1, " ).arg(
m_fDefaultBpm ) )
257 .append( QString(
"m_tempoMarkers: [" ) );
259 if ( tt !=
nullptr ) {
260 sOutput.append( QString(
" [column: %1 , bpm: %2]" ).arg( tt->nColumn ).arg( tt->fBpm ) );
263 sOutput.append( QString(
"], m_tags: [" ) );
264 for (
auto const& tt :
m_tags ) {
265 if ( tt !=
nullptr ) {
266 sOutput.append( QString(
" [column: %1 , tag: %2]" ).arg( tt->nColumn ).arg( tt->sTag ) );
269 sOutput.append(
" ]");
278 if ( nDecimals >= 0 ) {
279 nPrec = std::min( nDecimals + (
fBpm >= 100 ? 3 : 2 ),
282 QString sOut = QString::number(
fBpm,
'g', nPrec );
284 return std::move( sOut );
291 sOutput = QString(
"%1[TempoMarker]\n" ).arg( sPrefix )
292 .append( QString(
"%1%2nColumn: %3\n" ).arg( sPrefix ).arg( s ).arg( nColumn ) )
293 .append( QString(
"%1%2fBpm: %3\n" ).arg( sPrefix ).arg( s ).arg( fBpm ) );
296 sOutput = QString(
"%1[TempoMarker] " ).arg( sPrefix )
297 .append( QString(
"nColumn: %3, " ).arg( nColumn ) )
298 .append( QString(
"fBpm: %3" ).arg( fBpm ) );
308 sOutput = QString(
"%1[TempoMarker]\n" ).arg( sPrefix )
309 .append( QString(
"%1%2nColumn: %3\n" ).arg( sPrefix ).arg( s ).arg( nColumn ) )
310 .append( QString(
"%1%2sTag: %3\n" ).arg( sPrefix ).arg( s ).arg( sTag ) );
313 sOutput = QString(
"%1[TempoMarker] " ).arg( sPrefix )
314 .append( QString(
"nColumn: %3, " ).arg( nColumn ) )
315 .append( QString(
"sTag: %3" ).arg( sTag ) );
static QString sPrintIndention
String used to format the debugging string output of some core classes.
std::shared_ptr< Song > getSong() const
Get the current song.
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
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.
bool hasColumnTempoMarker(int nColumn) const
bool isFirstTempoMarkerSpecial() const
Whether there is a TempoMarker introduced by the user at the first column.
float getTempoAtColumn(int nColumn) const
Returns the tempo of the Song at a given column.
bool hasColumnTag(int nColumn) const
void addTag(int nColumn, QString sTag)
Adds a Tag to the Timeline.
std::shared_ptr< const Timeline::TempoMarker > getTempoMarkerAtColumn(int nColumn) const
void activate()
Registers the current playback tempo to m_fDefaultBpm.
void deactivate()
Convencience function in order to create a symmetric pair with activate.
std::vector< std::shared_ptr< const TempoMarker > > m_tempoMarkers
std::vector< std::shared_ptr< const Tag > > m_tags
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.
void addTempoMarker(int nColumn, float fBpm)
Adds a TempoMarker to the Timeline.
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
float m_fDefaultBpm
Tempo used for the special tempo marker.
Tag specifies a note added to a certain position in the Song.
QString toQString(const QString &sPrefix="", bool bShort=true) const
QString toQString(const QString &sPrefix="", bool bShort=true) const
QString getPrettyString(int nDecimals=2) const