Exemple #1
0
        public DescriptorList(StreamReader reader)
        {
            List <EnvelopeDescriptor>  envList  = new List <EnvelopeDescriptor>();
            List <FilterDescriptor>    fltrList = new List <FilterDescriptor>();
            List <LfoDescriptor>       lfoList  = new List <LfoDescriptor>();
            List <GeneratorDescriptor> genList  = new List <GeneratorDescriptor>();
            List <CustomDescriptor>    cList    = new List <CustomDescriptor>();
            List <string> descList = new List <string>();

            while (!reader.EndOfStream)
            {
                string tag = ReadNextTag(reader, descList);
                switch (tag)
                {
                case "envelope":
                {
                    EnvelopeDescriptor env = new EnvelopeDescriptor();
                    env.Read(descList.ToArray());
                    envList.Add(env);
                    break;
                }

                case "generator":
                {
                    GeneratorDescriptor gen = new GeneratorDescriptor();
                    gen.Read(descList.ToArray());
                    genList.Add(gen);
                    break;
                }

                case "filter":
                {
                    FilterDescriptor fltr = new FilterDescriptor();
                    fltr.Read(descList.ToArray());
                    fltrList.Add(fltr);
                    break;
                }

                case "lfo":
                {
                    LfoDescriptor lfo = new LfoDescriptor();
                    lfo.Read(descList.ToArray());
                    lfoList.Add(lfo);
                    break;
                }

                default:
                    if (!tag.Equals(string.Empty))
                    {
                        CustomDescriptor cus = new CustomDescriptor(tag, 0);
                        cus.Read(descList.ToArray());
                        cList.Add(cus);
                    }
                    break;
                }
                descList.Clear();
            }
            EnvelopeDescriptions = envList.ToArray();
            FilterDescriptions   = fltrList.ToArray();
            LfoDescriptions      = lfoList.ToArray();
            GenDescriptions      = genList.ToArray();
            CustomDescriptions   = cList.ToArray();
        }
Exemple #2
0
        public DescriptorList(BinaryReader reader)
        {
            List <EnvelopeDescriptor>  envList  = new List <EnvelopeDescriptor>();
            List <FilterDescriptor>    fltrList = new List <FilterDescriptor>();
            List <LfoDescriptor>       lfoList  = new List <LfoDescriptor>();
            List <GeneratorDescriptor> genList  = new List <GeneratorDescriptor>();
            List <CustomDescriptor>    cList    = new List <CustomDescriptor>();
            int count = reader.ReadInt16();

            for (int x = 0; x < count; x++)
            {
                string id   = new string(IOHelper.Read8BitChars(reader, 4));
                int    size = reader.ReadInt32();
                switch (id.ToLower())
                {
                case EnvelopeDescriptor.ID:
                {
                    EnvelopeDescriptor env = new EnvelopeDescriptor();
                    env.Read(reader);
                    envList.Add(env);
                    break;
                }

                case GeneratorDescriptor.ID:
                {
                    GeneratorDescriptor gen = new GeneratorDescriptor();
                    gen.Read(reader);
                    genList.Add(gen);
                    break;
                }

                case FilterDescriptor.ID:
                {
                    FilterDescriptor fltr = new FilterDescriptor();
                    fltr.Read(reader);
                    fltrList.Add(fltr);
                    break;
                }

                case LfoDescriptor.ID:
                {
                    LfoDescriptor lfo = new LfoDescriptor();
                    lfo.Read(reader);
                    lfoList.Add(lfo);
                    break;
                }

                default:
                {
                    CustomDescriptor cus = new CustomDescriptor(id, size);
                    cus.Read(reader);
                    cList.Add(cus);
                    break;
                }
                }
            }
            EnvelopeDescriptions = envList.ToArray();
            FilterDescriptions   = fltrList.ToArray();
            LfoDescriptions      = lfoList.ToArray();
            GenDescriptions      = genList.ToArray();
            CustomDescriptions   = cList.ToArray();
        }