Esempio n. 1
0
 public InstrumentChunk(string id, int size, IReadable input)
     : base(id, size)
 {
     if (size % 22 != 0)
         throw new Exception("Invalid SoundFont. The preset chunk was invalid.");
     _rawInstruments = new RawInstrument[((int)(size / 22.0))];
     RawInstrument lastInstrument = null;
     for (int x = 0; x < _rawInstruments.Length; x++)
     {
         var i = new RawInstrument();
         i.Name = input.Read8BitStringLength(20);
         i.StartInstrumentZoneIndex = input.ReadUInt16LE();
         if (lastInstrument != null)
         {
             lastInstrument.EndInstrumentZoneIndex = TypeUtils.ToUInt16((i.StartInstrumentZoneIndex - 1));
         }
         _rawInstruments[x] = i;
         lastInstrument = i;
     }
 }
Esempio n. 2
0
        public InstrumentChunk(string id, int size, IReadable input)
            : base(id, size)
        {
            if (size % 22 != 0)
            {
                throw new Exception("Invalid SoundFont. The preset chunk was invalid.");
            }
            _rawInstruments = new RawInstrument[((int)(size / 22.0))];
            RawInstrument lastInstrument = null;

            for (int x = 0; x < _rawInstruments.Length; x++)
            {
                var i = new RawInstrument();
                i.Name = input.Read8BitStringLength(20);
                i.StartInstrumentZoneIndex = input.ReadUInt16LE();
                if (lastInstrument != null)
                {
                    lastInstrument.EndInstrumentZoneIndex = TypeUtils.ToUInt16((i.StartInstrumentZoneIndex - 1));
                }
                _rawInstruments[x] = i;
                lastInstrument     = i;
            }
        }