Preset.fromInfo constructor

Preset.fromInfo(
  1. PresetInfo info,
  2. List<Zone> zones,
  3. List<Instrument> instruments
)

Implementation

factory Preset.fromInfo(PresetInfo info, List<Zone> zones, List<Instrument> instruments)
{

  var zoneCount = info.zoneEndIndex - info.zoneStartIndex + 1;
  if (zoneCount <= 0)
  {
      throw "The preset '${info.name}' has no zone.";
  }

  List<Zone> zoneSpan = zones.sublist(info.zoneStartIndex, info.zoneStartIndex + zoneCount);

  List<PresetRegion> regions = PresetRegion.create(zoneSpan, instruments);

  return Preset(
    name: info.name,
    patchNumber: info.patchNumber,
    bankNumber: info.bankNumber,
    library: info.library,
    genre: info.genre,
    morphology: info.morphology,
    regions: regions,
  );
}