/// <summary> /// /// </summary> /// <param name="combi"></param> public TritonLeTimbres(ICombi combi) : base(combi, TimbresOffsetConstant) { for (var n = 0; n < TimbresPerCombi; n++) { TimbresCollection.Add(new TritonLeTimbre(this, n)); } }
/// <summary> /// /// </summary> /// <param name="combi"></param> public MicroStationTimbres(ICombi combi) : base(combi, TimbresOffsetConstant) { for (int n = 0; n < TimbresPerCombi; n++) { TimbresCollection.Add(new MicroStationTimbre(this, n)); } }
/// <summary> /// /// </summary> /// <param name="combi"></param> public Zero3RwTimbres(ICombi combi) : base(combi) { TimbresCollection.Clear(); //IMPR: is clear really necessary here? for (var n = 0; n < TimbresPerCombi; n++) { TimbresCollection.Add(new Zero3RwTimbre(this, n)); } }
/// <summary> /// /// </summary> /// <param name="rule"></param> /// <param name="combi"></param> private void ChangeReferencesInTimbres(KeyValuePair <IPatch, IPatch> rule, ICombi combi) { foreach (var timbre in combi.Timbres.TimbresCollection.Where(timbre => timbre.UsedProgram == rule.Key)) { if (((timbre.GetParam(ParameterNames.TimbreParameterName.Status).Value == "Off") || (timbre.GetParam(ParameterNames.TimbreParameterName.Status).Value == "Int")) && !_processedTimbres.Contains(timbre)) { timbre.UsedProgram = (IProgram)rule.Value; _processedTimbres.Add(timbre); } } }
/// <summary> /// /// </summary> /// <param name="combi"></param> /// <param name="timbresPerCombi"></param> /// <param name="timbresOffset"></param> protected Timbres(ICombi combi, int timbresPerCombi, int timbresOffset) { Debug.Assert(timbresPerCombi > 0); Debug.Assert(timbresOffset > 0); TimbresCollection = new ObservableCollectionEx <ITimbre>(); _combi = combi; TimbresPerCombi = timbresPerCombi; TimbresOffset = timbresOffset; Fill(); }
/// <summary> /// /// </summary> /// <param name="offset"></param> private void ReadSingleCombi(int offset) { ICombiBank bank = (ICombiBank)(CurrentPcgMemory.CombiBanks[0]); bank.ByteOffset = 0; bank.ByteLength = 240; bank.IsWritable = true; bank.IsLoaded = true; ICombi combi = (ICombi)bank[0]; combi.ByteOffset = offset; combi.ByteLength = bank.ByteLength; combi.IsLoaded = true; }
/// <summary> /// /// </summary> /// <param name="pcgViewModel"></param> /// <param name="combi"></param> public CombiViewModel(IPcgViewModel pcgViewModel, ICombi combi) { PcgViewModel = pcgViewModel; Combi = combi; // Select first if none selected. if ((Combi.Timbres.TimbresCollection.Any()) && (Combi.Timbres.TimbresCollection.Count(item => item.IsSelected) == 0)) { Combi.Timbres.TimbresCollection[0].IsSelected = true; } Combi.PcgRoot.PropertyChanged += OnPcgRootChanged; ReassignClearProgram(); }
private void ReadSingleCombi(int offset) { ICombiBank bank = (ICombiBank)(CurrentPcgMemory.CombiBanks[_bank]); bank.ByteOffset = 0; bank.ByteLength = 0x7bc; bank.IsWritable = true; bank.IsLoaded = true; ICombi combi = (ICombi)bank[_patchIndex]; combi.ByteOffset = offset; combi.ByteLength = bank.ByteLength; combi.IsLoaded = true; IncreaseCombi(); }
/// <summary> /// /// </summary> /// <param name="writer"></param> private void WriteLongListToFile(TextWriter writer) { foreach (IPatch patch in from combiBank in SelectedCombiBanks from combi in combiBank.Patches where combiBank.IsLoaded && combi.UseInList(IgnoreInitCombis, FilterOnText, FilterText, FilterCaseSensitive, ListFilterOnFavorites, false) select combi) { ICombi combi = (ICombi)patch; // Gather info for header. string categoryString = combi.CategoryAsName; //var subCategory = combi.GetParam("SubCategory"); string subCategoryString = combi.SubCategoryAsName; IParameter favorite = combi.PcgRoot.AreFavoritesSupported ? combi.GetParam(ParameterNames.CombiParameterName.Favorite) : null; string favoriteString = (favorite == null) ? "-" : (favorite.Value) ? "Yes" : "No"; IParameter paramTempo = combi.GetParam(ParameterNames.CombiParameterName.Tempo); dynamic tempo = paramTempo == null ? "-" : string.Format("{0,6:0.00}", paramTempo.Value); // Print header. writer.WriteLine("+------------+-----------------------------+----------------------------+--------------------------------+------------+-------+---------------------------------+"); // ReSharper disable RedundantStringFormatCall writer.WriteLine(string.Format(new CultureInfo("en-US"), // ReSharper restore RedundantStringFormatCall "|Combi {0,-6}|Name:{1,-24}|Cat:{2,-24}|Sub Cat:{3,-24}|Tempo:{4,-6}|Fav:{5,-3}| |", combi.Id, combi.Name, categoryString, subCategoryString, tempo, favoriteString)); writer.WriteLine("+------------+-----------------------------+----------------------------+--------------------------------+------------+-------+---------------------------------+"); writer.WriteLine("|Timbres List |"); writer.WriteLine("+---+----------+------------------------+------------------------+------------------------+---+---+----+----+----+---------+-------+----+----+---+-----+---+----+"); writer.WriteLine("|Tim|Program |Name of the program |Category |Sub Category |Vol|Sta|Mute|Prio|MIDI|Key Zone |Veloc. |OSC |OSC |Tra| De- |Por|Bend|"); writer.WriteLine("|bre| | | | |ume|tus| |rity|Ch. | |Zone |Mode|Sel.|nsp|tune |tam|Rng.|"); writer.WriteLine("+---+----------+------------------------+------------------------+------------------------+---+---+----+----+----+---------+-------+----+----+---+-----+---+----+"); // Print timbres.); for (int index = 0; index < combi.Timbres.TimbresCollection.Count; index++) { PrintTimbre(writer, combi, index); } // Print footer. writer.WriteLine("+---+----------+------------------------+------------------------+------------------------+---+---+----+----+----+---------+-------+----+----+---+-----+---+----+\r\n"); } }
/// <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> static void FixReferencesToCombi(IClipBoardPatch patch, ICombi combi) { var 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 (var 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; } } }
/// <summary> /// /// </summary> /// <param name="patchToPaste"></param> /// <param name="patch"></param> public void PastePatch(IClipBoardPatch patchToPaste, IPatch patch) { // Copy patch from clipboard to PCG. patch.PcgRoot.CopyPatch(patchToPaste, patch); patchToPaste.PasteDestination = patch; ProtectedPatches.Add(patch); if (CutPasteSelected) { IProgram program = patch as IProgram; if (program != null) { FixReferencesToProgram(patchToPaste, program); } else { ICombi combi = patch as ICombi; if (combi != null) { FixReferencesToCombi(patchToPaste, combi); } else { IDrumKit drumKit = patch as IDrumKit; if (drumKit != null) { FixReferencesToDrumKit(patchToPaste, drumKit); } else { IDrumPattern drumPattern = patch as IDrumPattern; if (drumPattern != null) { FixReferencesToDrumPattern(patchToPaste, drumPattern); } } } } // If it is a set list slot do nothing. } }
/// <summary> /// /// </summary> /// <param name="pcgViewModel"></param> /// <param name="combi"></param> public CombiWindow(IPcgViewModel pcgViewModel, ICombi combi) { InitializeComponent(); ViewModel = new CombiViewModel(pcgViewModel, combi) { ShowEditDialog = () => { var window = new WindowEditSingleCombi(CombiViewModel.Combi); var result = window.ShowDialog(); return(result.HasValue && result.Value); }, UpdateUiContent = () => { listViewTimbres.Items.Refresh(); listViewTimbres.UpdateLayout(); }, CloseWindow = CloseWindow }; DataContext = ViewModel; }
/// <summary> /// /// </summary> /// <param name="setListSlot"></param> /// <param name="clearAfterCopy"></param> public void CopySetListSlotToClipBoard(ISetListSlot setListSlot, bool clearAfterCopy) { // Copy set list slot. if (setListSlot.PcgRoot.Content != null) { ClipBoardSetListSlot clipBoardSetListSlot = new ClipBoardSetListSlot(setListSlot); SetListSlots.CopiedPatches.Add(clipBoardSetListSlot); if (clearAfterCopy) { setListSlot.Clear(); } // Copy program of combi (do not copy song). if (!CutPasteSelected) { IPatch usedPatch = setListSlot.UsedPatch; if ((usedPatch != null) && (Settings.Default.CopyPaste_CopyPatchesFromMasterFile || !usedPatch.IsFromMasterFile)) { if (setListSlot.UsedPatch is IProgram) { IProgram program = (IProgram)usedPatch; if (((IProgramBank)(program.Parent)).Type != BankType.EType.Gm) { clipBoardSetListSlot.Reference = CopyProgramToClipBoard(program, false); } } else if (setListSlot.UsedPatch is ICombi) { ICombi combi = (ICombi)usedPatch; clipBoardSetListSlot.Reference = CopyCombiToClipBoard(combi, false); } } } } }
/* * /// <summary> * /// Fix drum kit references in programs (clipBoardPatches). * /// </summary> * /// <param name="clipBoardPatches"></param> * private void FixPasteDrumKitReferencesInPrograms(IEnumerable<IClipBoardPatch> clipBoardPatches) * { * foreach (var clipBoardPatch in clipBoardPatches) * { * var program = (IClipBoardProgram) clipBoardPatch; * foreach (var clipBoardDrumKit in DrumKits.CopiedPatches) * { * var drumKits = program.ReferencedDrumKits; * for (var drumKitIndex = 0; drumKitIndex < drumKits.CopiedPatches.Count(); drumKitIndex++) * { * var drumKit = program.ReferencedDrumKits.CopiedPatches[drumKitIndex]; * if (drumKit != clipBoardDrumKit) * { * continue; * } * * if ((drumKit.PasteDestination != null) && (program.PasteDestination != null)) * { * // When pasting to the same file, then it is not wanted to fix references, * // because a duplicate drumkit/program can exist before the original reference * // so it will be changed unnecessarily. * if (drumKit.OriginalLocation.Root != PastePcgMemory) * { * var changes = new Dictionary<IDrumKit, IDrumKit> * { * * * * //xxx * * * * * * {(IDrumKit) (drumKit.OriginalLocation), * (IDrumKit) (drumKit.PasteDestination)} * }; * * ((IProgram) (program.PasteDestination)).ReplaceDrumKit(changes); * } * program.ReferencedDrumKits.CopiedPatches[drumKitIndex] = null; // Prevent fixing it again * } * } * } * } * } */ /// <summary> /// /// </summary> private void FixPastePatchInSetListSlotsReferences() { foreach (IClipBoardPatch clipBoardPatch in SetListSlots.CopiedPatches) { IClipBoardSetListSlot clipBoardSetListSlot = (IClipBoardSetListSlot)clipBoardPatch; ISetListSlot setListSlot = (ISetListSlot)(clipBoardSetListSlot.PasteDestination); if ((setListSlot != null) && (clipBoardSetListSlot.Reference != null)) { // Fix reference to program/combi. IClipBoardPatch clipBoardReference = clipBoardSetListSlot.Reference; // When pasting to the same file (second condition below), then it is not wanted to fix references, // because a duplicate program/combi can exist before the original reference so it will be changed // unnecessarily. if ((clipBoardReference.PasteDestination != null) && (clipBoardSetListSlot.Reference.OriginalLocation.Root != PastePcgMemory)) { if (clipBoardReference.PasteDestination is IProgram) { IProgram program = (IProgram)(clipBoardReference.PasteDestination); setListSlot.UsedPatch = program; } else if (clipBoardReference.PasteDestination is ICombi) { ICombi combi = (ICombi)(clipBoardReference.PasteDestination); setListSlot.UsedPatch = combi; } else { throw new ApplicationException("Illegal clip board reference"); } setListSlot.RaisePropertyChanged(string.Empty, false); } } } }
/// <summary> /// /// </summary> /// <param name="combi"></param> /// <param name="timbresOffsetConstant"></param> protected MntxTimbres(ICombi combi, int timbresOffsetConstant) : base(combi, TimbresPerCombiConstant, timbresOffsetConstant) { }
/// <summary> /// /// </summary> /// <param name="patch"></param> public WindowEditSingleCombi(ICombi patch) { InitializeComponent(); _patch = patch; }
/// <summary> /// IMPR: Reduce complexity by creating a 'result' structure and split method in several parts. /// </summary> /// <param name="writer"></param> /// <param name="combi"></param> /// <param name="index"></param> private void PrintTimbre(TextWriter writer, ICombi combi, int index) { var timbre = combi.Timbres.TimbresCollection[index]; var status = timbre.GetParam(ParameterNames.TimbreParameterName.Status).Value; var muteParam = timbre.GetParam(ParameterNames.TimbreParameterName.Mute); var mute = muteParam != null && (bool)muteParam.Value; var muteString = mute.ToYesNo(); if (!ShowTimbre(timbre)) { return; } var usedProgram = timbre.UsedProgram; var timbreId = (usedProgram == null) ? "???" : timbre.ColumnProgramId; var isGmProgram = (usedProgram != null) && ((ProgramBank)(timbre.UsedProgram.Parent)).Type == BankType.EType.Gm; var byteOffset = (usedProgram == null) ? 0 : timbre.UsedProgram.ByteOffset; var name = isGmProgram ? "-" : (byteOffset == 0) ? "???" : timbre.ColumnProgramName; var category = isGmProgram ? "-" : (byteOffset == 0) ? "???" : timbre.UsedProgram.CategoryAsName; var subCategory = isGmProgram ? "-" : ((byteOffset == 0) ? "???" : timbre.UsedProgram.SubCategoryAsName); var volume = (string)(timbre.GetParam(ParameterNames.TimbreParameterName.Volume).Value.ToString()); var priority = timbre.GetParam(ParameterNames.TimbreParameterName.Priority); var priorityString = (isGmProgram || (priority == null)) ? "No" : ((byteOffset == 0) ? "???" : ((bool)priority.Value).ToYesNo()); var midiChannelString = ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.MidiChannel, (int)timbre.GetParam(ParameterNames.TimbreParameterName.MidiChannel).Value); var bottomKey = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.BottomKey, timbre.GetParam(ParameterNames.TimbreParameterName.BottomKey).Value); var topKey = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.TopKey, timbre.GetParam(ParameterNames.TimbreParameterName.TopKey).Value); var bottomVelocity = (string)timbre.GetParam(ParameterNames.TimbreParameterName.BottomVelocity).Value.ToString(); var topVelocity = (string)timbre.GetParam(ParameterNames.TimbreParameterName.TopVelocity).Value.ToString(); var paramOscMode = timbre.GetParam(ParameterNames.TimbreParameterName.OscMode); var oscMode = (paramOscMode == null) ? "-" : (string)paramOscMode.Value; var paramOscSelect = timbre.GetParam(ParameterNames.TimbreParameterName.OscSelect); var oscSelect = (paramOscSelect == null) ? "-" : (string)paramOscSelect.Value; var transpose = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.Transpose, timbre.GetParam(ParameterNames.TimbreParameterName.Transpose).Value); var paramDetune = timbre.GetParam(ParameterNames.TimbreParameterName.Detune); var detune = (paramDetune == null) ? "-" : (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.Detune, paramDetune.Value); var paramPortamento = timbre.GetParam(ParameterNames.TimbreParameterName.Portamento); var portamento = (paramPortamento == null) ? "-" : (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.Portamento, paramPortamento.Value); var bendRange = (string)ParameterValues.GetStringValue(ParameterNames.TimbreParameterName.BendRange, timbre.GetParam(ParameterNames.TimbreParameterName.BendRange).Value); writer.Write( $"|{index + 1,2} |{timbreId,-10}|{name,-24}|{category,-24}|{subCategory,-24}|{volume,3}|{status,-3}|{muteString,-4}|{priorityString,-4}|{midiChannelString,-4}|"); // ReSharper disable RedundantStringFormatCall writer.WriteLine( $"{bottomKey,-4}~{topKey,-4}|{bottomVelocity,3}~{topVelocity,3}|{oscMode,-4}|{oscSelect,-4}|{transpose,3}|{detune,5}|{portamento,3}|{bendRange,-3} |"); }
/// <summary> /// /// </summary> /// <param name="patch"></param> public WindowEditMultipleCombis(ICombi patch) { InitializeComponent(); _patch = patch; }