internal SF2Inst(SF2 inSf2, string name) { sf2 = inSf2; achInstName = new char[20]; var temp = name.ToCharArray().Take(20).ToArray(); Buffer.BlockCopy(temp, 0, achInstName, 0, temp.Length * 2); wInstBagNdx = (ushort)sf2.IBAGCount; }
internal SF2PresetHeader(SF2 inSf2, string name, ushort patch, ushort bank) { sf2 = inSf2; ach_preset_name = new char[20]; var temp = name.ToCharArray().Take(20).ToArray(); Buffer.BlockCopy(temp, 0, ach_preset_name, 0, temp.Length * 2); wPreset = patch; wBank = bank; wPresetBagNdx = (ushort)sf2.PBAGCount; }
internal PdtaListChunk(SF2 inSf2) : base(inSf2, "pdta") { phdr_subchunk = new PHDRSubChunk(inSf2); pbag_subchunk = new BAGSubChunk(inSf2, true); pmod_subchunk = new MODSubChunk(inSf2, true); pgen_subchunk = new GENSubChunk(inSf2, true); inst_subchunk = new INSTSubChunk(inSf2); ibag_subchunk = new BAGSubChunk(inSf2, false); imod_subchunk = new MODSubChunk(inSf2, false); igen_subchunk = new GENSubChunk(inSf2, false); shdr_subchunk = new SHDRSubChunk(inSf2); }
internal SF2Bag(SF2 inSf2, bool isPresetBag) { if (isPresetBag) { GeneratorIndex = (ushort)inSf2.HydraChunk.PGENSubChunk.Count; ModulatorIndex = (ushort)inSf2.HydraChunk.PMODSubChunk.Count; } else { GeneratorIndex = (ushort)inSf2.HydraChunk.IGENSubChunk.Count; ModulatorIndex = (ushort)inSf2.HydraChunk.IMODSubChunk.Count; } }
ushort wModNdx; // Index of list of modulators internal SF2Bag(SF2 inSf2, bool preset) { sf2 = inSf2; if (preset) { wGenNdx = (ushort)sf2.PGENCount; wModNdx = (ushort)sf2.PMODCount; } else { wGenNdx = (ushort)sf2.IGENCount; wModNdx = (ushort)sf2.IMODCount; } }
internal InfoListChunk(SF2 inSf2, string engine, string bank, string rom, SFVersionTag rom_revision, string date, string designer, string products, string copyright, string comment, string tools) : base(inSf2, "INFO") { sub_chunks = new List <SF2Chunk>() // Mandatory sub-chunks { new VersionSubChunk(inSf2, "ifil", new SFVersionTag(2, 1)), new HeaderSubChunk(inSf2, "isng", string.IsNullOrEmpty(engine) ? "EMU8000" : engine), new HeaderSubChunk(inSf2, "INAM", string.IsNullOrEmpty(bank) ? "General MIDI" : bank), }; // Optional sub-chunks if (!string.IsNullOrEmpty(rom)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "irom", rom)); } if (rom_revision != null) { sub_chunks.Add(new VersionSubChunk(inSf2, "iver", rom_revision)); } if (!string.IsNullOrEmpty(date)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "ICRD", date)); } if (!string.IsNullOrEmpty(designer)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "IENG", designer)); } if (!string.IsNullOrEmpty(products)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "IPRD", products)); } if (!string.IsNullOrEmpty(copyright)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "ICOP", copyright)); } if (!string.IsNullOrEmpty(comment)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "ICMT", comment, 0x10000)); } if (!string.IsNullOrEmpty(tools)) { sub_chunks.Add(new HeaderSubChunk(inSf2, "ISFT", tools)); } foreach (var sub in sub_chunks) { Size += sub.Size + 8; } }
internal SF2Sample(SF2 inSf2, string name, uint start, uint end, uint start_loop, uint end_loop, uint sample_rate, sbyte original_pitch, sbyte pitch_correction) { achSampleName = new char[20]; var temp = name.ToCharArray().Take(20).ToArray(); Buffer.BlockCopy(temp, 0, achSampleName, 0, temp.Length * 2); dwStart = start; dwEnd = end; dwStartloop = start_loop; dwEndloop = end_loop; dwSampleRate = sample_rate; byOriginalPitch = original_pitch; chPitchCorrection = pitch_correction; wSampleLink = 0; sfSampleType = SF2SampleLink.monoSample; sf2 = inSf2; }
internal HeaderSubChunk(SF2 inSf2, string subchunk_type, string s, int max_size = 0x100) : base(inSf2, subchunk_type) // Maybe maxsize must go here { var test = s.ToCharArray().ToList(); if (test.Count >= max_size) // Input too long; cut it down { test = test.Take(max_size).ToList(); test[max_size - 1] = '\0'; } else if (test.Count % 2 == 0) // Even amount of characters { test.Add('\0'); // Add two null-terminators to keep the byte count even test.Add('\0'); } else // Odd amount of characters { test.Add('\0'); // Add one null-terminator since that would make byte the count even } field = test.ToArray(); Size += (uint)field.Length; }
internal GENSubChunk(SF2 inSf2, bool preset) : base(inSf2, preset ? "pgen" : "igen") { generator_list = new List <SF2GenList>(); }
internal BAGSubChunk(SF2 inSf2, bool preset) : base(inSf2, preset ? "pbag" : "ibag") { bag_list = new List <SF2Bag>(); }
internal MODSubChunk(SF2 inSf2, bool preset) : base(inSf2, preset ? "pmod" : "imod") { modulator_list = new List <SF2ModList>(); }
internal PHDRSubChunk(SF2 inSf2) : base(inSf2, "phdr") { preset_list = new List <SF2PresetHeader>(); }
internal INSTSubChunk(SF2 inSf2) : base(inSf2, "inst") { instrument_list = new List <SF2Inst>(); }
internal SF2ModList(SF2 inSf2) { sf2 = inSf2; }
List <uint> loop_pos_list; // Loop start data internal SMPLSubChunk(SF2 inSf2) : base(inSf2, "smpl") { wave_list = new List <short[]>(); loop_flag_list = new List <bool>(); loop_pos_list = new List <uint>(); }
internal VersionSubChunk(SF2 inSf2, EndianBinaryReader reader) : base(inSf2, reader) { Version = new SF2VersionTag(reader); }
internal VersionSubChunk(SF2 inSf2, string subChunkName) : base(inSf2, subChunkName) { Size = SF2VersionTag.Size; inSf2.UpdateSize(); }
protected SF2ListChunk(SF2 inSf2, string name) : base(inSf2, "LIST") { ListChunkName = name; Size = 4; }
protected SF2Chunk(SF2 inSf2, BinaryReader reader) { sf2 = inSf2; chunkName = reader.ReadChars(4); Size = reader.ReadUInt32(); }
internal SF2GenList(SF2 inSf2, SF2Generator operation, GenAmountType amount) { sf2 = inSf2; sfGenOper = operation; genAmount = amount; }
internal SF2GenList(SF2 inSf2) { sf2 = inSf2; genAmount = new GenAmountType(); }
protected SF2Chunk(SF2 inSf2, string name) { chunk_name = name.ToCharArray(); sf2 = inSf2; }
internal SHDRSubChunk(SF2 inSf2) : base(inSf2, "shdr") { sample_list = new List <SF2Sample>(); }
} // Size in bytes protected SF2Chunk(SF2 inSf2, string name) { sf2 = inSf2; chunkName = name.ToCharArray(); }
protected SF2Chunk(SF2 inSf2, EndianBinaryReader reader) { _sf2 = inSf2; ChunkName = reader.ReadString(4, false); Size = reader.ReadUInt32(); }
protected SF2ListChunk(SF2 inSf2, BinaryReader reader) : base(inSf2, reader) { listChunkName = reader.ReadChars(4); }
internal SdtaListChunk(SF2 inSf2) : base(inSf2, "sdta") { smpl_subchunk = new SMPLSubChunk(inSf2); }
char[] chunk_name; // Length 4 protected ListChunk(SF2 inSf2, string name) : base(inSf2, "LIST") { chunk_name = name.ToCharArray(); Size = 4; }
internal VersionSubChunk(SF2 inSf2, string subchunk_type, SFVersionTag version) : base(inSf2, subchunk_type) { revision = version; Size += SFVersionTag.Size; }
protected SF2ListChunk(SF2 inSf2, EndianBinaryReader reader) : base(inSf2, reader) { ListChunkName = reader.ReadString(4, false); }