protected async Task GetPresetsUsingFullBank(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(index); var preset = new PresetParserMetadata { PresetName = PluginInstance.GetCurrentProgramName(), BankPath = bank.BankPath, SourceFile = sourceFile + ":" + index, Plugin = PluginInstance.Plugin }; await DataPersistence.PersistPreset(preset, PluginInstance.GetChunk(false)); } }
/** * Checks if the chunks are null */ public bool AreChunksNull(bool isPreset) { Logger.Debug(isPreset ? $"{PluginInstance.Plugin.PluginName}: checking if bank chunks are null" : $"{PluginInstance.Plugin.PluginName}: checking if program chunks are null"); PluginInstance.SetProgram(0); var chunk = PluginInstance.GetChunk(isPreset); return(chunk == null); }
/** * Checks if the current program number is stored in the bank chunk. Some VSTs do it (like V-Station), * others don't (which should be the norm). * * Interpret the return value "true" as "uncertain" */ public bool IsCurrentProgramStoredInBankChunk() { PluginInstance.SetProgram(0); var firstHash = HashUtils.getIxxHash(PluginInstance.GetChunk(false)); PluginInstance.SetProgram(1); var secondHash = HashUtils.getIxxHash(PluginInstance.GetChunk(false)); if (firstHash != secondHash) { return(true); } return(false); }
/** * Checks if the full bank presets are consistent. The full bank chunk should not change for the same program. * * We check it 10 times to see if the hashes are consistent. If they're not, the plugin most likely stores some * runtime data (like LFO state). * */ public bool AreChunksConsistent(bool isPreset) { Logger.Debug(isPreset ? $"{PluginInstance.Plugin.PluginName}: checking if bank chunks are consistent" : $"{PluginInstance.Plugin.PluginName}: checking if program chunks are consistent"); PluginInstance.SetProgram(0); var chunk = PluginInstance.GetChunk(isPreset); if (chunk == null) { return(false); } var firstPresetHash = HashUtils.getIxxHash(chunk); Logger.Debug(PluginInstance.Plugin.PluginName + ": hash for program 0 is " + firstPresetHash); for (var i = 0; i < 10; i++) { PluginInstance.SetProgram(0); chunk = PluginInstance.GetChunk(isPreset); if (chunk == null) { return(false); } if (firstPresetHash != HashUtils.getIxxHash(chunk)) { return(false); } } return(true); }
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); } } }