#include <multitrack.h>
Public Member Functions | |
MIDIMultiTrackIterator (MIDIMultiTrack *mlt) | |
virtual | ~MIDIMultiTrackIterator () |
void | GoToTime (MIDIClockTime time) |
bool | GetCurEventTime (MIDIClockTime *t) |
bool | GetCurEvent (int *track, MIDITimedBigMessage **msg) |
bool | GoToNextEvent () |
bool | GoToNextEventOnTrack (int track) |
const MIDIMultiTrackIteratorState & | GetState () const |
MIDIMultiTrackIteratorState & | GetState () |
void | SetState (const MIDIMultiTrackIteratorState &s) |
MIDIMultiTrack * | GetMultiTrack () |
const MIDIMultiTrack * | GetMultiTrack () const |
Protected Attributes | |
MIDIMultiTrack * | multitrack |
MIDIMultiTrackIteratorState | state |
|
Definition at line 225 of file jdkmidi_multitrack.cpp.
00226 : 00227 multitrack(mlt), 00228 state( mlt->GetNumTracks() ) 00229 00230 { 00231 } |
|
Definition at line 233 of file jdkmidi_multitrack.cpp.
00234 { 00235 } |
|
Definition at line 315 of file jdkmidi_multitrack.cpp. References jdkmidi::MIDIMultiTrackIteratorState::GetCurEventTrack(), jdkmidi::MIDITrack::GetEventAddress(), jdkmidi::MIDIMultiTrack::GetTrack(), multitrack, jdkmidi::MIDIMultiTrackIteratorState::next_event_number, and state.
00316 { 00317 int t = state.GetCurEventTrack(); 00318 00319 if( t != -1 ) 00320 { 00321 if( track ) 00322 { 00323 *track=t; 00324 } 00325 00326 if( msg ) 00327 { 00328 int num = state.next_event_number[t]; 00329 00330 if( num>=0 ) 00331 { 00332 *msg = multitrack->GetTrack(t)->GetEventAddress( state.next_event_number[t] ); 00333 } 00334 else 00335 { 00336 *msg = 0; 00337 } 00338 00339 // do we really have a message? 00340 if( ! *msg ) 00341 { 00342 // no, return false then 00343 return false; 00344 } 00345 } 00346 00347 return true; 00348 } 00349 else 00350 { 00351 return false; 00352 } 00353 } |
|
Definition at line 299 of file jdkmidi_multitrack.cpp. References jdkmidi::MIDIMultiTrackIteratorState::GetCurEventTrack(), jdkmidi::MIDIMultiTrackIteratorState::GetCurrentTime(), jdkmidi::MIDIClockTime, and state.
|
|
Definition at line 139 of file multitrack.h. References multitrack.
00139 { return multitrack; } |
|
Definition at line 138 of file multitrack.h. References multitrack.
00138 { return multitrack; } |
|
Definition at line 128 of file multitrack.h. References state.
00129 { 00130 return state; 00131 } |
|
Definition at line 123 of file multitrack.h. References state.
00124 { 00125 return state; 00126 } |
|
Definition at line 355 of file jdkmidi_multitrack.cpp. References jdkmidi::MIDIMultiTrackIteratorState::cur_event_track, jdkmidi::MIDIMultiTrackIteratorState::FindTrackOfFirstEvent(), GoToNextEventOnTrack(), and state.
00356 { 00357 // find the next event in the multitrack list 00358 // and return it 00359 // if there is no event left, return false 00360 00361 if( state.cur_event_track==-1 ) 00362 { 00363 // no tracks left - all tracks are at end 00364 return false; 00365 } 00366 00367 // update the current event for the current track to the 00368 // next event on the same track. 00369 00370 GoToNextEventOnTrack( state.cur_event_track ); 00371 00372 // now find out which track now has the earliest event 00373 00374 if( state.FindTrackOfFirstEvent()==-1 ) 00375 { 00376 // No tracks do. all tracks are at the end. return false. 00377 return false; 00378 } 00379 00380 // ok, now state.cur_event_track has a valid track # of the next event 00381 00382 return true; 00383 } |
|
Definition at line 385 of file jdkmidi_multitrack.cpp. References jdkmidi::MIDITrack::GetEventAddress(), jdkmidi::MIDITrack::GetNumEvents(), jdkmidi::MIDITimedBigMessage::GetTime(), jdkmidi::MIDIMultiTrack::GetTrack(), multitrack, jdkmidi::MIDIMultiTrackIteratorState::next_event_number, jdkmidi::MIDIMultiTrackIteratorState::next_event_time, and state.
00386 { 00387 // Get the track that we are dealing with 00388 MIDITrack *track = multitrack->GetTrack( track_num ); 00389 00390 // Get ptr to the current event number for this track 00391 int *event_num = &state.next_event_number[ track_num ]; 00392 00393 // skip this track if this event number is <0 - This track has hit end already. 00394 00395 if( *event_num <0 ) 00396 { 00397 return false; // at end of track 00398 } 00399 00400 // increment *event_num to next event on track 00401 00402 (*event_num) += 1; 00403 00404 // are we at end of track? 00405 if( *event_num >= track->GetNumEvents() ) 00406 { 00407 // yes, set *event_num to -1 00408 *event_num=-1; 00409 return false; // at end of track 00410 } 00411 else 00412 { 00413 // not at end of track yet - get the time of the event 00414 MIDITimedBigMessage *msg; 00415 00416 msg = track->GetEventAddress( *event_num ); 00417 00418 state.next_event_time[ track_num ] = msg->GetTime(); 00419 } 00420 00421 00422 00423 return true; 00424 } |
|
Definition at line 237 of file jdkmidi_multitrack.cpp. References jdkmidi::MIDIMultiTrackIteratorState::FindTrackOfFirstEvent(), jdkmidi::MIDIMultiTrackIteratorState::GetCurrentTime(), jdkmidi::MIDITrack::GetEventAddress(), jdkmidi::MIDITrack::GetNumEvents(), jdkmidi::MIDIMultiTrack::GetNumTracks(), jdkmidi::MIDITimedBigMessage::GetTime(), jdkmidi::MIDIMultiTrack::GetTrack(), GoToNextEvent(), jdkmidi::MIDIClockTime, multitrack, jdkmidi::MIDIMultiTrackIteratorState::next_event_number, jdkmidi::MIDIMultiTrackIteratorState::next_event_time, jdkmidi::MIDIMultiTrackIteratorState::Reset(), and state.
00238 { 00239 // start at time 0 00240 00241 state.Reset(); 00242 00243 // transfer info from the first events in each track in the 00244 // multitrack object to our current state. 00245 00246 for( int i=0; i<multitrack->GetNumTracks(); ++i ) 00247 { 00248 MIDITrack *track = multitrack->GetTrack(i); 00249 00250 // default: set the next_event_number for this track to -1 00251 // to signify end of track 00252 00253 state.next_event_number[ i ] = -1; 00254 00255 // are there any events in this track? 00256 if( track && track->GetNumEvents()>0 ) 00257 { 00258 // yes, extract the time of the first event 00259 00260 MIDITimedBigMessage *msg = track->GetEventAddress( 0 ); 00261 00262 if( msg ) 00263 { 00264 // found the first message of the track. Keep track 00265 // of the event number and the event time. 00266 00267 state.next_event_number[i]=0; 00268 state.next_event_time[i]=msg->GetTime(); 00269 } 00270 } 00271 } 00272 00273 00274 // are there any events at all? find the track with the 00275 // earliest event 00276 00277 if( state.FindTrackOfFirstEvent()!=-1 ) 00278 { 00279 // yes 00280 // iterate through all the events until we find a time >= the requested time 00281 00282 while( state.GetCurrentTime()<time ) 00283 { 00284 // did not get to the requested time yet. 00285 // go to the next chronological event on all tracks 00286 00287 if( !GoToNextEvent() ) 00288 { 00289 // there is no more events to go to 00290 00291 break; 00292 } 00293 00294 } 00295 } 00296 00297 } |
|
Definition at line 133 of file multitrack.h. References state.
00134 { 00135 state = s; 00136 } |
|
Definition at line 143 of file multitrack.h. |
|
Definition at line 144 of file multitrack.h. |