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; } }
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; } }
public Modulator(IReadable input) { _sourceModulationData = new ModulatorType(input); _destinationGenerator = input.ReadUInt16LE(); _amount = input.ReadInt16LE(); _sourceModulationAmount = new ModulatorType(input); _sourceTransform = input.ReadUInt16LE(); }
public static HydraIbag Load(IReadable reader) { var ibag = new HydraIbag(); ibag.InstGenNdx = reader.ReadUInt16LE(); ibag.InstModNdx = reader.ReadUInt16LE(); return(ibag); }
public static HydraPbag Load(IReadable reader) { var pbag = new HydraPbag(); pbag.GenNdx = reader.ReadUInt16LE(); pbag.ModNdx = reader.ReadUInt16LE(); return(pbag); }
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); }
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(); }
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(); }
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); }
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); }
public static HydraPgen Load(IReadable reader) { var pgen = new HydraPgen(); pgen.GenOper = reader.ReadUInt16LE(); pgen.GenAmount = HydraGenAmount.Load(reader); return(pgen); }
public static HydraInst Load(IReadable reader) { var inst = new HydraInst(); inst.InstName = reader.Read8BitStringLength(20); inst.InstBagNdx = reader.ReadUInt16LE(); return(inst); }
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)); }
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)); }
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; } }
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; } }
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; } }
public Generator(IReadable input) { GeneratorType = (GeneratorEnum)input.ReadUInt16LE(); _rawAmount = input.ReadUInt16LE(); }