private void ApplyControllerMapping(string filePath) { using (var fileStream = new FileStream(filePath, FileMode.Open)) { NKSFRiff n = new NKSFRiff(); n.Read(fileStream); DefaultControllerAssignments = n.kontaktSound.controllerAssignments.controllerAssignments; } GenerateControllerMappingModels(); }
public void ExportNKSPreset(PresetExportInfo preset, byte[] data) { var nksf = new NKSFRiff(); nksf.kontaktSound.summaryInformation.summaryInformation.vendor = preset.PluginVendor; nksf.kontaktSound.summaryInformation.summaryInformation.uuid = preset.PresetGuid; nksf.kontaktSound.summaryInformation.summaryInformation.name = preset.PresetName; if (preset.PluginType == Plugin.PluginTypes.Instrument) { nksf.kontaktSound.summaryInformation.summaryInformation.deviceType = "INST"; } else if (preset.PluginType == Plugin.PluginTypes.Effect) { nksf.kontaktSound.summaryInformation.summaryInformation.deviceType = "FX"; } else { throw new ArgumentException("Unknown device type"); } nksf.kontaktSound.summaryInformation.summaryInformation.bankChain.Add(preset.PluginName); nksf.kontaktSound.summaryInformation.summaryInformation.bankChain.AddRange(preset.BankPath); nksf.kontaktSound.summaryInformation.summaryInformation.Types = preset.Types; nksf.kontaktSound.summaryInformation.summaryInformation.Modes = preset.Modes; nksf.kontaktSound.summaryInformation.summaryInformation.author = preset.Author; nksf.kontaktSound.summaryInformation.summaryInformation.comment = preset.Comment + Environment.NewLine + "Generated with PresetMagician"; nksf.kontaktSound.pluginId.pluginId.VSTMagic = (uint)preset.PluginId; nksf.kontaktSound.pluginChunk.PresetData = data; if (preset.DefaultControllerAssignments != null) { nksf.kontaktSound.controllerAssignments.controllerAssignments = preset.DefaultControllerAssignments; } var outputFilename = preset.GetFullOutputPath(); Directory.CreateDirectory(Path.GetDirectoryName(outputFilename)); var fileStream2 = new FileStream(outputFilename, FileMode.Create); nksf.Write(fileStream2); fileStream2.Close(); }
private void OnParseNKSFFileExecute() { Log.Debug("Trying to parse NKSF"); using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { NKSFRiff n = new NKSFRiff(); n.Read(fileStream); SummaryInformation = FormatJson(n.kontaktSound.summaryInformation.getJSON()); PluginId = FormatJson(n.kontaktSound.pluginId.getJSON()); ControllerAssignments = FormatJson(n.kontaktSound.controllerAssignments.getJSON()); var ms = new MemoryStream(); ms.Write(n.kontaktSound.pluginChunk.Chunk, 0, n.kontaktSound.pluginChunk.Chunk.Length); PluginChunk = ms; PluginChunkHash = HashUtils.getIxxHash(n.kontaktSound.pluginChunk.Chunk); } Log.Debug("Parse Complete"); }
public void ComputeOutputFilename() { if (_outputFilename != null) { return; } string fileExtension; if (PluginType == Plugin.PluginTypes.Instrument) { fileExtension = ".nksf"; } else if (PluginType == Plugin.PluginTypes.Effect) { fileExtension = ".nksfx"; } else { throw new ArgumentException("Unknown device type"); } var fileName = GetNKSFPresetName(PresetName) + fileExtension; var filePath = Path.Combine(GetUserContentDirectory(), fileName); if (File.Exists(filePath)) { Guid existingGuid; switch (OverwriteMode) { case FileOverwriteMode.FORCE_OVERWRITE: break; case FileOverwriteMode.APPEND_GUID: existingGuid = NKSFRiff.GetPresetGuid(filePath); if (existingGuid != PresetGuid) { fileName = GetNKSFPresetName(PresetName, true) + fileExtension; } break; case FileOverwriteMode.REPORT_ERROR: existingGuid = NKSFRiff.GetPresetGuid(filePath); if (existingGuid != PresetGuid) { _canExport = false; CannotExportReason = $"File {filePath} already exists and has a different preset ID"; } break; } } _outputFilename = fileName; }