示例#1
0
        public PresetHeaderChunk(string id, int size, IReadable input)
            : base(id, size)
        {
            if (size % 38 != 0)
            {
                throw new Exception("Invalid SoundFont. The preset chunk was invalid.");
            }

            _rawPresets = new RawPreset[((int)(size / 38.0))];
            RawPreset lastPreset = null;

            for (int x = 0; x < _rawPresets.Length; x++)
            {
                var p = new RawPreset();
                p.Name                 = input.Read8BitStringLength(20);
                p.PatchNumber          = input.ReadUInt16LE();
                p.BankNumber           = input.ReadUInt16LE();
                p.StartPresetZoneIndex = input.ReadUInt16LE();
                p.Library              = input.ReadInt32LE();
                p.Genre                = input.ReadInt32LE();
                p.Morphology           = input.ReadInt32LE();
                if (lastPreset != null)
                {
                    lastPreset.EndPresetZoneIndex = TypeUtils.ToUInt16((p.StartPresetZoneIndex - 1));
                }
                _rawPresets[x] = p;
                lastPreset     = p;
            }
        }
示例#2
0
        public PresetHeaderChunk(string id, int size, IReadable input)
            : base(id, size)
        {
            if (size % 38 != 0)
                throw new Exception("Invalid SoundFont. The preset chunk was invalid.");

            _rawPresets = new RawPreset[((int)(size / 38.0))];
            RawPreset lastPreset = null;
            for (int x = 0; x < _rawPresets.Length; x++)
            {
                var p = new RawPreset();
                p.Name = input.Read8BitStringLength(20);
                p.PatchNumber = input.ReadUInt16LE();
                p.BankNumber = input.ReadUInt16LE();
                p.StartPresetZoneIndex = input.ReadUInt16LE();
                p.Library = input.ReadInt32LE();
                p.Genre = input.ReadInt32LE();
                p.Morphology = input.ReadInt32LE();
                if (lastPreset != null)
                {
                    lastPreset.EndPresetZoneIndex = TypeUtils.ToUInt16((p.StartPresetZoneIndex - 1));
                }
                _rawPresets[x] = p;
                lastPreset = p;
            }
        }