예제 #1
0
        internal void Save(TsiXmlDocument xml)
        {
            var defBtn = new DefaultButtonFx(_effect)
            {
                Value = new List <int>
                {
                    Buttons.ButtonGroupMode,
                    Buttons.Button3,
                    Buttons.Button2,
                    Buttons.Button1,
                    Buttons.OnOff,
                }
            };

            xml.SaveEntry(defBtn);

            var defParam = new DefaultParamFx(_effect)
            {
                Value = new List <float>
                {
                    Knobs.KnobGroupMode,
                    Knobs.Knob3,
                    Knobs.Knob2,
                    Knobs.Knob1,
                    Knobs.DryWet,
                }
            };

            xml.SaveEntry(defParam);
        }
예제 #2
0
파일: TsiFile.cs 프로젝트: whiteschool/cmdr
        public bool Save(string filePath)
        {
            // workaround to save indices instead of ids
            var effectSelectorInCommands  = getCriticalEffectSelectorInCommands();
            var effectSelectorOutCommands = getCriticalEffectSelectorOutCommands();

            bool prepared = false;

            if (!_ignoreFx && (effectSelectorInCommands.Any() || effectSelectorOutCommands.Any()))
            {
                if (FxSettings == null)
                {
                    FxSettings = (TraktorSettings.Initialized) ? TraktorSettings.Instance.FxSettings : createDefaultFxSettings();
                }

                prepareFxForSave(effectSelectorInCommands, effectSelectorOutCommands);
                prepared = true;
            }

            // build controller config (binary)
            DeviceIoConfigController controllerConfig = null;

            try
            {
                string tsiData = getDataAsBase64String();
                controllerConfig       = new DeviceIoConfigController();
                controllerConfig.Value = tsiData;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error building controller config. Reason: " + ex.Message);
                return(false);
            }

            if (prepared)
            {
                restoreEffectSelectorCommands(effectSelectorInCommands, effectSelectorOutCommands);
            }

            // build xml document
            try
            {
                TsiXmlDocument xml = (Path != null) ? new TsiXmlDocument(Path) : new TsiXmlDocument();
                if (FxSettings != null && (effectSelectorInCommands.Any() || effectSelectorOutCommands.Any()))
                {
                    FxSettings.Save(xml);
                }
                xml.SaveEntry(controllerConfig);
                xml.Save(filePath);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error building xml document. Reason: " + ex.Message);
                return(false);
            }

            Path = filePath;
            return(true);
        }
예제 #3
0
        internal void Save(TsiXmlDocument xml)
        {
            var fxSelection = new AudioFxSelection {
                Value = _effects
            };

            xml.SaveEntry(fxSelection);

            foreach (var effDef in _snapshots.Values)
            {
                effDef.Save(xml);
            }
        }
예제 #4
0
파일: TsiFile.cs 프로젝트: pestrela/cmdr
        public bool Save(string filePath, bool optimizeFXList, bool backup = false)
        {
            // workaround to save indices (position on a list) instead of ids (actual command)
            var effectSelectorInCommands  = getCriticalEffectSelectorInCommands();
            var effectSelectorOutCommands = getCriticalEffectSelectorOutCommands();

            OptimizeFXList = optimizeFXList;

            bool prepared = false;

            if (!_ignoreFx && (effectSelectorInCommands.Any() || effectSelectorOutCommands.Any()))
            {
                if (FxSettings == null)
                {
                    FxSettings = (TraktorSettings.Initialized) ? TraktorSettings.Instance.FxSettings : createDefaultFxSettings();
                }

                prepareFxForSave(effectSelectorInCommands, effectSelectorOutCommands);
                prepared = true;
            }

            // build controller config (binary)
            DeviceIoConfigController controllerConfigController = null;
            DeviceIoConfigKeyboard   controllerConfigKeyboard   = null;

            var all_devices      = _devices.Select(d => d).ToList();
            var only_keyboard    = _devices.Where(d => (d.IsKeyboard == true)).ToList();
            var only_controllers = _devices.Where(d => (d.IsKeyboard == false)).ToList();

            try {
                if (only_controllers.Any())
                {
                    string tsiDataController = getDataAsBase64String(false);
                    controllerConfigController       = new DeviceIoConfigController();
                    controllerConfigController.Value = tsiDataController;
                }

                if (only_keyboard.Any())
                {
                    string tsiDataKeyboard = getDataAsBase64String(true);
                    controllerConfigKeyboard       = new DeviceIoConfigKeyboard();
                    controllerConfigKeyboard.Value = tsiDataKeyboard;
                }
            }
            catch (Exception ex)
            {
                // FIXME: show this to the user somehow
                //   at least a show console option

                // Exception thrown: 'System.OutOfMemoryException' in mscorlib.dll
                // Error building controller config. Reason: Exception of type 'System.OutOfMemoryException' was thrown.

                Debug.WriteLine("Error building controller config. Reason: " + ex.Message);
                return(false);
            }

            if (prepared)
            {
                restoreEffectSelectorCommands(effectSelectorInCommands, effectSelectorOutCommands);
            }

            // build xml document
            try
            {
                TsiXmlDocument xml = (Path != null) ? new TsiXmlDocument(Path) : new TsiXmlDocument();
                if (FxSettings != null && (effectSelectorInCommands.Any() || effectSelectorOutCommands.Any()))
                {
                    FxSettings.Save(xml);
                }

                if (only_controllers.Any())
                {
                    xml.SaveEntry(controllerConfigController);
                }
                if (only_keyboard.Any())
                {
                    xml.SaveEntry(controllerConfigKeyboard);
                }

                xml.Save(filePath);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error building xml document. Reason: " + ex.Message);
                return(false);
            }

            if (!backup)
            {
                Path = filePath;
            }
            return(true);
        }