Ejemplo n.º 1
0
        internal static PresetRegion[] Create(Preset preset, Span <Zone> zones, Instrument[] instruments)
        {
            Zone global = null;

            // Is the first one the global zone?
            if (zones[0].Generators.Length == 0 || zones[0].Generators.Last().Type != GeneratorType.Instrument)
            {
                // The first one is the global zone.
                global = zones[0];
            }

            if (global != null)
            {
                // The global zone is regarded as the base setting of subsequent zones.
                var regions = new PresetRegion[zones.Length - 1];
                for (var i = 0; i < regions.Length; i++)
                {
                    regions[i] = new PresetRegion(preset, global.Generators, zones[i + 1].Generators, instruments);
                }
                return(regions);
            }
            else
            {
                // No global zone.
                var regions = new PresetRegion[zones.Length];
                for (var i = 0; i < regions.Length; i++)
                {
                    regions[i] = new PresetRegion(preset, null, zones[i].Generators, instruments);
                }
                return(regions);
            }
        }
Ejemplo n.º 2
0
        private Preset(PresetInfo info, Zone[] zones, Instrument[] instruments)
        {
            this.name        = info.Name;
            this.patchNumber = info.PatchNumber;
            this.bankNumber  = info.BankNumber;
            this.library     = info.Library;
            this.genre       = info.Genre;
            this.morphology  = info.Morphology;

            var zoneCount = info.ZoneEndIndex - info.ZoneStartIndex + 1;

            if (zoneCount <= 0)
            {
                throw new InvalidDataException($"The preset '{info.Name}' has no zone.");
            }

            var zoneSpan = zones.AsSpan(info.ZoneStartIndex, zoneCount);

            regions = PresetRegion.Create(this, zoneSpan, instruments);
        }
Ejemplo n.º 3
0
 internal RegionPair(PresetRegion preset, InstrumentRegion instrument)
 {
     this.preset     = preset;
     this.instrument = instrument;
 }