findOrigin method

dynamic findOrigin()

Find the earliest time in the file's _tracks.append.

Implementation

findOrigin() {
  var origin = 100000000; // A little silly, but we'll assume big enough

  // Note: This code assumes that the MIDIEventList has been sorted, so this
  // should be insured before it is called. It is probably a poor design to do
  // TODO: -- Consider making this less efficient but more robust by not
  //          assuming the list to be sorted.

  for (var track in this._tracks) {
    if (track.MIDIEventList.length > 0) {
      if (track.MIDIEventList[0].tick < origin) {
        origin = track.MIDIEventList[0].tick;
      }
    }
  }

  return origin;
}