public SplitInstrument(BinaryReader r) { var regionEnds = r.ReadBytes(8); byte start = 0; foreach (var end in regionEnds) { if (end == 0) { break; } var region = new InstrumentRegion(); region.lowEnd = start; region.highEnd = end; byte instrumentType = r.ReadByte(); r.Skip(1); region.subInstrument = (BaseLeafInstrument)Instrument.parseRecord(instrumentType, r); regions.Add(region); start = (byte)(end + 1); } }
public DrumkitInstrument(BinaryReader r) { byte low = r.ReadByte(); byte high = r.ReadByte(); if (high < low) { throw new InvalidDataException("High must be higher than low!"); } for (byte note = low; note <= high; ++note) { var region = new InstrumentRegion(); region.lowEnd = note; region.highEnd = note; byte instrumentType = r.ReadByte(); r.Skip(1); region.subInstrument = (BaseLeafInstrument)Instrument.parseRecord(instrumentType, r); regions.Add(region); } }