Example #1
0
        public override void Load(DescriptorList description, AssetManager assets)
        {
            //read in sfz params
            CustomDescriptor sfzConfig = description.FindCustomDescriptor("sfzi");

            exTarget    = (int)sfzConfig.Objects[0];
            exGroup     = (int)sfzConfig.Objects[1];
            sfzVolume   = (float)sfzConfig.Objects[2];
            sfzPan      = new PanComponent((float)sfzConfig.Objects[3], PanFormulaEnum.Neg3dBCenter);
            ampKeyTrack = (float)sfzConfig.Objects[4];
            ampRootKey  = (byte)sfzConfig.Objects[5];
            ampVelTrack = (float)sfzConfig.Objects[6];
            //read in the generator info
            GeneratorDescriptor gdes = description.GenDescriptions[0];

            if (gdes.SamplerType != WaveformEnum.SampleData)
            {
                throw new Exception("Sfz can only support sample data generators.");
            }
            this.genList[0] = gdes.ToGenerator(assets);
            //read in the envelope info
            this.envList[0] = description.EnvelopeDescriptions[0];
            this.envList[1] = description.EnvelopeDescriptions[1];
            this.envList[2] = description.EnvelopeDescriptions[2];
            //read in the lfo info
            this.lfoList[0] = description.LfoDescriptions[0];
            this.lfoList[1] = description.LfoDescriptions[1];
            this.lfoList[2] = description.LfoDescriptions[2];
            //read in the filter info
            this.fltrList[0] = description.FilterDescriptions[0];
        }
Example #2
0
        public override void Load(DescriptorList description, AssetManager assets)
        {
            CustomDescriptor fmConfig = description.FindCustomDescriptor("fm2c");

            cIndex   = (double)fmConfig.Objects[0];
            mIndex   = (double)fmConfig.Objects[1];
            feedBack = (double)fmConfig.Objects[2];
            sync     = GetSyncModeFromString((string)fmConfig.Objects[3]);
            if (description.GenDescriptions[0].LoopMethod != LoopModeEnum.Continuous || description.GenDescriptions[1].LoopMethod != LoopModeEnum.Continuous)
            {
                throw new Exception("Fm2 patches must have continuous generators with wrapping bounds.");
            }
            genList[0] = description.GenDescriptions[0].ToGenerator(assets);
            genList[1] = description.GenDescriptions[1].ToGenerator(assets);
            envList[0] = description.EnvelopeDescriptions[0];
            envList[1] = description.EnvelopeDescriptions[1];
            lfoList[0] = description.LfoDescriptions[0];
        }
Example #3
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();
        }
Example #4
0
 private void LoadSfzCustom(SfzRegion region)
 {
     CustomDescriptions    = new CustomDescriptor[1];
     CustomDescriptions[0] = new CustomDescriptor("sfzi", 32,
                                                  new object[] { region.offBy, region.group, region.volume, region.pan / 100f, region.ampKeyTrack, region.ampKeyCenter, region.ampVelTrack / 100f });
 }
Example #5
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();
        }