コード例 #1
0
        public override async Task DoScan()
        {
            foreach (var bankFile in GetBankFiles())
            {
                Logger.Debug($"Parsing {bankFile}");

                try
                {
                    var cfg = new SpireJsonConfig {
                        SelectedBank = bankFile
                    };

                    var bf = new SpireBank();
                    bf.ParseDiskFile(File.ReadAllBytes(bankFile));

                    foreach (var p in bf.Presets)
                    {
                        var bankPath = Path.GetFileNameWithoutExtension(bankFile);

                        var preset = new PresetParserMetadata
                        {
                            PresetName = p.ProgramName.Trim(), Plugin = PluginInstance.Plugin,
                            BankPath   = bankPath,
                            SourceFile = bankFile + ":" + bf.Presets.IndexOf(p)
                        };



                        await DataPersistence.PersistPreset(preset, bf.GenerateMemoryBank(p, cfg));
                    }
                }
                catch (SpireException e)
                {
                    Logger.Error($"Error parsing {bankFile}");
                    Logger.LogException(e);
                }
            }

            await base.DoScan();
        }
コード例 #2
0
        public override int GetNumPresets()
        {
            var numPresets = 0;

            foreach (var bankFile in GetBankFiles())
            {
                Logger.Debug($"Parsing {bankFile}");

                try
                {
                    var bf = new SpireBank();
                    bf.ParseDiskFile(File.ReadAllBytes(bankFile));
                    numPresets += bf.Presets.Count;
                }
                catch (SpireException e)
                {
                    Logger.Error($"Error parsing {bankFile}");
                    Logger.LogException(e);
                }
            }

            return(base.GetNumPresets() + numPresets);
        }