本文整理汇总了C++中MIDITimedBigMessage::GetTimeSigNumerator方法的典型用法代码示例。如果您正苦于以下问题:C++ MIDITimedBigMessage::GetTimeSigNumerator方法的具体用法?C++ MIDITimedBigMessage::GetTimeSigNumerator怎么用?C++ MIDITimedBigMessage::GetTimeSigNumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MIDITimedBigMessage
的用法示例。
在下文中一共展示了MIDITimedBigMessage::GetTimeSigNumerator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractMarkers
void AdvancedSequencer::ExtractMarkers ( std::vector< std::string > *list )
{
if ( !file_loaded )
{
list->clear();
num_markers = 0;
return;
}
MIDITrack *t = tracks.GetTrack ( 0 );
list->clear();
int cnt = 0;
int measure = 0;
int beat = 0;
int timesig_numerator = 4;
int timesig_denominator = 4;
MIDIClockTime last_beat_time = 0;
MIDIClockTime last_event_time = 0;
int clks_per_beat = tracks.GetClksPerBeat();
for ( int i = 0; i < t->GetNumEvents(); ++i )
{
MIDITimedBigMessage *m = t->GetEventAddress ( i );
if ( m )
{
// how many beats have gone by since the last event?
long beats_gone_by = ( m->GetTime() - last_beat_time ) / clks_per_beat;
if ( beats_gone_by > 0 )
{
// calculate what our new measure/beat is
beat += beats_gone_by;
// carry over beat overflow to measure
measure += beat / timesig_numerator;
beat = beat % timesig_numerator;
last_beat_time += ( clks_per_beat * beats_gone_by );
}
if ( m->IsMetaEvent() && m->IsTimeSig() )
{
timesig_numerator = m->GetTimeSigNumerator();
timesig_denominator = m->GetTimeSigDenominator();
clks_per_beat = tracks.GetClksPerBeat() * 4 / timesig_denominator;
}
if ( m->IsTextEvent() && m->GetSysEx() )
{
if ( ( m->GetMetaType() == META_GENERIC_TEXT )
|| m->GetMetaType() == META_MARKER_TEXT
|| m->GetMetaType() == META_CUE_TEXT )
{
char buf[256];
char line[256];
memcpy ( buf, m->GetSysEx()->GetBuf(), m->GetSysEx()->GetLength() );
buf[ m->GetSysEx()->GetLength() ] = '\0';
FixQuotes ( buf );
sprintf ( line, "%03d:%d %s", measure + 1, beat + 1, buf );
list->push_back ( std::string ( line ) );
marker_times[ cnt++ ] = m->GetTime();
}
}
last_event_time = m->GetTime();
}
}
num_markers = cnt;
}