private void FillDictionaryWithSetListSlots() { for (int setListIndex = 0; setListIndex < 128; setListIndex++) { if ((setListIndex < SetListsRangeFrom) || (setListIndex > SetListsRangeTo)) { continue; } ISetList setList = ((ISetList)PcgMemory.SetLists[setListIndex]); foreach (IPatch setListSlot in setList.Patches.Where( setListSlot => setList.IsLoaded && !setListSlot.IsEmptyOrInit)) { switch (((ISetListSlot)setListSlot).SelectedPatchType) { case SetListSlot.PatchType.Program: { IProgramBank usedProgramBank = ((ISetListSlot)setListSlot).UsedPatch.Parent as IProgramBank; Tuple <IProgramBank, IProgram> key = new Tuple <IProgramBank, IProgram>(usedProgramBank, ((ISetListSlot)setListSlot).UsedPatch as IProgram); if (_dict.ContainsKey(key) && !_dict[key].Contains(setListSlot)) { _dict[key].AddLast(setListSlot); } } break; } } } }
/// <summary> /// Copies combi and set list slot. /// </summary> /// <param name="setListTarget"></param> /// <param name="combiBankTarget"></param> /// <param name="mainMidiChannel"></param> /// <param name="secondaryMidiChannel"></param> /// <param name="sourceSetListSlot"></param> /// <param name="currentTargetCombiIndex"></param> /// <param name="finishedPrematurely"></param> /// <param name="currentTargetSetListSlotIndex"></param> /// <returns></returns> private static bool CopySecondaryPatches(ISetList setListTarget, ICombiBank combiBankTarget, int mainMidiChannel, int secondaryMidiChannel, ISetListSlot sourceSetListSlot, ref int currentTargetCombiIndex, ref bool finishedPrematurely, ref int currentTargetSetListSlotIndex) { ICombi sourceCombi = (ICombi)sourceSetListSlot.UsedPatch; if (sourceCombi.UsesMidiChannel(secondaryMidiChannel)) { // Create second combi with changed name and MIDI channels switched. if (currentTargetCombiIndex >= combiBankTarget.CountPatches) { finishedPrematurely = true; return(true); } sourceCombi.PcgRoot.CopyPatch(sourceCombi, combiBankTarget.Patches[currentTargetCombiIndex]); ICombi combi = (ICombi)combiBankTarget.Patches[currentTargetCombiIndex]; combi.SetNameSuffix($"/MC{secondaryMidiChannel}"); combi.SwitchMidiChannels(mainMidiChannel, secondaryMidiChannel); currentTargetCombiIndex++; // Copy set list slot with changed name and referencing to combi. if (currentTargetSetListSlotIndex >= setListTarget.Patches.Count) { finishedPrematurely = true; return(true); } sourceSetListSlot.PcgRoot.CopyPatch(sourceSetListSlot, setListTarget.Patches[currentTargetSetListSlotIndex]); ISetListSlot setListSlotSecondary = (ISetListSlot)setListTarget.Patches[currentTargetSetListSlotIndex]; setListSlotSecondary.SetNameSuffix($"/MC{secondaryMidiChannel}"); setListSlotSecondary.UsedPatch = combi; currentTargetSetListSlotIndex++; } return(false); }
public static IEnumerator LoadResOfType <T>(string path, ISetList comp) where T : Object { AssetBundle bundle = LoadAssetBundleDependcy(path); List <T> TList = new List <T>(); if (bundle != null) { int assetNameStart = path.LastIndexOf("/") + 1; int assetNameEnd = path.LastIndexOf(".") == -1 ? path.Length : path.LastIndexOf("."); string assetName = path.Substring(assetNameStart, assetNameEnd - assetNameStart); Debug.Log(assetName); Object[] objList = bundle.LoadAllAssets(typeof(T)); for (int i = 0; i < objList.Length; ++i) { TList.Add(objList[i] as T); } } yield return(null); comp.setList <T>(TList); }
/// <summary> /// /// </summary> /// <param name="setList"></param> public WindowEditSingleSetList(ISetList setList) { InitializeComponent(); _setList = setList; }
/// <summary> /// /// </summary> /// <param name="setListSource"></param> /// <param name="setListTarget"></param> /// <param name="combiBankTarget"></param> /// <param name="mainMidiChannel"></param> /// <param name="secondaryMidiChannel"></param> internal void Process(ISetList setListSource, ISetList setListTarget, Model.Common.Synth.PatchCombis.ICombiBank combiBankTarget, int mainMidiChannel, int secondaryMidiChannel) { int currentTargetSetListSlotIndex = 0; int currentTargetCombiIndex = 0; bool finishedPrematurely = false; string errorText = string.Empty; if (!setListSource.IsLoaded) { finishedPrematurely = true; errorText = PcgToolsResources.Strings.KeyboardSetupErrorSetListsNotPresent; //TODO page 178 manual } else if (setListTarget.CountFilledPatches > 0) { finishedPrematurely = true; errorText = PcgToolsResources.Strings.KeyboardSetupErrorTargetSetListNotEmpty; } else if (!combiBankTarget.IsWritable) { finishedPrematurely = true; errorText = PcgToolsResources.Strings.KeyboardSetupErrorTargetCombiBankNotPresent; } else { foreach (Model.Common.Synth.Meta.IPatch patch in setListSource.Patches.Where(patch => !((ISetListSlot)patch).IsEmptyOrInit)) { ISetListSlot sourceSetListSlot = (ISetListSlot)patch; if (currentTargetSetListSlotIndex >= setListTarget.Patches.Count) { finishedPrematurely = true; errorText = PcgToolsResources.Strings.KeyboardSetupErrorNotEnoughSetListSlotsInTargetSetList; break; } // copy set list slot to target set list. // change suffix sourcemidi sourceSetListSlot.PcgRoot.CopyPatch(sourceSetListSlot, setListTarget.Patches[currentTargetSetListSlotIndex]); Model.Common.Synth.Meta.IPatch targetSetListSlot = setListTarget.Patches[currentTargetSetListSlotIndex]; targetSetListSlot.SetNameSuffix($"/MC{mainMidiChannel}"); currentTargetSetListSlotIndex++; if (sourceSetListSlot.SelectedPatchType == SetListSlot.PatchType.Combi) { if (CopySecondaryPatches(setListTarget, combiBankTarget, mainMidiChannel, secondaryMidiChannel, sourceSetListSlot, ref currentTargetCombiIndex, ref finishedPrematurely, ref currentTargetSetListSlotIndex)) { break; } } } } if (finishedPrematurely) { // Show message box. Console.WriteLine(errorText); } }