Пример #1
0
        private string GetSectionSuggestedFileName(string description, SectionType recordSectionType)
        {
            switch (recordSectionType)
            {
            case SectionType.BackupDescription:
                return($"{FileNamingService.CoerceValidFileName(description)}.txt");

            case SectionType.GlobalSettings:
                return($"{FileNamingService.CoerceValidFileName(description)}.json");

            case SectionType.HelixDi:
                return($"{FileNamingService.CoerceValidFileName(description)}.dat");

            case SectionType.ImpulseResponse:
                return($"{FileNamingService.CoerceValidFileName(description)}.wav");

            case SectionType.SetListNames:
                return($"{FileNamingService.CoerceValidFileName(description)}.dat");

            case SectionType.SetList:
                return($"{FileNamingService.CoerceValidFileName(description)}.json");

            default:
                return("unknown.dat");
            }
        }
Пример #2
0
        private void ParseSetList(byte[] setListJson)
        {
            if (!ParsePresets)
            {
                return;
            }

            var     enc  = new UTF8Encoding();
            dynamic json = JsonConvert.DeserializeObject(enc.GetString(setListJson));

            if (json != null)
            {
                var setListName = json.data.meta.name;

                var presets = json.data.presets;

                foreach (var preset in presets)
                {
                    var encodedData = preset.encoded_data;
                    var isEncoded   = encodedData != null;

                    string presetName;

                    if (!isEncoded)
                    {
                        if (preset.meta == null)
                        {
                            // An empty preset.
                            continue;
                        }

                        presetName = preset.meta.name;

                        if (string.IsNullOrEmpty(presetName))
                        {
                            // Unusual! It may represent corrupt preset data
                            // or simply extraneous data that should be ignored...
                            continue;
                        }
                    }
                    else
                    {
                        // when encrypted (a premium preset), we can't decrypt to get the
                        // preset name so fabricate a name...
                        presetName = FabricatePresetName();
                    }

                    OnParsedPresetEvent(new PresetDataEventArgs
                    {
                        ParentSetListName = setListName,
                        PresetName        = presetName,
                        SuggestedFileName = $"{FileNamingService.CoerceValidFileName(presetName)}.hlx",
                        PresetData        = preset.ToString(),
                    });
                }
            }
        }