public void DeterminatePresetParser(IRemotePluginInstance pluginInstance) { if (pluginInstance.Plugin.PresetParser != null) { return; } if (!pluginInstance.Plugin.PluginLocation.HasMetadata) { throw new NoMetadataAvailableException(pluginInstance); } pluginInstance.Plugin.PluginLocation.PresetParser = GetPresetParser(pluginInstance); pluginInstance.Plugin.PluginLocation.PresetParser.PresetParserConfiguration.LastScanVersion = _globalService.PresetMagicianVersion; if (pluginInstance.Plugin.PresetParser == null) { pluginInstance.Plugin.IsSupported = false; } else { pluginInstance.Plugin.IsSupported = !pluginInstance.Plugin.PresetParser.IsNullParser; } }
private async Task OnLoadPluginCommandExecute() { _remotePluginInstance = _remoteVstService.GetInteractivePluginInstance(Plugin); if (!_remotePluginInstance.IsLoaded) { await _remotePluginInstance.LoadPlugin(); } _remotePluginInstance.PatchPluginToAudioOutput(_globalService.RuntimeConfiguration.AudioOutputDevice, _globalService.RuntimeConfiguration.AudioLatency); foreach (var dev in _globalService.RuntimeConfiguration.MidiInputDevices) { try { _remotePluginInstance.PatchPluginToMidiInput(dev); } catch (Exception e) { LogTo.Error(e.Message); } } ShowEditorCommand.RaiseCanExecuteChanged(); LoadPresetCommand.RaiseCanExecuteChanged(); }
public void AutoGenerateResources(IRemotePluginInstance pluginInstance) { var generate = false; var imagesToSave = new List <ResourceImage>(); foreach (var img in pluginInstance.Plugin.NativeInstrumentsResource.ResourceImages) { if (img.State.State != NativeInstrumentsResource.ResourceStates.Empty) { continue; } generate = true; imagesToSave.Add(img); } var previousCategoriesState = pluginInstance.Plugin.NativeInstrumentsResource.CategoriesState.State; var previousColorState = pluginInstance.Plugin.NativeInstrumentsResource.ColorState.State; var previousShortNameState = pluginInstance.Plugin.NativeInstrumentsResource.ShortNamesState.State; if (pluginInstance.Plugin.NativeInstrumentsResource.CategoriesState.State == NativeInstrumentsResource.ResourceStates.Empty || pluginInstance.Plugin.NativeInstrumentsResource.ShortNamesState.State == NativeInstrumentsResource.ResourceStates.Empty || pluginInstance.Plugin.NativeInstrumentsResource.ColorState.State == NativeInstrumentsResource.ResourceStates.Empty || generate) { GenerateResources(pluginInstance); if (previousCategoriesState == NativeInstrumentsResource.ResourceStates.Empty) { pluginInstance.Plugin.NativeInstrumentsResource.CategoriesState.ShouldSave = true; } if (previousColorState == NativeInstrumentsResource.ResourceStates.Empty) { pluginInstance.Plugin.NativeInstrumentsResource.ColorState.ShouldSave = true; } if (previousShortNameState == NativeInstrumentsResource.ResourceStates.Empty) { pluginInstance.Plugin.NativeInstrumentsResource.ShortNamesState.ShouldSave = true; } foreach (var img in imagesToSave) { if (img.State.State == NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated) { img.State.ShouldSave = true; } } pluginInstance.Plugin.NativeInstrumentsResource.Save(pluginInstance.Plugin); } }
public VstPluginChunkViewModel(IRemotePluginInstance pluginInstance, IOpenFileService openFileService, ISaveFileService saveFileService, DeveloperService developerService) { _openFileService = openFileService; _saveFileService = saveFileService; _developerService = developerService; Plugin = pluginInstance.Plugin; PluginInstance = pluginInstance; Title = "Plugin Info for " + Plugin.PluginName; OpenBankWithHexEditor = new TaskCommand(OnOpenBankWithHexEditorExecute); OpenPresetWithHexEditor = new TaskCommand(OnOpenPresetWithHexEditorExecute); SaveBankChunk = new TaskCommand(OnSaveBankChunkExecute); LoadBankChunk = new TaskCommand(OnLoadBankChunkExecute); Refresh = new Command(OnRefreshExecute); }
public bool ShouldCreateScreenshot(IRemotePluginInstance pluginInstance) { var shouldCreateScreenshot = false; var niResource = pluginInstance.Plugin.NativeInstrumentsResource; if (niResource.ColorState.State == NativeInstrumentsResource.ResourceStates.Empty) { shouldCreateScreenshot = true; } foreach (var img in niResource.ResourceImages) { if (img.State.State == NativeInstrumentsResource.ResourceStates.Empty) { shouldCreateScreenshot = true; } } return(shouldCreateScreenshot); }
public bool NeedToGenerateResources(IRemotePluginInstance pluginInstance) { foreach (var img in pluginInstance.Plugin.NativeInstrumentsResource.ResourceImages) { if (img.State.State == NativeInstrumentsResource.ResourceStates.Empty) { return(true); } } if (pluginInstance.Plugin.NativeInstrumentsResource.CategoriesState.State == NativeInstrumentsResource.ResourceStates.Empty || pluginInstance.Plugin.NativeInstrumentsResource.ShortNamesState.State == NativeInstrumentsResource.ResourceStates.Empty || pluginInstance.Plugin.NativeInstrumentsResource.ColorState.State == NativeInstrumentsResource.ResourceStates.Empty) { return(true); } return(false); }
public void GenerateResources(IRemotePluginInstance pluginInstance, bool force = false) { Image bmp; var niResource = pluginInstance.Plugin.NativeInstrumentsResource; var pluginName = pluginInstance.Plugin.GetEffectivePluginName(); if (niResource.ShortNamesState.State == NativeInstrumentsResource.ResourceStates.Empty || force) { niResource.ShortNames.VB_shortname = pluginName; niResource.ShortNames.MKII_shortname = pluginName; niResource.ShortNames.MIKRO_shortname = pluginName; niResource.ShortNames.MST_shortname = pluginName; niResource.ShortNamesState.State = NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated; } if (niResource.CategoriesState.State == NativeInstrumentsResource.ResourceStates.Empty || force) { niResource.Categories.CategoryNames.Clear(); var categoryDb = new CategoryDB { FileType = pluginInstance.Plugin.PluginType == Plugin.PluginTypes.Instrument ? "INST" : "FX" }; niResource.Categories.CategoryDB.Add(categoryDb); niResource.Categories.Vendor = pluginInstance.Plugin.PluginVendor; niResource.Categories.Product = pluginName; niResource.CategoriesState.State = NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated; } var pluginVendor = pluginInstance.Plugin.PluginVendor; niResource.MST_logo.ReplaceFromStream( RenderBigLogo(pluginName, pluginVendor, niResource.MST_logo.TargetSize, 35, 12), NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated); niResource.VB_logo.ReplaceFromStream( RenderLogo(pluginName, niResource.VB_logo.TargetSize, 30, new Point(7, 2)), NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated); niResource.OSO_logo.ReplaceFromStream( RenderLogo(pluginName, niResource.OSO_logo.TargetSize, 43, new Point(7, 2)), NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated); niResource.Color.SetRandomColor(); niResource.ColorState.State = NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated; if (!ShouldCreateScreenshot(pluginInstance) && !force) { return; } if (!pluginInstance.IsEditorOpen) { // todo: create dummy image and generate random color pluginInstance.Plugin.Logger.Error( "Tried to create a screenshot, but the editor was not open (maybe the plugin denied to open the editor)"); return; } var data = pluginInstance.CreateScreenshot(); if (data != null) { var ms = new MemoryStream(); ms.Write(data, 0, data.Length); ms.Seek(0, SeekOrigin.Begin); bmp = Image.FromStream(ms); } else { // todo: create dummy image and generate random color pluginInstance.Plugin.Logger.Error("Failed to acquire screenshot."); return; } niResource.VB_artwork.ReplaceFromStream(GetScaledBitmap(bmp, niResource.VB_artwork.TargetSize), NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated); niResource.MST_plugin.ReplaceFromStream(GetScaledBitmap(bmp, niResource.MST_plugin.TargetSize), NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated); niResource.MST_artwork.ReplaceFromStream(GetScaledBitmap(bmp, niResource.MST_artwork.TargetSize), NativeInstrumentsResource.ResourceStates.AutomaticallyGenerated); niResource.Color.BackgroundColor = DetectBestColor((Bitmap)bmp); }
private IVendorPresetParser GetPresetParser(IRemotePluginInstance pluginInstance) { pluginInstance.Plugin.Logger.Debug("Resolving Preset Parser"); var list = GetPresetHandlerListByPlugin(); if (list.ContainsKey(pluginInstance.Plugin.VstPluginId)) { var directlyFoundParser = list[pluginInstance.Plugin.VstPluginId]; directlyFoundParser.PluginInstance = pluginInstance; directlyFoundParser.Init(); if (directlyFoundParser.CanHandle()) { pluginInstance.Plugin.Logger.Debug( $"Directly found PresetHandler {directlyFoundParser.PresetParserType}"); return(directlyFoundParser); } } var orderedPresetParsers = GetPresetParsers(); foreach (var parser in orderedPresetParsers) { parser.PluginInstance = pluginInstance; try { parser.Init(); if (parser.IsNullParser) { continue; } parser.Logger.Clear(); parser.Logger.MirrorTo(pluginInstance.Plugin.Logger); if (!parser.CanHandle()) { continue; } pluginInstance.Plugin.Logger.Debug($"Using PresetHandler {parser.PresetParserType}"); } catch (ConnectivityLostException e) { // Let the upstream caller handle this throw e; } catch (Exception e) { LogTo.Error( $"Error while trying to use PresetParser {parser.GetType().FullName}: {e.GetType().FullName} {e.Message}."); LogTo.Debug(e.StackTrace); continue; } return(parser); } pluginInstance.Plugin.Logger.Debug("No PresetHandler found, using NullPresetParser"); return((IVendorPresetParser)Activator.CreateInstance(_nullPresetParserType)); }
public NoMetadataAvailableException(IRemotePluginInstance pluginInstance) : base( $"{pluginInstance.Plugin.DllPath} has no metadata loaded, unable to continue") { }