Example #1
0
        public void ChangeSetListSlotNotTooMany()
        {
            IPcgMemory pcg = CreatePcg();

            IProgram     programIa000      = (IProgram)pcg.ProgramBanks[0][0];
            ISetListSlot setListSlot000000 = (ISetListSlot)(pcg.SetLists[0])[0];

            setListSlot000000.SelectedPatchType = SetListSlot.PatchType.Program;
            setListSlot000000.UsedPatch         = programIa000;

            IProgram     programIa001      = (IProgram)pcg.ProgramBanks[0][1];
            ISetListSlot setListSlot000001 = (ISetListSlot)(pcg.SetLists[0])[1];

            setListSlot000001.SelectedPatchType = SetListSlot.PatchType.Program;
            setListSlot000001.UsedPatch         = programIa001;

            ReferenceChanger referenceChanger = new ReferenceChanger(pcg);
            RuleParser       ruleParser       = new RuleParser(pcg);

            referenceChanger.ParseRules(ruleParser, "I-A000->I-B000");
            referenceChanger.ChangeReferences();

            Debug.Assert(setListSlot000000.UsedPatch == pcg.ProgramBanks[1][0]); // Changed
            Debug.Assert(setListSlot000001.UsedPatch == programIa001);           // Not changed
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        public override void Clear()
        {
            IPcgMemory memory = (IPcgMemory)Root;

            if (memory.AssignedClearProgram == null)
            {
                UsedProgram = (IProgram)(PcgRoot.ProgramBanks[0][0]);
            }
            else
            {
                UsedProgram = memory.AssignedClearProgram;
            }

            GetParam(ParameterNames.TimbreParameterName.Status).Value = "Off";
            if (GetParam(ParameterNames.TimbreParameterName.Mute) != null)
            {
                GetParam(ParameterNames.TimbreParameterName.Mute).Value = true;
            }
            GetParam(ParameterNames.TimbreParameterName.Volume).Value      = 0;
            GetParam(ParameterNames.TimbreParameterName.MidiChannel).Value = 15;

            GetParam(ParameterNames.TimbreParameterName.BottomKey).Value      = 0;
            GetParam(ParameterNames.TimbreParameterName.TopKey).Value         = 0;
            GetParam(ParameterNames.TimbreParameterName.BottomVelocity).Value = 0;
            GetParam(ParameterNames.TimbreParameterName.TopVelocity).Value    = 0;
            GetParam(ParameterNames.TimbreParameterName.OscMode).Value        = "Force Poly";
            GetParam(ParameterNames.TimbreParameterName.OscSelect).Value      = "Hide OSC2";

            GetParam(ParameterNames.TimbreParameterName.Transpose).Value = 0;
            GetParam(ParameterNames.TimbreParameterName.BendRange).Value = 0;

            RefillColumns();
        }
Example #3
0
        /// <summary>
        /// Cut or Copy for cut/copy/paste.
        /// </summary>
        /// <param name="pcgClipBoard"></param>
        /// <param name="setListsSelected"></param>
        /// <param name="waveSequenceBanksSelected"></param>
        /// <param name="allPatchesSelected"></param>
        /// <param name="banks"></param>
        /// <param name="patches"></param>
        /// <param name="cutPasteAction">Cut paste action selected; clears patches after copying (otherwise it is a
        /// cut/copy/paste action)</param>
        /// <param name="selectedPcgMemory"></param>
        /// <param name="selectedScopeSet"></param>
        /// <param name="programBanksSelected"></param>
        /// <param name="combiBanksSelected"></param>
        /// <param name="drumKitBanksSelected"></param>
        /// /// <param name="drumPatternBanksSelected"></param>
        public void CopyPasteCopy(IPcgClipBoard pcgClipBoard, IPcgMemory selectedPcgMemory, PcgViewModel.ScopeSet selectedScopeSet,
                                  bool programBanksSelected, bool combiBanksSelected, bool setListsSelected, bool drumKitBanksSelected,
                                  bool drumPatternBanksSelected, bool waveSequenceBanksSelected,
                                  bool allPatchesSelected,
                                  ObservableCollectionEx <IBank> banks, ObservableCollectionEx <IPatch> patches, bool cutPasteAction)
        {
            PcgClipBoard              = pcgClipBoard;
            SelectedPcgMemory         = selectedPcgMemory;
            SelectedScopeSet          = selectedScopeSet;
            ProgramBanksSelected      = programBanksSelected;
            CombiBanksSelected        = combiBanksSelected;
            SetListsSelected          = setListsSelected;
            DrumKitBanksSelected      = drumKitBanksSelected;
            DrumPatternBanksSelected  = drumPatternBanksSelected;
            WaveSequenceBanksSelected = waveSequenceBanksSelected;
            AllPatchesSelected        = allPatchesSelected;
            Banks   = banks;
            Patches = patches;

            CopyPasteInit(cutPasteAction);

            CopyPasteCopyPatches(cutPasteAction);

            PcgClipBoard.Memorize();
        }
Example #4
0
        public void ChangeCombi()
        {
            IPcgMemory pcg          = CreatePcg();
            IProgram   programIa000 = (IProgram)pcg.ProgramBanks[0][0];
            ICombi     combiIa000   = (ICombi)(pcg.CombiBanks[0])[0];

            combiIa000.Name = "NonEmpty";

            combiIa000.Timbres.TimbresCollection[0].UsedProgram = programIa000;

            // Set most virtual banks loaded to save time.
            foreach (IBank bank in pcg.CombiBanks.BankCollection.Where(
                         bank => (bank.Type == BankType.EType.Virtual) && (bank.Id != "V-0A")))
            {
                bank.IsLoaded = false;
            }

            // Run actual test.
            ReferenceChanger referenceChanger = new ReferenceChanger(pcg);
            RuleParser       ruleParser       = new RuleParser(pcg);

            referenceChanger.ParseRules(ruleParser, "I-A000->I-B000");
            referenceChanger.ChangeReferences();

            Debug.Assert(combiIa000.Timbres.TimbresCollection[0].UsedProgram == pcg.ProgramBanks[1][0]);
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pcgClipBoard"></param>
        /// <param name="selectedPcgMemory"></param>
        /// <param name="selectedScopeSet"></param>
        /// <param name="programBanksSelected"></param>
        /// <param name="combiBanksSelected"></param>
        /// <param name="setListsSelected"></param>
        /// <param name="waveSequenceBanksSelected"></param>
        /// <param name="allPatchesSelected"></param>
        /// <param name="banks"></param>
        /// <param name="patches"></param>
        /// <param name="drumKitsSelected"></param>
        /// <param name="drumPatternsSelected"></param>
        /// <returns></returns>
        public string CopyPastePaste(IPcgClipBoard pcgClipBoard, IPcgMemory selectedPcgMemory, PcgViewModel.ScopeSet selectedScopeSet,
                                     bool programBanksSelected, bool combiBanksSelected, bool setListsSelected, bool drumKitsSelected,
                                     bool drumPatternsSelected, bool waveSequenceBanksSelected,
                                     bool allPatchesSelected,
                                     ObservableCollectionEx <IBank> banks, ObservableCollectionEx <IPatch> patches)
        {
            PcgClipBoard              = pcgClipBoard;
            SelectedPcgMemory         = selectedPcgMemory;
            SelectedScopeSet          = selectedScopeSet;
            ProgramBanksSelected      = programBanksSelected;
            CombiBanksSelected        = combiBanksSelected;
            SetListsSelected          = setListsSelected;
            DrumKitBanksSelected      = drumKitsSelected;
            DrumPatternBanksSelected  = drumPatternsSelected;
            WaveSequenceBanksSelected = waveSequenceBanksSelected;
            AllPatchesSelected        = allPatchesSelected;
            Banks   = banks;
            Patches = patches;

            PasteDuplicates();

            var infoText = PastePatches();

            if (!PcgClipBoard.CutPasteSelected)
            {
                PcgClipBoard.FixPasteReferencesAfterCopyPaste();
            }

            if (PcgClipBoard.IsPastingFinished)
            {
                PastingFinished();
            }

            return(infoText);
        }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="currentPcgMemory"></param>
 /// <param name="content"></param>
 /// <param name="contentType"></param>
 /// <param name="sysExStartOffset"></param>
 /// <param name="sysExEndOffset"></param>
 public Z1FileReader(
     IPcgMemory currentPcgMemory, byte[] content, PcgMemory.ContentType contentType,
     int sysExStartOffset, int sysExEndOffset)
     : base(currentPcgMemory, content, contentType, sysExStartOffset, sysExEndOffset)
 {
     //TimbreByteSize = 16;
 }
Example #7
0
        public static void SetChars(IPcgMemory pcgMemory, byte[] data, int start, int maxLength, string text)
        {
            Debug.Assert(pcgMemory != null);
            Debug.Assert(data != null);

            Debug.Assert(start >= 4); // Do not overwrite KORG header.
            Debug.Assert(text.Length <= maxLength);

            var dirty = false;

            int index;

            for (index = 0; index < text.Length; index++)
            {
                var orgData = data[start + index];
                data[start + index] = (byte)(text[index]);
                //Console.WriteLine(String.Format("SetChars: Write {0} to {1} ", (byte) (text[index]), start + index));
                dirty |= (orgData != data[start + index]);
            }

            // Padd with zeros.
            while (index < maxLength)
            {
                dirty |= (data[start + index] != 0);
                data[start + index] = 0;
                index++;
            }

            pcgMemory.IsDirty |= dirty;
        }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="currentPcgMemory"></param>
 /// <param name="content"></param>
 /// <param name="contentType"></param>
 /// <param name="sysExStartOffset"></param>
 /// <param name="sysExEndOffset"></param>
 protected SysExFileReader(IPcgMemory currentPcgMemory, byte[] content,
                           PcgMemory.ContentType contentType, int sysExStartOffset, int sysExEndOffset)
     : base(currentPcgMemory, content)
 {
     ContentType      = contentType;
     SysExStartOffset = sysExStartOffset;
     SysExEndOffset   = sysExEndOffset;
 }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="memory"></param>
        public ProgramReferenceChangerWindow(IPcgMemory memory)
        {
            _memory = memory;
            InitializeComponent();

            LabelProgress.Visibility    = Visibility.Hidden;
            ProgressBarRules.Visibility = Visibility.Hidden;
        }
Example #10
0
        public void NoRules()
        {
            IPcgMemory pcg        = CreatePcg();
            RuleParser ruleParser = new RuleParser(pcg);

            ruleParser.Parse("");
            Debug.Assert(ruleParser.HasParsedOk);
            Debug.Assert(ruleParser.ParsedRules.Count == 0);
        }
        /// <summary>
        /// Changes all references of the original location of patch to program.
        /// Only used for cut/paste.
        /// </summary>
        /// <param name="patch"></param>
        /// <param name="program"></param>
        private static void FixReferencesToProgram(IClipBoardPatch patch, IProgram program)
        {
            IPcgMemory memory = patch.OriginalLocation.Root as IPcgMemory;

            Debug.Assert(memory != null);

            FixProgramReferencesToCombi(patch, program, memory);
            FixProgramReferencesToSetLists(patch, program, memory);
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="memory"></param>
        /// <param name="offset"></param>
        private void ReadAllCombis(IPcgMemory memory, int offset)
        {
            _bank       = 0;
            _patchIndex = 0;

            foreach (IBank bank in memory.CombiBanks.BankCollection)
            {
                ReadSingleCombi(offset);
                offset += bank.ByteLength;
            }
        }
Example #13
0
        public void BankRule()
        {
            IPcgMemory pcg        = CreatePcg();
            RuleParser ruleParser = new RuleParser(pcg);

            ruleParser.Parse("I-A->I-B");
            Debug.Assert(ruleParser.HasParsedOk);

            Debug.Assert(ruleParser.ParsedRules.Count == pcg.ProgramBanks[0].CountPatches);
            PcgTools.Model.Common.Synth.Meta.IPatch rule = ruleParser.ParsedRules[pcg.ProgramBanks[0][127]]; // I-A127
            Debug.Assert(rule == pcg.ProgramBanks[1][127]);                                                  // I-B127
        }
Example #14
0
        public void RangeRule()
        {
            IPcgMemory pcg        = CreatePcg();
            RuleParser ruleParser = new RuleParser(pcg);

            ruleParser.Parse("I-A000..010->I-B000..010");
            Debug.Assert(ruleParser.HasParsedOk);

            Debug.Assert(ruleParser.ParsedRules.Count == 11);
            PcgTools.Model.Common.Synth.Meta.IPatch rule = ruleParser.ParsedRules[pcg.ProgramBanks[0][10]]; // I-A010
            Debug.Assert(rule == pcg.ProgramBanks[1][10]);                                                  // I-B010
        }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="memory"></param>
        /// <param name="offset"></param>
        private void ReadAllPrograms(IPcgMemory memory, int offset)
        {
            _bank       = 0;
            _patchIndex = 0;

            foreach (IBank bank in memory.ProgramBanks.BankCollection.Where(
                         bank => bank.Type != BankType.EType.Gm))
            {
                ReadSingleProgram(offset);
                offset += bank.ByteLength;
            }
        }
Example #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="changes"></param>
 /// <param name="pcgMemory">PCG Memory of changes</param>
 public void ChangeTimbreReferences(Dictionary <IProgram, IProgram> changes, IPcgMemory pcgMemory)
 {
     foreach (ITimbre timbre in from bank in BankCollection
              where bank.IsFilled
              from combi in bank.Patches
              from timbre in ((Combi)combi).Timbres.TimbresCollection
              where  (!timbre.UsedProgram.IsFromMasterFile || timbre.UsedProgram.PcgRoot == pcgMemory) &&
              changes.ContainsKey(timbre.UsedProgram)
              select timbre)
     {
         timbre.UsedProgram = changes[timbre.UsedProgram];
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnPcgViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "SelectedMemory")
            {
                IPcgMemory memory = ((PcgViewModel)sender).SelectedPcgMemory;
                if (memory != null)
                {
                    memory.PropertyChanged += OnSelectedPcgMemoryPropertyChanged;
                }

                Instances.UpdateStates();
            }
        }
Example #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="currentPcgMemory"></param>
 /// <param name="content"></param>
 public TritonKarmaPcgFileReader(IPcgMemory currentPcgMemory, byte[] content)
     : base(currentPcgMemory, content)
 {
     // PcgFileHeader PcgFileHeader;
     // Pcg1Chunk Pcg1Chunk;
     // Div1Chunk Div1Chunk;
     // Ini2Chunk Ini2Chunk;
     // Ini1Chunk Ini1Chunk;
     // Prg1Chunk Prg1Chunk;
     // Cmb1Chunk Cmb1Chunk;
     // Dkt1Chunk Dkt1Chunk;
     // Arp1Chunk Arp1Chunk;
     // Glb1Chunk Glb1Chunk;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pcgMemory"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public override IPatchesFileReader CreateFileReader(IPcgMemory pcgMemory, byte[] content)
        {
            PatchesFileReader reader;

            if (Util.GetChars(content, 0, 2) == "tr")
            {
                reader = new Kross2TrFileReader(pcgMemory, content, _contentType);
            }
            else
            {
                reader = new Kross2PcgFileReader(pcgMemory, content);
            }
            return(reader);
        }
Example #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="currentPcgMemory"></param>
 /// <param name="content"></param>
 /// <param name="modeChangeOffset"></param>
 public M50PcgFileReader(IPcgMemory currentPcgMemory, byte[] content, int modeChangeOffset = 0)
     : base(currentPcgMemory, content)
 {
     // PcgFileHeader PcgFileHeader;
     // Pcg1Chunk Pcg1Chunk;
     // Div1Chunk Div1Chunk;
     // Ini2Chunk Ini2Chunk;
     // Ini1Chunk Ini1Chunk;
     // Prg1Chunk Prg1Chunk;
     // Cmb1Chunk Cmb1Chunk;
     // Dkt1Chunk Dkt1Chunk;
     // Arp1Chunk Arp1Chunk;
     // Glb1Chunk Glb1Chunk;
 }
Example #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="currentPcgMemory"></param>
 /// <param name="content"></param>
 protected KronosOasysPcgFileReader(IPcgMemory currentPcgMemory, byte[] content)
     : base(currentPcgMemory, content)
 {
     // PcgFileHeader PcgFileHeader;
     // Pcg1Chunk Pcg1Chunk;
     // Div1Chunk Div1Chunk;
     // Ini2Chunk Ini2Chunk;
     // Ini1Chunk Ini1Chunk;
     // Sls1Chunk Sls1Chunk;
     // Prg1Chunk Prg1Chunk;
     // Cmb1Chunk Cmb1Chunk;
     // Dkt1Chunk Dkt1Chunk;
     // Arp1Chunk Arp1Chunk;
     // Glb1Chunk Glb1Chunk;
 }
Example #22
0
        /// <summary>
        /// Returns the global of this PCG or if no global present, the Master PCG file's global.
        /// This is a copy from Timbre.cs
        /// </summary>
        /// <returns></returns>
        protected IGlobal FindGlobal()
        {
            IGlobal global = (PcgRoot.Content == null) ? null : PcgRoot.Global;

            if (global == null)
            {
                // Find master PCG memory (except when file is master file itself).
                IPcgMemory masterPcgMemory = MasterFiles.MasterFiles.Instances.FindMasterPcg(Root.Model);
                if ((masterPcgMemory != null) && (masterPcgMemory.FileName != Root.FileName))
                {
                    global = masterPcgMemory.Global;
                }
            }
            return(global);
        }
Example #23
0
        public static void SetInt(IPcgMemory pcgMemory, byte[] data, int start, int amount, int value)
        {
            Debug.Assert(pcgMemory != null);
            Debug.Assert(data != null);

            var dirty = false;

            switch (amount)
            {
            case 1:
                Debug.Assert((value >= 0) && (value <= 255));
                dirty |= (data[start] != (byte)value);
                //Console.WriteLine(String.Format("SetInt: Write {0} to {1} ", (byte) value, start));
                data[start] = (byte)value;
                break;

            case 2:
                Debug.Assert((value >= 0) && (value <= 65535));
                dirty |= (data[start] != (byte)(value / 256));
                //Console.WriteLine(String.Format("SetInt: Write two bytes to {0}", start));
                data[start]     = (byte)(value / 256);
                dirty          |= (data[start + 1] != (byte)(value % 256));
                data[start + 1] = (byte)(value % 256);
                break;

            case 4:
                //Console.WriteLine(String.Format("SetInt: Write four bytes to {0}", start));
                dirty          |= (data[start + 3] != (byte)(value % 256));
                data[start + 3] = (byte)(value % 256);

                value          /= 256;
                dirty          |= (data[start + 2] != (byte)(value % 256));
                data[start + 2] = (byte)(value % 256);

                value          /= 256;
                dirty          |= (data[start + 1] != (byte)(value % 256));
                data[start + 1] = (byte)(value % 256);

                dirty      |= (data[start] != (byte)(value / 256));
                data[start] = (byte)(value / 256);
                break;

            default:
                throw new ApplicationException("Illegal value");
            }

            pcgMemory.IsDirty |= dirty;
        }
Example #24
0
        /// <summary>
        /// In case the name changes, check if it is a single patch file and if so, the name of the file might need to be changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "Name":
                IPcgMemory memory = PcgRoot;
                if ((memory.HasOnlyOnePatch && Settings.Default.Edit_RenameFileWhenPatchNameChanges))
                {
                    string directoryName = Path.GetDirectoryName(memory.OriginalFileName);
                    PcgRoot.FileName = directoryName + memory.NameOfOnlyPatch;
                }
                break;

                // default: Do nothing
            }
        }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="currentPcgMemory"></param>
        /// <param name="content"></param>
        public MicroStationPcgFileReader(IPcgMemory currentPcgMemory, byte[] content)
            : base(currentPcgMemory, content)
        {
            // PcgFileHeader PcgFileHeader;
            // Pcg1Chunk Pcg1Chunk;
            // Div1Chunk Div1Chunk;
            // Ini2Chunk Ini2Chunk;
            // Ini1Chunk Ini1Chunk;
            // Prg1Chunk Prg1Chunk;
            // Cmb1Chunk Cmb1Chunk;
            // Dkt1Chunk Dkt1Chunk;
            // Arp1Chunk Arp1Chunk;
            // Glb1Chunk Glb1Chunk;

            currentPcgMemory.PcgChecksumType = PcgMemory.ChecksumType.MicroStation;
        }
Example #26
0
        public void TwoRules()
        {
            IPcgMemory pcg = CreatePcg();

            pcg.Content = new byte[10000];
            RuleParser ruleParser = new RuleParser(pcg);

            ruleParser.Parse("I-A000->I-B000\nI-A001->I-B001");
            Debug.Assert(ruleParser.HasParsedOk);

            Debug.Assert(ruleParser.ParsedRules.Count == 2);
            PcgTools.Model.Common.Synth.Meta.IPatch rule = ruleParser.ParsedRules[pcg.ProgramBanks[0][0]]; // I-A000
            Debug.Assert(rule == pcg.ProgramBanks[1][0]);                                                  // I-B000
            rule = ruleParser.ParsedRules[pcg.ProgramBanks[0][1]];                                         // I-A001
            Debug.Assert(rule == pcg.ProgramBanks[1][1]);                                                  // I-B001
        }
Example #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="currentPcgMemory"></param>
        /// <param name="content"></param>
        public NautilusPcgFileReader(IPcgMemory currentPcgMemory, byte[] content)
            : base(currentPcgMemory, content)
        {
            // PcgFileHeader PcgFileHeader;
            // Pcg1Chunk Pcg1Chunk;
            // Div1Chunk Div1Chunk;
            // Ini2Chunk Ini2Chunk;
            // Ini1Chunk Ini1Chunk;
            // Sls1Chunk Sls1Chunk;
            // Prg1Chunk Prg1Chunk;
            // Cmb1Chunk Cmb1Chunk;
            // Dkt1Chunk Dkt1Chunk;
            // Arp1Chunk Arp1Chunk;
            // Glb1Chunk Glb1Chunk;

            currentPcgMemory.Model = Models.Find(Models.EOsVersion.Nautilus);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="currentPcgMemory"></param>
        /// <param name="content"></param>
        /// <param name="modeChangeOffset"></param>
        public Kross2PcgFileReader(IPcgMemory currentPcgMemory, byte[] content, int modeChangeOffset = 0)
            : base(currentPcgMemory, content)
        {
            // PcgFileHeader PcgFileHeader;
            // Pcg1Chunk Pcg1Chunk;
            // Div1Chunk Div1Chunk;
            // Ini2Chunk Ini2Chunk;
            // Ini1Chunk Ini1Chunk;
            // Prg1Chunk Prg1Chunk;
            // Cmb1Chunk Cmb1Chunk;
            // Dkt1Chunk Dkt1Chunk;
            // Arp1Chunk Arp1Chunk;
            // Glb1Chunk Glb1Chunk;

            if (content[9] == 1)
            {
                currentPcgMemory.PcgChecksumType = PcgMemory.ChecksumType.Kross2;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pcgMemory"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public override IPatchesFileReader CreateFileReader(IPcgMemory pcgMemory, byte[] content)
        {
            IPatchesFileReader reader = null;

            switch (_fileType)
            {
            case Memory.FileType.MkxlPAll:
                reader = new MicroKorgXlMkxlPAllFileReader(pcgMemory, content);
                break;

            case Memory.FileType.MkxlPProg:
                reader = new MicroKorgXlMkxlPProgFileReader(pcgMemory, content);
                break;

            default:
                throw new NotSupportedException("Unsupported reader");
            }
            return(reader);
        }
        /// <summary>
        /// Changes all references of the original location of patch to combi.
        /// Only used for cut/paste.
        /// </summary>
        /// <param name="patch"></param>
        /// <param name="combi"></param>
        private static void FixReferencesToCombi(IClipBoardPatch patch, ICombi combi)
        {
            IPcgMemory memory = patch.OriginalLocation.Root as IPcgMemory;

            Debug.Assert(memory != null);

            // Change set list slots (if present and not from master file).
            if (memory.SetLists != null)
            {
                foreach (ISetListSlot slot in memory.SetLists.BankCollection.Where(
                             bank => bank.IsWritable && !bank.IsFromMasterFile).SelectMany(
                             list => list.Patches, (list, patch1) => (ISetListSlot)patch1).Where(
                             slot => (slot.SelectedPatchType == SetListSlot.PatchType.Combi) &&
                             (slot.UsedPatch == patch.OriginalLocation)))
                {
                    slot.UsedPatch = combi;
                }
            }
        }