private void prepareFxSettings(IEnumerable <EffectSelectorInCommand> effectSelectorInCommands, IEnumerable <EffectSelectorOutCommand> effectSelectorOutCommands) { List <Effect> usedFxIn = effectSelectorInCommands.Select(e => e.Value).Distinct().ToList(); List <Effect> usedFxOut = effectSelectorOutCommands.Select(e => e.ControllerRangeMin).Distinct().ToList(); List <Effect> usedFx = usedFxIn.Union(usedFxOut).Distinct().Except(new[] { Effect.NoEffect }).OrderBy(e => e).ToList(); // Keep effects from Traktor settings as they are. Append new effects if necessary. if (IsTraktorSettings) { usedFx = FxSettings.Effects.Union(usedFx).Distinct().ToList(); } Dictionary <Effect, FxSnapshot> usedSnapshots = new Dictionary <Effect, FxSnapshot>(); foreach (var fx in usedFx) { FxSnapshot snapshot = null; if (FxSettings.Snapshots.ContainsKey(fx)) { snapshot = FxSettings.Snapshots[fx]; } else { if (TraktorSettings.Initialized && TraktorSettings.Instance.FxSettings.Snapshots.ContainsKey(fx)) { snapshot = TraktorSettings.Instance.FxSettings.Snapshots[fx]; } else { snapshot = new FxSnapshot(fx); } } usedSnapshots.Add(fx, snapshot); } // Keep snapshots from Traktor settings as they are. Add new snapshots if necessary. if (IsTraktorSettings) { usedSnapshots = FxSettings.Snapshots.Union(usedSnapshots).Distinct().ToDictionary(s => s.Key, s => s.Value); } bool optimizeFXList = OptimizeFXList; // how to use CmdrSettings.Instance.OptimizeFXList ?; if (optimizeFXList) { FxSettings = new FxSettings(usedFx, usedSnapshots); } }
internal static FxSnapshot Load(Effect effect, TsiXmlDocument xml) { var fxDefault = new FxSnapshot(effect); DefaultButtonFx defBtn = xml.GetEntry(new DefaultButtonFx(effect)); if (defBtn != null) { fxDefault._buttons = new FxButtonsSnapshot { ButtonGroupMode = defBtn.Value[0], Button3 = defBtn.Value[1], Button2 = defBtn.Value[2], Button1 = defBtn.Value[3], OnOff = defBtn.Value[4] }; } DefaultParamFx defParam = xml.GetEntry(new DefaultParamFx(effect)); if (defParam != null) { fxDefault._knobs = new FxKnobsSnapshot { KnobGroupMode = defParam.Value[0], Knob3 = defParam.Value[1], Knob2 = defParam.Value[2], Knob1 = defParam.Value[3], DryWet = defParam.Value[4] }; } // reason for logical OR: usually, there is both entries, but preservation goes over completeness // TODO: try if Traktor accepts "half" snapshots if (defBtn != null || defParam != null) { return(fxDefault); } return(null); }
internal static FxSettings Load(TsiXmlDocument xml) { var fxSelection = xml.GetEntry <AudioFxSelection>(); if (fxSelection == null) { return(null); } Dictionary <Effect, FxSnapshot> defaults = new Dictionary <Effect, FxSnapshot>(); var allEffects = Enum.GetValues(typeof(Effect)).Cast <Effect>().Except(new[] { Effect.NoEffect }).ToList(); foreach (var effect in allEffects) { var effDef = FxSnapshot.Load(effect, xml); if (effDef != null) { defaults.Add(effect, effDef); } } return(new FxSettings(fxSelection.Value, defaults)); }
public void SetSnapshot(FxSnapshot snapshot) { _snapshots[snapshot.Effect] = snapshot; }