Пример #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 = Platform.Platform.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;
            }
        }
Пример #3
0
 public Modulator(IReadable input)
 {
     _sourceModulationData = new ModulatorType(input);
     _destinationGenerator = input.ReadUInt16LE();
     _amount = input.ReadInt16LE();
     _sourceModulationAmount = new ModulatorType(input);
     _sourceTransform        = input.ReadUInt16LE();
 }
Пример #4
0
        public static HydraIbag Load(IReadable reader)
        {
            var ibag = new HydraIbag();

            ibag.InstGenNdx = reader.ReadUInt16LE();
            ibag.InstModNdx = reader.ReadUInt16LE();
            return(ibag);
        }
Пример #5
0
 public Modulator(IReadable input)
 {
     _sourceModulationData = new ModulatorType(input);
     _destinationGenerator = input.ReadUInt16LE();
     _amount = input.ReadInt16LE();
     _sourceModulationAmount = new ModulatorType(input);
     _sourceTransform = input.ReadUInt16LE();
 }
Пример #6
0
        public static HydraPbag Load(IReadable reader)
        {
            var pbag = new HydraPbag();

            pbag.GenNdx = reader.ReadUInt16LE();
            pbag.ModNdx = reader.ReadUInt16LE();
            return(pbag);
        }
Пример #7
0
        public static HydraImod Load(IReadable reader)
        {
            var imod = new HydraImod();

            imod.ModSrcOper    = reader.ReadUInt16LE();
            imod.ModDestOper   = reader.ReadUInt16LE();
            imod.ModAmount     = reader.ReadInt16LE();
            imod.ModAmtSrcOper = reader.ReadUInt16LE();
            imod.ModTransOper  = reader.ReadUInt16LE();
            return(imod);
        }
Пример #8
0
 public SampleHeader(IReadable input)
 {
     Name = input.Read8BitStringLength(20);
     Start = input.ReadInt32LE();
     End = input.ReadInt32LE();
     StartLoop = input.ReadInt32LE();
     EndLoop = input.ReadInt32LE();
     SampleRate = input.ReadInt32LE();
     RootKey = (byte) input.ReadByte();
     Tune = TypeUtils.ToInt16(input.ReadByte());
     SampleLink = input.ReadUInt16LE();
     SoundFontSampleLink = (SFSampleLink) input.ReadUInt16LE();
 }
Пример #9
0
 public SampleHeader(IReadable input)
 {
     Name                = input.Read8BitStringLength(20);
     Start               = input.ReadInt32LE();
     End                 = input.ReadInt32LE();
     StartLoop           = input.ReadInt32LE();
     EndLoop             = input.ReadInt32LE();
     SampleRate          = input.ReadInt32LE();
     RootKey             = (byte)input.ReadByte();
     Tune                = Platform.Platform.ToInt16(input.ReadByte());
     SampleLink          = input.ReadUInt16LE();
     SoundFontSampleLink = (SFSampleLink)input.ReadUInt16LE();
 }
Пример #10
0
        public static HydraPhdr Load(IReadable reader)
        {
            HydraPhdr phdr = new HydraPhdr();

            phdr.PresetName   = reader.Read8BitStringLength(20);
            phdr.Preset       = reader.ReadUInt16LE();
            phdr.Bank         = reader.ReadUInt16LE();
            phdr.PresetBagNdx = reader.ReadUInt16LE();
            phdr.Library      = reader.ReadUInt32LE();
            phdr.Genre        = reader.ReadUInt32LE();
            phdr.Morphology   = reader.ReadUInt32LE();

            return(phdr);
        }
Пример #11
0
        public static HydraShdr Load(IReadable reader)
        {
            var shdr = new HydraShdr();

            shdr.SampleName      = reader.Read8BitStringLength(20);
            shdr.Start           = reader.ReadUInt32LE();
            shdr.End             = reader.ReadUInt32LE();
            shdr.StartLoop       = reader.ReadUInt32LE();
            shdr.EndLoop         = reader.ReadUInt32LE();
            shdr.SampleRate      = reader.ReadUInt32LE();
            shdr.OriginalPitch   = (byte)reader.ReadByte();
            shdr.PitchCorrection = reader.ReadSignedByte();
            shdr.SampleLink      = reader.ReadUInt16LE();
            shdr.SampleType      = reader.ReadUInt16LE();
            return(shdr);
        }
Пример #12
0
        public static HydraPgen Load(IReadable reader)
        {
            var pgen = new HydraPgen();

            pgen.GenOper   = reader.ReadUInt16LE();
            pgen.GenAmount = HydraGenAmount.Load(reader);
            return(pgen);
        }
Пример #13
0
        public static HydraInst Load(IReadable reader)
        {
            var inst = new HydraInst();

            inst.InstName   = reader.Read8BitStringLength(20);
            inst.InstBagNdx = reader.ReadUInt16LE();
            return(inst);
        }
Пример #14
0
        public ModulatorType(IReadable input)
        {
            var raw = input.ReadUInt16LE();

            Polarity = (raw & 0x0200) == 0x0200 ? PolarityEnum.Bipolar : PolarityEnum.Unipolar;
            Direction = (raw & 0x0100) == 0x0100 ? DirectionEnum.MaxToMin : DirectionEnum.MinToMax;

            IsMidiContinuousController = ((raw & 0x0080) == 0x0080);
            SourceType = ((raw & (0xFC00)) >> 10);
            _controllerSource = TypeUtils.ToUInt16((raw & 0x007F));
        }
Пример #15
0
        public ModulatorType(IReadable input)
        {
            var raw = input.ReadUInt16LE();

            Polarity  = (raw & 0x0200) == 0x0200 ? PolarityEnum.Bipolar : PolarityEnum.Unipolar;
            Direction = (raw & 0x0100) == 0x0100 ? DirectionEnum.MaxToMin : DirectionEnum.MinToMax;

            IsMidiContinuousController = ((raw & 0x0080) == 0x0080);
            SourceType        = ((raw & (0xFC00)) >> 10);
            _controllerSource = Platform.Platform.ToUInt16((raw & 0x007F));
        }
Пример #16
0
        public ZoneChunk(string id, int size, IReadable input)
            : base(id, size)
        {
            _zoneData = new RawZoneData[((int)(size / 4.0))];

            RawZoneData lastZone = null;

            for (int x = 0; x < _zoneData.Length; x++)
            {
                var z = new RawZoneData();
                z.GeneratorIndex = input.ReadUInt16LE();
                z.ModulatorIndex = input.ReadUInt16LE();
                if (lastZone != null)
                {
                    lastZone.GeneratorCount = TypeUtils.ToUInt16(z.GeneratorIndex - lastZone.GeneratorIndex);
                    lastZone.ModulatorCount = TypeUtils.ToUInt16(z.ModulatorIndex - lastZone.ModulatorIndex);
                }
                _zoneData[x] = z;
                lastZone     = z;
            }
        }
Пример #17
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;
     }
 }
Пример #18
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 = Platform.Platform.ToUInt16((i.StartInstrumentZoneIndex - 1));
                }
                _rawInstruments[x] = i;
                lastInstrument     = i;
            }
        }
Пример #19
0
 public Generator(IReadable input)
 {
     GeneratorType = (GeneratorEnum)input.ReadUInt16LE();
     _rawAmount    = input.ReadUInt16LE();
 }
Пример #20
0
 public Generator(IReadable input)
 {
     GeneratorType = (GeneratorEnum)input.ReadUInt16LE();
     _rawAmount = input.ReadUInt16LE();
 }