Пример #1
0
        private void load(TsiXmlDocument xml, bool RemoveUnusedMIDIDefinitions)
        {
            // Traktor version, optional (only for "Traktor Settings.tsi")
            var browserDirRoot = xml.GetEntry <BrowserDirRoot>();

            if (browserDirRoot != null)
            {
                Match m = REGEX_TRAKTOR_FOLDER.Match(browserDirRoot.Value);
                if (m.Success) // Overwrite version if possible
                {
                    TraktorVersion = m.Groups[1].Value;
                }
            }

            // Effects, optional (FxSettings.Load may return null)
            // can this move below ?
            FxSettings = FxSettings.Load(xml);

            // Devices
            StringXmlEntry controllerConfigController = xml.GetEntry <DeviceIoConfigController>();

            if (controllerConfigController != null)
            {
                byte[] decoded = Convert.FromBase64String(controllerConfigController.Value);
                _devicesContainerControllers = new DeviceMappingsContainer(new MemoryStream(decoded));
                var _devices_tmp = _devicesContainerControllers.Devices.List.Select(d => new Device(max_id++, d, RemoveUnusedMIDIDefinitions, false)).ToList();

                // append to whole list
                _devices.AddRange(_devices_tmp);
            }

            StringXmlEntry controllerConfigKeyboard = xml.GetEntry <DeviceIoConfigKeyboard>();

            if (controllerConfigKeyboard != null)
            {
                byte[] decoded = Convert.FromBase64String(controllerConfigKeyboard.Value);
                _devicesContainerKeyboard = new DeviceMappingsContainer(new MemoryStream(decoded));
                var _devices_tmp = _devicesContainerKeyboard.Devices.List.Select(d => new Device(max_id++, d, RemoveUnusedMIDIDefinitions, true)).ToList();

                // append to whole list
                _devices.AddRange(_devices_tmp);
            }

            load_FX();
        }
Пример #2
0
        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);
        }
Пример #3
0
        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));
        }
Пример #4
0
        private void load(TsiXmlDocument xml)
        {
            // Traktor version, optional (only for "Traktor Settings.tsi")
            var browserDirRoot = xml.GetEntry <BrowserDirRoot>();

            if (browserDirRoot != null)
            {
                Match m = REGEX_TRAKTOR_FOLDER.Match(browserDirRoot.Value);
                if (m.Success) // Overwrite version if possible
                {
                    TraktorVersion = m.Groups[1].Value;
                }
            }

            // effects, optional (FxSettings.Load may return null)
            FxSettings = FxSettings.Load(xml);

            // devices
            var controllerConfig = xml.GetEntry <DeviceIoConfigController>();

            if (controllerConfig != null)
            {
                byte[] decoded = Convert.FromBase64String(controllerConfig.Value);
                _devicesContainer = new DeviceMappingsContainer(new MemoryStream(decoded));
                int id = 0;
                _devices = _devicesContainer.Devices.List.Select(d => new Device(id++, d)).ToList();

                var effectSelectorInCommands  = getCriticalEffectSelectorInCommands();
                var effectSelectorOutCommands = getCriticalEffectSelectorOutCommands();
                if (effectSelectorInCommands.Any() || effectSelectorOutCommands.Any())
                {
                    // need FxSettings for interpretation but not provided by file itself?
                    if (FxSettings == null)
                    {
                        // call for help
                        string rId     = new FileInfo(Path).Name;
                        var    request = new EffectIdentificationRequest(rId);
                        var    handler = EffectIdentificationRequest;
                        if (handler != null)
                        {
                            handler(this, request);

                            // wait for help
                            while (!request.Handled)
                            {
                                Thread.Sleep(100);
                            }

                            if (request.FxSettings != null)
                            {
                                FxSettings = request.FxSettings;
                            }
                        }
                    }

                    // if possible, replace effect indices with ids
                    if (FxSettings != null)
                    {
                        restoreEffectSelectorCommands(effectSelectorInCommands, effectSelectorOutCommands);
                    }
                    else
                    {
                        _ignoreFx = true;
                    }
                }
            }
        }