public void LoadPlugin(string pluginPath) { LoadedPluginContext = VstPluginContext.Create(pluginPath, this); // update plugin info to loaded plugin _hostCmdProxy.UpdatePluginInfo(LoadedPluginContext.PluginInfo); }
//load from file private VstPluginContext OpenPlugin(string pluginPath) { try { HostCommandStub hostCmdStub = new HostCommandStub(); hostCmdStub.PluginCalled += HostCmdStub_PluginCalled; hostCmdStub.RaiseSave = SetNeedsSafe; VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub); var midiOutChannels = ctx.PluginCommandStub.GetNumberOfMidiOutputChannels(); //if(midiOutChannels > 0) { hostCmdStub.FProcessEventsAction = ReceiveEvents; } // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Open(); return(ctx); } catch (Exception e) { MessageBox.Show(FOwnerWindow, e.ToString(), "VST Load", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); }
public void Create_InvalidPluginFile_ThrowsExpectedExceptionWithResourceString() { var hostCmdStub = new StubHostCommandStub(); var notaPluginFile = Assembly.GetExecutingAssembly().Location; VstPluginContext.Create(notaPluginFile, hostCmdStub); }
public VstPluginContext CreateVstPluginContext(string pluginName) { VstPluginContext pluginContext = null; string pluginPath = AvailablePlugins.First(x => x.Name == pluginName).DLLPath; try { //VstHostCommandBase hostCmdStub = new VstHostCommandBase(this); //hostCmdStub.PluginCalled += hostCmdStub_PluginCalled; pluginContext = VstPluginContext.Create(pluginPath, this); // add custom data to the context pluginContext.Set("PluginPath", pluginName); pluginContext.Set("HostCmdStub", this); // actually open the plugin itself pluginContext.PluginCommandStub.Open(); pluginContext.PluginCommandStub.SetBlockSize(mAsioBuffSize); if (mAsio != null) { pluginContext.PluginCommandStub.SetSampleRate((float)mAsio.SampleRate); } pluginContext.PluginCommandStub.SetProcessPrecision(VstProcessPrecision.Process32); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(pluginContext); }
void SetEditor(bool reset = false) { if (reset || OpenContext != FSelectedSignal.PluginContext) { ClearCurrentView(); OpenContext = FSelectedSignal.PluginContext; if (HasEditor(OpenContext)) { OpenContext.PluginCommandStub.EditorOpen(PluginPanel.Handle); FHasEditor = true; if (FGenericUI != null) { PluginPanel.Controls.Remove(FGenericUI); FGenericUI.Dispose(); FGenericUI = null; } } else { FGenericUI = new GenericUI(OpenContext); FGenericUI.Dock = DockStyle.Fill; PluginPanel.Controls.Add(FGenericUI); FHasEditor = false; } } }
static void StartAudioOutput(string pluginPath, string waveFilePath) { try { var hostCmdStub = new HostCommandStub(); VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub); // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Open(); var audioOut = new AudioOutput( new List <IVstPluginCommandStub>() { ctx.PluginCommandStub }, waveFilePath); Thread.Sleep(100); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
public static VST LoadVST(string VSTPath, IntPtr hWnd) { DisposeVST(); GeneralVST = new VST(); var hcs = new HostCommandStub(); hcs.Directory = System.IO.Path.GetDirectoryName(VSTPath); try { GeneralVST.pluginContext = VstPluginContext.Create(VSTPath, hcs); GeneralVST.pluginContext.PluginCommandStub.Open(); //pluginContext.PluginCommandStub.SetProgram(0); GeneralVST.pluginContext.PluginCommandStub.EditorOpen(hWnd); GeneralVST.pluginContext.PluginCommandStub.MainsChanged(true); vstStream = new VSTStream(); vstStream.ProcessCalled += GeneralVST.Stream_ProcessCalled; vstStream.pluginContext = GeneralVST.pluginContext; vstStream.SetWaveFormat(44100, 2); Mixer32.AddInputStream(vstStream); return(GeneralVST); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(null); }
public void AttachVstPluginContext(VstPluginContext ctx, string name) { mVstPluginContext = ctx; // Create big enough buffers to fit all plugin types int inSize = 32; // value.PluginInfo.AudioInputCount; int outSize = 64; // value.PluginInfo.AudioOutputCount; if (mAsioBuffSize != 0) { if (InputBuffers == null || inSize != InputBuffers.Count) { InputBuffers = null; // Dispose first if already existed! InputBuffers = new AudioBufferInfo(inSize, mParentInBuffers); } if (OutputBuffers == null || outSize != OutputBuffers.Count) { OutputBuffers = null; // Dispose first if already existed! OutputBuffers = new AudioBufferInfo(outSize, mParentOutBuffers); } } ctx.PluginCommandStub.MainsChanged(true); ctx.PluginCommandStub.StartProcess(); State = PluginState.Deactivated; PluginName = name; ProgramName = ctx.PluginCommandStub.GetProgramName(); UseExtendedEffectRange = (PluginName == "Nexus"); }
public static VST LoadVst(string vstPath, IntPtr hWnd) { DisposeVst(); _generalVst = new VST(); var hcs = new HostCommandStub { Directory = System.IO.Path.GetDirectoryName(vstPath) }; try { _generalVst.pluginContext = VstPluginContext.Create(vstPath, hcs); _generalVst.pluginContext.PluginCommandStub.Open(); _generalVst.pluginContext.PluginCommandStub.SetProgram(13000); _generalVst.pluginContext.PluginCommandStub.EditorOpen(hWnd); _generalVst.pluginContext.PluginCommandStub.MainsChanged(true); _vstStream = new VSTStream(); _vstStream.ProcessCalled += _generalVst.Stream_ProcessCalled; _vstStream.pluginContext = _generalVst.pluginContext; _vstStream.SetWaveFormat(44100, 2); _mixer32.AddInputStream(_vstStream); return(_generalVst); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(null); }
//private void OutPluginInfo(VstPluginContext ctx) //{ // Debug.Print("Plugin: " + ctx.PluginCommandStub.GetEffectName() + " " // + ctx.PluginCommandStub.GetProductString() // + "Version: " + ctx.PluginCommandStub.GetVendorVersion().ToString() + "\n" // + "***********************************************************************\n"); //} public VstPluginContext OpenPlugin(string pluginPath) { try { HostCommandStub hostCmdStub = new HostCommandStub(); hostCmdStub.PluginCalled += new EventHandler <PluginCalledEventArgs>(HostCmdStub_PluginCalled); VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub); // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Open(); Plugin plugin = new Plugin(ctx.PluginInfo.PluginID, ctx.PluginCommandStub.GetProductString(), ctx, GetParameters(ctx)); Plugins.Add(ctx.PluginInfo.PluginID, plugin); Debug.Print("Plugin: " + pluginPath + " Loaded"); return(ctx); } catch (Exception e) { Debug.Print(e.Message); } return(null); }
public void Unload() { if (State == PluginState.Unloading || State == PluginState.Empty) { throw new Exception("Shouldn't be here!"); } if (State == PluginState.Activated) { Deactivate(); } if (State == PluginState.Deactivated) { // Start unload CloseEditor(); mUnloadingCompleteEvent.Reset(); State = PluginState.Unloading; // Wait for asio callback to handle plugin deactivation to prevent a lock! if (mUnloadingCompleteEvent.Wait(100) == false) { // Asio driver not firing events and setting mUnloadingCompleteEvent: ignore } mVstPluginContext.PluginCommandStub.StopProcess(); mVstPluginContext.PluginCommandStub.MainsChanged(false); mVstPluginContext.PluginCommandStub.Close(); mVstPluginContext = null; } }
private void PluginListVw_SelectedIndexChanged(object sender, EventArgs e) { try { if (PluginListVw.SelectedItems.Count > 0) { PluginContext = (VstPluginContext)PluginListVw.SelectedItems[0].Tag; } else { PluginContext = null; } string Category = PluginContext.PluginCommandStub.GetCategory().ToString(); if (Category != "Effect") { isEffect = false; } else { isEffect = true; } if (isEffect == false) { plugins.AddPlugins(PluginContext); } else { } } catch (Exception) {} }
public InvisibleForm(VstPluginContext vstPluginContext) { InitializeComponent(); VstPluginContext = vstPluginContext; this.Shown += ThisFormShow; }
private VstPluginContext OpenPlugin(string pluginPath) { try { HostCommandStub hostCmdStub = new HostCommandStub(); hostCmdStub.PluginCalled += new EventHandler <PluginCalledEventArgs>(HostCmdStub_PluginCalled); VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub); // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Commands.Open(); return(ctx); } catch (Exception e) { MessageBox.Show(this, e.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); }
public Plugin(int id, string name, VstPluginContext pluginContext, List <Parameter> parameters) { Id = id; Name = name; PluginContext = pluginContext; Parameters = parameters; }
public void DetachVstPluginContext() { PluginName = string.Empty; ProgramName = string.Empty; State = PluginState.Empty; mVstPluginContext.PluginCommandStub.StopProcess(); mVstPluginContext.PluginCommandStub.MainsChanged(false); mVstPluginContext = null; }
public void Create_InvalidPluginFile_ThrowsExpectedException() { var hostCmdStub = new StubHostCommandStub(); var notaPluginFile = Assembly.GetExecutingAssembly().Location; Action target = () => VstPluginContext.Create(notaPluginFile, hostCmdStub); target.Should().Throw <EntryPointNotFoundException>(); }
void AddPlugin(string dir, bool is64) { VstPluginContext ctx = OpenPlugin(dir); if (ctx != null) { _plugins.Add(ctx); FillPluginList(); } }
//clear all displayed info or editor void ClearCurrentView() { if (OpenContext != null) { OpenContext.PluginCommandStub.EditorClose(); OpenContext = null; } PluginPanel.Controls.Clear(); }
public void Start() { const string extension = ".net.vstdll"; var pluginName = Directory.GetFiles(Directory.GetCurrentDirectory(), "*" + extension, SearchOption.AllDirectories).FirstOrDefault(); if (pluginName == null) { throw new Exception("No plugin in directoy."); } pluginName = pluginName.Replace(extension, ".dll"); _plugin = OpenPlugin(pluginName); if (_plugin != null) { _form.Text = string.Format("{0} {1} {2} {3}", _plugin.PluginCommandStub.GetEffectName(), _plugin.PluginCommandStub.GetProductString(), _plugin.PluginCommandStub.GetVendorString(), _plugin.PluginCommandStub.GetVendorVersion()); _plugin.PluginCommandStub.MainsChanged(true); Rectangle wndRect; if (_plugin.PluginCommandStub.EditorGetRect(out wndRect)) { var panelSize = _form.GetSizeFromClientSize(new Size(wndRect.Width, wndRect.Height)); panelSize.Height += _form.FMenu.Height; _form.Size = panelSize; _plugin.PluginCommandStub.EditorOpen(_form.PluginPanel.Handle); } else { FillParametersForm(); } FillProgramsList(); _plugin.PluginCommandStub.MainsChanged(false); _audioGenerator = new AudioGenerator(_host, _plugin); _audioPlayer = new WaveOut(); _audioPlayer.DesiredLatency = 110; _audioPlayer.Init(_audioGenerator); _audioPlayer.Play(); } if (_plugin == null) { MessageBox.Show("No plugin loaded."); _form.Close(); } }
protected void Load(string filename) { if (File.Exists(filename)) { PluginContext = OpenPlugin(filename); if (PluginContext == null) { return; } SetOutputCount(PluginContext.PluginInfo.AudioOutputCount); PluginContext.PluginCommandStub.MainsChanged(true); PluginContext.PluginCommandStub.SetSampleRate(WaveFormat.SampleRate); PluginContext.PluginCommandStub.SetBlockSize(AudioService.Engine.Settings.BufferSize); FIsSynth = PluginContext.PluginInfo.Flags.HasFlag(VstPluginFlags.IsSynth); PluginContext.PluginCommandStub.StartProcess(); FInputCount = PluginContext.PluginInfo.AudioInputCount; FOutputCount = PluginContext.PluginInfo.AudioOutputCount; FInputMgr = new VstAudioBufferManager(FInputCount, AudioService.Engine.Settings.BufferSize); FOutputMgr = new VstAudioBufferManager(FOutputCount, AudioService.Engine.Settings.BufferSize); FInputBuffers = FInputMgr.ToArray(); FOutputBuffers = FOutputMgr.ToArray(); // plugin does not support processing audio if ((PluginContext.PluginInfo.Flags & VstPluginFlags.CanReplacing) == 0) { MessageBox.Show("This plugin does not process any audio."); return; } FCanEvents = PluginContext.PluginCommandStub.CanDo("receiveVstMidiEvent") == VstCanDoResult.Yes; InfoForm = new PluginInfoForm(); InfoForm.PluginContext = PluginContext; InfoForm.DataToForm(); InfoForm.Dock = DockStyle.Fill; InfoForm.ParameterCheck += InfoForm_ParameterCheck; GetPluginInfo(); GetProgramNames(); if (PluginChanged != null) { PluginChanged(); } FDoProcess = true; } }
private void AddBtn_Click(object sender, EventArgs e) { VstPluginContext ctx = OpenPlugin(PluginPathTxt.Text); if (ctx != null) { _plugins.Add(ctx); FillPluginList(); } }
public void Finish() { if (_plugin != null) { _audioPlayer.Stop(); _audioPlayer.Dispose(); _plugin.PluginCommandStub.EditorClose(); _plugin.Dispose(); _plugin = null; } }
private VstPluginContext OpenPlugin(string pluginPath) { try { HostCommandStub hostCmdStub = new HostCommandStub(); //hostCmdStub.PluginCalled += new EventHandler<PluginCalledEventArgs>(HostCmdStub_PluginCalled); VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub); // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Open(); ctx.PluginCommandStub.SetSampleRate(44100f); ctx.PluginCommandStub.SetBlockSize(512); ctx.PluginCommandStub.MainsChanged(true); ctx.PluginCommandStub.StartProcess(); var sp = new VstSpeakerArrangement(); sp.Type = VstSpeakerArrangementType.SpeakerArrStereo; VstSpeakerProperties[] f = new VstSpeakerProperties[2]; f[0] = new VstSpeakerProperties(); f[1] = new VstSpeakerProperties(); f[0].SpeakerType = VstSpeakerTypes.SpeakerL; f[1].SpeakerType = VstSpeakerTypes.SpeakerR; sp.Speakers = f; var spin = new VstSpeakerArrangement(); spin.Type = VstSpeakerArrangementType.SpeakerArrEmpty; VstSpeakerProperties[] f2 = new VstSpeakerProperties[0]; spin.Speakers = f2; //ctx.PluginCommandStub.SetSpeakerArrangement(spin, sp); return(ctx); } catch (Exception e) { MessageBox.Show(this, e.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); }
private void DeleteBtn_Click(object sender, EventArgs e) { VstPluginContext ctx = SelectedPluginContext; if (ctx != null) { ctx.Dispose(); _plugins.Remove(ctx); FillPluginList(); } }
public void AddPlugins(VstPluginContext pluginContext) { string path = pluginContext.Find <string>("PluginPath"); pluginsInfo = new PluginsInfo(path); pluginsInfo.label1.Text = pluginContext.PluginCommandStub.GetEffectName(); pluginsInfo.Dock = DockStyle.Left; this.Controls.Add(pluginsInfo); this.AutoScroll = false; this.VerticalScroll.Enabled = false; this.VerticalScroll.Visible = false; this.VerticalScroll.Maximum = 0; this.AutoScroll = true; }
public void Dispose() { // try { // if ( // context!=null && // context.PluginCommandStub != null // ) { // context.PluginCommandStub.Close(); // context.Dispose(); // } // } // catch{} context = null; }
void CreateContext(string path) { if (context != null) { try{ context.PluginCommandStub.Close(); } catch {} try{ context.Dispose(); } catch {} try{ context = null; } catch {} } context = VstPluginContext.Create(path, Host.VstHost); PluginCommandStub.SetSampleRate(Convert.ToSingle(Host.VstPlayer.Settings.Rate)); Set("PluginPath", PluginPath = path); Set("HostCmdStub", Host.VstHost); // if (context!=null) Open(); }
public void AddParameters(VstPluginContext pluginContext) { lbParameters.Items.Clear(); for (int i = 0; i < pluginContext.PluginInfo.ParameterCount; i++) { var param = new VSTParameter(); param.Properties = pluginContext.PluginCommandStub.GetParameterProperties(i); param.Name = pluginContext.PluginCommandStub.GetParameterName(i); param.Label = pluginContext.PluginCommandStub.GetParameterLabel(i); param.Display = pluginContext.PluginCommandStub.GetParameterDisplay(i); lbParameters.Items.Add(param); } }
public VSTiInterface(string pluginPath) { HostCommandStub hostCmdStub = new HostCommandStub(); hostCmdStub.PluginCalled += new EventHandler <PluginCalledEventArgs>(HostCmdStub_PluginCalled); ctx = VstPluginContext.Create(pluginPath, hostCmdStub); // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Open(); }
public void AddParameters(VstPluginContext pluginContext) { lbParameters.Items.Clear(); for (int i = 0; i < pluginContext.PluginInfo.ParameterCount; i++) { VSTParameter param = new VSTParameter(); param.Properties = pluginContext.PluginCommandStub.GetParameterProperties(i); param.Name = pluginContext.PluginCommandStub.GetParameterName(i); param.Label = pluginContext.PluginCommandStub.GetParameterLabel(i); param.Display = pluginContext.PluginCommandStub.GetParameterDisplay(i); lbParameters.Items.Add(param); } }
static void Method(VstPluginContext PluginContext, int bytesWritten, byte[] destBuffer) { int inputCount = PluginContext.PluginInfo.AudioInputCount; int outputCount = PluginContext.PluginInfo.AudioOutputCount; int blockSize = bytesWritten; VstAudioBufferManager inputMgr = new VstAudioBufferManager(inputCount, blockSize); VstAudioBufferManager outputMgr = new VstAudioBufferManager(outputCount, blockSize); foreach (VstAudioBuffer buffer in inputMgr.ToArray()) { for (int i = 0; i < blockSize; i++) { buffer[i] = (float)destBuffer[i] / 128.0f - 1.0f; } } PluginContext.PluginCommandStub.SetBlockSize(blockSize); PluginContext.PluginCommandStub.SetSampleRate(44.8f); PluginContext.PluginCommandStub.StartProcess(); PluginContext.PluginCommandStub.ProcessReplacing(inputMgr.ToArray(), outputMgr.ToArray()); PluginContext.PluginCommandStub.StopProcess(); foreach (VstAudioBuffer buffer in outputMgr.ToArray()) { for (int i = 0; i < blockSize; i++) { destBuffer[i] = Convert.ToByte(((float)buffer[i] + 1.0f) * 128.0f); } } inputMgr.ClearBuffer(inputMgr.ToArray()[0]); inputMgr.ClearBuffer(inputMgr.ToArray()[1]); inputMgr.Dispose(); outputMgr.ClearBuffer(outputMgr.ToArray()[0]); outputMgr.ClearBuffer(outputMgr.ToArray()[1]); outputMgr.Dispose(); }
public PluginWindow(VstPluginContext ctx) { InitializeComponent(); _ctx = ctx; }
public Int32PluginContextChannel(VstPluginContext pluginContext) : base(44100,2) { this.pluginContext = pluginContext; lastPosition = 0; }
protected void Load(string filename) { if (File.Exists(filename)) { PluginContext = OpenPlugin(filename); if(PluginContext == null) return; SetOutputCount(PluginContext.PluginInfo.AudioOutputCount); PluginContext.PluginCommandStub.MainsChanged(true); PluginContext.PluginCommandStub.SetSampleRate(WaveFormat.SampleRate); PluginContext.PluginCommandStub.SetBlockSize(AudioService.Engine.Settings.BufferSize); FIsSynth = PluginContext.PluginInfo.Flags.HasFlag(VstPluginFlags.IsSynth); PluginContext.PluginCommandStub.StartProcess(); FInputCount = PluginContext.PluginInfo.AudioInputCount; FOutputCount = PluginContext.PluginInfo.AudioOutputCount; FInputMgr = new VstAudioBufferManager(FInputCount, AudioService.Engine.Settings.BufferSize); FOutputMgr = new VstAudioBufferManager(FOutputCount, AudioService.Engine.Settings.BufferSize); FInputBuffers = FInputMgr.ToArray(); FOutputBuffers = FOutputMgr.ToArray(); // plugin does not support processing audio if ((PluginContext.PluginInfo.Flags & VstPluginFlags.CanReplacing) == 0) { MessageBox.Show("This plugin does not process any audio."); return; } FCanEvents = PluginContext.PluginCommandStub.CanDo("receiveVstMidiEvent") == VstCanDoResult.Yes; InfoForm = new PluginInfoForm(); InfoForm.PluginContext = PluginContext; InfoForm.DataToForm(); InfoForm.Dock = DockStyle.Fill; GetPluginInfo(); GetProgramNames(); if (PluginChanged != null) PluginChanged(); FDoProcess = true; } }
private VstPluginContext OpenPlugin(string pluginPath) { try { HostCommandStub hostCmdStub = new HostCommandStub(); hostCmdStub.PluginCalled += new EventHandler<PluginCalledEventArgs>(HostCmdStub_PluginCalled); VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub); PluginContext = ctx; // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); // actually open the plugin itself ctx.PluginCommandStub.Open(); labelVstPath.Text = pluginPath; return ctx; } catch (Exception e) { MessageBox.Show(this, e.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } return null; }
private bool HasEditor(VstPluginContext ctx) { if (ctx.PluginInfo.Flags.HasFlag(VstPluginFlags.HasEditor)) return true; var rect = new Rectangle(); ctx.PluginCommandStub.EditorGetRect(out rect); return rect.Width > 0; }
void SetEditor(bool reset = false) { if (reset || OpenContext != FSelectedSignal.PluginContext) { ClearCurrentView(); OpenContext = FSelectedSignal.PluginContext; if (HasEditor(OpenContext)) { OpenContext.PluginCommandStub.EditorOpen(PluginPanel.Handle); } else { //TODO: create basic gui } } }