bool MIDISequencer::GoToTime ( MIDIClockTime time_clk ) { // temporarily disable the gui notifier bool notifier_mode = false; if ( state.notifier ) { notifier_mode = state.notifier->GetEnable(); state.notifier->SetEnable ( false ); } if ( time_clk < state.cur_clock || time_clk == 0 ) { // start from zero if desired time is before where we are for ( int i = 0; i < state.num_tracks; ++i ) { state.track_state[i]->GoToZero(); } state.iterator.GoToTime ( 0 ); state.cur_time_ms = 0.0; state.cur_clock = 0; // state.next_beat_time = state.multitrack->GetClksPerBeat(); state.next_beat_time = state.multitrack->GetClksPerBeat() * 4 / ( state.track_state[0]->timesig_denominator ); state.cur_beat = 0; state.cur_measure = 0; } MIDIClockTime t = 0; int trk; MIDITimedBigMessage ev; while ( GetNextEventTime ( &t ) && t < time_clk && GetNextEvent ( &trk, &ev ) ) { ; } // examine all the events at this specific time // and update the track states to reflect this time ScanEventsAtThisTime(); // re-enable the gui notifier if it was enabled previously if ( state.notifier ) { state.notifier->SetEnable ( notifier_mode ); // cause a full gui refresh now state.notifier->Notify ( this, MIDISequencerGUIEvent::GROUP_ALL ); } return true; }
void MIDISequencer::GoToZero() { // go to time zero for ( int i = 0; i < num_tracks; ++i ) { state.track_state[i]->GoToZero(); } state.iterator.GoToTime ( 0 ); state.cur_time_ms = 0.0; state.cur_clock = 0; // state.next_beat_time = state.multitrack->GetClksPerBeat(); state.next_beat_time = state.multitrack->GetClksPerBeat() * 4 / ( state.track_state[0]->timesig_denominator ); // examine all the events at this specific time // and update the track states to reflect this time ScanEventsAtThisTime(); }
bool MIDISequencer::GoToMeasure( int measure, int beat ) { // temporarily disable the gui notifier bool notifier_mode=false; if( state.notifier ) { notifier_mode = state.notifier->GetEnable(); state.notifier->SetEnable(false); } if( measure < state.cur_measure || measure==0 ) { for( int i=0; i<state.num_tracks; ++i ) { state.track_state[i]->GoToZero(); } state.iterator.GoToTime( 0 ); state.cur_time_ms = 0.0; state.cur_clock = 0; state.cur_beat = 0; state.cur_measure = 0; // state.next_beat_time = state.multitrack->GetClksPerBeat(); state.next_beat_time = state.multitrack->GetClksPerBeat() * 4 / (state.track_state[0]->timesig_denominator); } MIDIClockTime t=0; int trk; MIDITimedBigMessage ev; // iterate thru all the events until cur-measure and cur_beat are // where we want them. while( GetNextEventTime( &t ) && GetNextEvent(&trk,&ev) && state.cur_measure<=measure ) { if( state.cur_measure==measure && state.cur_beat>=beat ) { break; } } // examine all the events at this specific time // and update the track states to reflect this time ScanEventsAtThisTime(); // re-enable the gui notifier if it was enabled previously if( state.notifier ) { state.notifier->SetEnable( notifier_mode ); // cause a full gui refresh now state.notifier->Notify( this, MIDISequencerGUIEvent::GROUP_ALL ); } // return true if we actually found the measure requested return state.cur_measure == measure && state.cur_beat == beat; }