MIDIFile constructor

MIDIFile({
  1. int numTracks = 1,
})

Implementation

MIDIFile({
  this.numTracks = 1,
}) {
  if (numTracks < 1) throw Exception("numTracksmust be >=1");
  bool removeDuplicates = true;
  bool deinterleave = true;
  bool _adjust_origin = false;
  int file_format = 1;
  int _ticks_per_quarternote = TICKSPERQUARTERNOTE;
  bool _eventtime_is_ticks = false;
  this._tracks = [];
  if (file_format == 1) {
    this.numTracks =
        numTracks + 1; // this._tracks[0] is the baked-in tempo track
  } else {
    this.numTracks = numTracks;
  }

  this._header =
      MIDIHeader(this.numTracks, file_format, _ticks_per_quarternote);

  this._adjust_origin = _adjust_origin;
  this._closed = false;

  this._ticks_per_quarternote = _ticks_per_quarternote;
  this._eventtime_is_ticks = _eventtime_is_ticks;

  if (this._eventtime_is_ticks) {
    this._time_to_ticks = (x) => x;
  } else {
    this._time_to_ticks = this._quarter_to_tick;
  }

  List.generate(this.numTracks, (index) {
    this._tracks.add(MIDITrack(removeDuplicates, deinterleave));
  });

  this._event_counter = 0;
}