private async Task OnLoadBankChunkExecute() { try { _openFileService.Filter = "Binary Files (*.*)|*.*"; _openFileService.IsMultiSelect = false; if (await _openFileService.DetermineFileAsync()) { PluginInstance.SetChunk(File.ReadAllBytes(_openFileService.FileName), false); } } catch (Exception ex) { Log.Error(ex, "Failed to open file"); } }
public VstUtils.LoadFxpResult LoadFxp(string filePath) { var result = VstUtils.LoadFxp(filePath, PluginInstance.Plugin.PluginInfo.ToNonSurrogate()); if (result.result == VstUtils.LoadFxpResult.Error) { Logger.Error($"Error loading FXB/FXP {filePath}: {result.message}"); return(result.result); } // If your plug-in is configured to use chunks // the Host will ask for a block of memory describing the current // plug-in state for saving. // To restore the state at a later stage, the same data is passed // back to setChunk. var chunkData = result.fxp.ChunkDataByteArray; PluginInstance.SetProgram(0); PluginInstance.SetChunk(chunkData, result.result == VstUtils.LoadFxpResult.Program); return(result.result); }
protected async Task GetPresetsUsingBankTrickery(PresetBank bank, int start, int numPresets, string sourceFile) { if (start < 0) { Logger.Error("GetPresets start index is less than 0, ignoring. This is probably a bug or a " + "misconfiguration. Please report this including the full log file."); return; } var endIndex = start + numPresets; if (endIndex > PluginInstance.Plugin.PluginInfo.ProgramCount) { Logger.Error( $"Tried to retrieve presets between the index {start} and {endIndex}, but this would exceed maximum " + $"program count of {PluginInstance.Plugin.PluginInfo.ProgramCount}, ignoring. You might wish to " + "report this as a bug."); return; } for (var index = start; index < endIndex; index++) { PluginInstance.SetProgram(0); PluginInstance.PerformIdleLoop(10); var programBackup = PluginInstance.GetChunk(true); PluginInstance.SetProgram(index); PluginInstance.PerformIdleLoop(10); var programName = PluginInstance.GetCurrentProgramName(); var fullSourceFile = sourceFile + ":" + index; var vstPreset = new PresetParserMetadata { SourceFile = fullSourceFile, BankPath = bank.BankPath, PresetName = programName, Plugin = PluginInstance.Plugin }; var realProgram = PluginInstance.GetChunk(true); PluginInstance.SetProgram(0); PluginInstance.PerformIdleLoop(10); PluginInstance.SetChunk(realProgram, true); PluginInstance.PerformIdleLoop(10); var presetData = PluginInstance.GetChunk(false); // Restore original program 0 PluginInstance.SetChunk(programBackup, true); PluginInstance.PerformIdleLoop(10); var hash = HashUtils.getIxxHash(presetData); if (PresetHashes.ContainsKey(hash)) { Logger.Warning( $"Skipping program {index} with name {programName} because a program with the same data " + $"was already added ({PresetHashes[hash]}. Please report this if you think if it's a bug."); } else { PresetHashes.Add(hash, fullSourceFile + " " + programName); await DataPersistence.PersistPreset(vstPreset, presetData); } } }