本文整理汇总了C++中AutomationPattern::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ AutomationPattern::clear方法的具体用法?C++ AutomationPattern::clear怎么用?C++ AutomationPattern::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutomationPattern
的用法示例。
在下文中一共展示了AutomationPattern::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readSMF
bool MidiImport::readSMF( TrackContainer* tc )
{
QString filename = file().fileName();
closeFile();
const int preTrackSteps = 2;
QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ),
TrackContainer::tr( "Cancel" ), 0, preTrackSteps, gui->mainWindow() );
pd.setWindowTitle( TrackContainer::tr( "Please wait..." ) );
pd.setWindowModality(Qt::WindowModal);
pd.setMinimumDuration( 0 );
pd.setValue( 0 );
Alg_seq_ptr seq = new Alg_seq(filename.toLocal8Bit(), true);
seq->convert_to_beats();
pd.setMaximum( seq->tracks() + preTrackSteps );
pd.setValue( 1 );
// 128 CC + Pitch Bend
smfMidiCC ccs[129];
smfMidiChannel chs[256];
MeterModel & timeSigMM = Engine::getSong()->getTimeSigModel();
AutomationPattern * timeSigNumeratorPat =
AutomationPattern::globalAutomationPattern( &timeSigMM.numeratorModel() );
AutomationPattern * timeSigDenominatorPat =
AutomationPattern::globalAutomationPattern( &timeSigMM.denominatorModel() );
// TODO: adjust these to Time.Sig changes
double beatsPerTact = 4;
double ticksPerBeat = DefaultTicksPerTact / beatsPerTact;
// Time-sig changes
Alg_time_sigs * timeSigs = &seq->time_sig;
for( int s = 0; s < timeSigs->length(); ++s )
{
Alg_time_sig timeSig = (*timeSigs)[s];
// Initial timeSig, set song-default value
if(/* timeSig.beat == 0*/ true )
{
// TODO set song-global default value
printf("Another timesig at %f\n", timeSig.beat);
timeSigNumeratorPat->putValue( timeSig.beat*ticksPerBeat, timeSig.num );
timeSigDenominatorPat->putValue( timeSig.beat*ticksPerBeat, timeSig.den );
}
else
{
}
}
pd.setValue( 2 );
// Tempo stuff
AutomationPattern * tap = tc->tempoAutomationPattern();
if( tap )
{
tap->clear();
Alg_time_map * timeMap = seq->get_time_map();
Alg_beats & beats = timeMap->beats;
for( int i = 0; i < beats.len - 1; i++ )
{
Alg_beat_ptr b = &(beats[i]);
double tempo = ( beats[i + 1].beat - b->beat ) /
( beats[i + 1].time - beats[i].time );
tap->putValue( b->beat * ticksPerBeat, tempo * 60.0 );
}
if( timeMap->last_tempo_flag )
{
Alg_beat_ptr b = &( beats[beats.len - 1] );
tap->putValue( b->beat * ticksPerBeat, timeMap->last_tempo * 60.0 );
}
}
// Song events
for( int e = 0; e < seq->length(); ++e )
{
Alg_event_ptr evt = (*seq)[e];
if( evt->is_update() )
{
printf("Unhandled SONG update: %d %f %s\n",
evt->get_type_code(), evt->time, evt->get_attribute() );
}
}
// Tracks
for( int t = 0; t < seq->tracks(); ++t )
{
QString trackName = QString( tr( "Track" ) + " %1" ).arg( t );
Alg_track_ptr trk = seq->track( t );
pd.setValue( t + preTrackSteps );
for( int c = 0; c < 129; c++ )
{
ccs[c].clear();
}
//.........这里部分代码省略.........