Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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;
     }
 }
Esempio n. 5
0
        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;
            }
        }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 internal GENSubChunk(SF2 inSf2, bool preset) : base(inSf2, preset ? "pgen" : "igen")
 {
     generator_list = new List <SF2GenList>();
 }
Esempio n. 10
0
 internal BAGSubChunk(SF2 inSf2, bool preset) : base(inSf2, preset ? "pbag" : "ibag")
 {
     bag_list = new List <SF2Bag>();
 }
Esempio n. 11
0
 internal MODSubChunk(SF2 inSf2, bool preset) : base(inSf2, preset ? "pmod" : "imod")
 {
     modulator_list = new List <SF2ModList>();
 }
Esempio n. 12
0
 internal PHDRSubChunk(SF2 inSf2) : base(inSf2, "phdr")
 {
     preset_list = new List <SF2PresetHeader>();
 }
Esempio n. 13
0
 internal INSTSubChunk(SF2 inSf2) : base(inSf2, "inst")
 {
     instrument_list = new List <SF2Inst>();
 }
Esempio n. 14
0
 internal SF2ModList(SF2 inSf2)
 {
     sf2 = inSf2;
 }
Esempio n. 15
0
        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>();
        }
Esempio n. 16
0
 internal VersionSubChunk(SF2 inSf2, EndianBinaryReader reader) : base(inSf2, reader)
 {
     Version = new SF2VersionTag(reader);
 }
Esempio n. 17
0
 internal VersionSubChunk(SF2 inSf2, string subChunkName) : base(inSf2, subChunkName)
 {
     Size = SF2VersionTag.Size;
     inSf2.UpdateSize();
 }
Esempio n. 18
0
 protected SF2ListChunk(SF2 inSf2, string name) : base(inSf2, "LIST")
 {
     ListChunkName = name;
     Size          = 4;
 }
Esempio n. 19
0
 protected SF2Chunk(SF2 inSf2, BinaryReader reader)
 {
     sf2       = inSf2;
     chunkName = reader.ReadChars(4);
     Size      = reader.ReadUInt32();
 }
Esempio n. 20
0
 internal SF2GenList(SF2 inSf2, SF2Generator operation, GenAmountType amount)
 {
     sf2       = inSf2;
     sfGenOper = operation;
     genAmount = amount;
 }
Esempio n. 21
0
 internal SF2GenList(SF2 inSf2)
 {
     sf2       = inSf2;
     genAmount = new GenAmountType();
 }
Esempio n. 22
0
 protected SF2Chunk(SF2 inSf2, string name)
 {
     chunk_name = name.ToCharArray();
     sf2        = inSf2;
 }
Esempio n. 23
0
 internal SHDRSubChunk(SF2 inSf2) : base(inSf2, "shdr")
 {
     sample_list = new List <SF2Sample>();
 }
Esempio n. 24
0
        }                                        // Size in bytes

        protected SF2Chunk(SF2 inSf2, string name)
        {
            sf2       = inSf2;
            chunkName = name.ToCharArray();
        }
Esempio n. 25
0
 protected SF2Chunk(SF2 inSf2, EndianBinaryReader reader)
 {
     _sf2      = inSf2;
     ChunkName = reader.ReadString(4, false);
     Size      = reader.ReadUInt32();
 }
Esempio n. 26
0
 protected SF2ListChunk(SF2 inSf2, BinaryReader reader) : base(inSf2, reader)
 {
     listChunkName = reader.ReadChars(4);
 }
Esempio n. 27
0
 internal SdtaListChunk(SF2 inSf2) : base(inSf2, "sdta")
 {
     smpl_subchunk = new SMPLSubChunk(inSf2);
 }
Esempio n. 28
0
        char[] chunk_name; // Length 4

        protected ListChunk(SF2 inSf2, string name) : base(inSf2, "LIST")
        {
            chunk_name = name.ToCharArray();
            Size       = 4;
        }
Esempio n. 29
0
 internal VersionSubChunk(SF2 inSf2, string subchunk_type, SFVersionTag version) : base(inSf2, subchunk_type)
 {
     revision = version;
     Size    += SFVersionTag.Size;
 }
Esempio n. 30
0
 protected SF2ListChunk(SF2 inSf2, EndianBinaryReader reader) : base(inSf2, reader)
 {
     ListChunkName = reader.ReadString(4, false);
 }