Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        //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);
        }
        //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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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();
        }
Beispiel #8
0
        public void OpenPlugin(string pluginPath, Jacobi.Vst.Core.Host.IVstHostCommandStub hostCmdStub)
        {
            try
            {
                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();
                PluginContext = ctx;

                // there is a question whether we should "turn on" the plugin here or later
                // by "turn on" i mean do MainsChanged(true)
                // a working Vst Host (see MidiVstTest, a copy from the microDRUM project)
                // does the following:
                //
                // GeneralVST.pluginContext = VstPluginContext.Create(VSTPath, hcs);
                // GeneralVST.pluginContext.PluginCommandStub.Open();
                // GeneralVST.pluginContext.PluginCommandStub.EditorOpen(hWnd);
                // GeneralVST.pluginContext.PluginCommandStub.MainsChanged(true);

                // While a forum entry suggested the following:
                // [plugin.Open()]
                // plugin.MainsChanged(true) // turn on 'power' on plugin.
                // plugin.StartProcess() // let the plugin know the audio engine has started
                // PluginContext.PluginCommandStub.ProcessEvents(ve); // process events (like VstMidiEvent)
                //
                // while(audioEngineIsRunning)
                // {
                //     plugin.ProcessReplacing(inputBuffers, outputBuffers)  // letplugin process audio stream
                // }
                //
                // plugin.StopProcess()
                // plugin.MainsChanged(false)
                //
                // [plugin.Close()]

                //doPluginOpen();
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(e.ToString(), e.InnerException);
            }
        }
Beispiel #9
0
        private VstPluginContext OpenPlugin(string pluginPath)
        {
            try
            {
                HostCommandStub hostCmdStub = new HostCommandStub();
                hostCmdStub.PluginCalled += new EventHandler <PluginCalledEventArgs>(HostCmdStub_PluginCalled);

                VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub);

                ctx.Set("PluginPath", pluginPath);
                ctx.Set("HostCmdStub", hostCmdStub);

                ctx.PluginCommandStub.Open();

                return(ctx);
            }
            catch (Exception) { }

            return(null);
        }
Beispiel #10
0
        private VstPluginContext LoadPlugin(string pluginPath)
        {
            try
            {
                HostCommandStub hostCommandStub = new HostCommandStub();
                hostCommandStub.PluginCalled += new EventHandler <PluginCalledEventArgs>(hostCommandStub_PluginCalled);
                VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCommandStub);
                ctx.Set("PluginPath", pluginPath);
                ctx.Set("HostCmdStub", hostCommandStub);
                ctx.PluginCommandStub.Commands.Open();

                selectVSTButton.Enabled = false;
                loadVSTButton.Enabled   = false;

                return(ctx);
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(null);
        }
Beispiel #11
0
        public void OpenPlugin(string pluginPath, Jacobi.Vst.Core.Host.IVstHostCommandStub hostCmdStub)
        {
            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();
                //doPluginOpen();

                PluginContext = ctx;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
        }
Beispiel #12
0
        private void addPath(string path)
        {
            Boolean saveSettings = false;

            if (!Directory.Exists(path))
            {
                return;
            }

            // Recursive
            foreach (var dir in new DirectoryInfo(path).GetDirectories())
            {
                addPath(dir.FullName);
            }

            foreach (FileInfo file in new DirectoryInfo(path).GetFiles())
            {
                if (file.Extension == ".dll")
                {
                    if (mSettingsMgr.Settings.KnownVSTPluginDlls.Contains(file.FullName))
                    {
                        continue;
                    }

                    try
                    {
                        //VstHostCommandBase tmpHostCmdStub = new VstHostCommandBase(this);
                        using (VstPluginContext ctx = VstPluginContext.Create(file.FullName, this))
                        {
                            // add custom data to the context
                            ctx.Set("PluginPath", file.FullName);
                            ctx.Set("HostCmdStub", this);

                            VstInfo info = new VstInfo();

                            info.AudioInputCount        = ctx.PluginInfo.AudioInputCount;
                            info.AudioOutputCount       = ctx.PluginInfo.AudioOutputCount;
                            info.CanReceiveVstMidiEvent = ctx.PluginCommandStub.CanDo(VstCanDoHelper.ToString(VstPluginCanDo.ReceiveVstMidiEvent)) == VstCanDoResult.Yes;
                            info.Name    = file.Name.Replace(".dll", string.Empty); // ctx.PluginCommandStub.GetEffectName();
                            info.DLLPath = file.FullName;

                            // Effect?
                            if (info.AudioInputCount > 0 && info.AudioOutputCount > 0)
                            {
                                mSettingsMgr.Settings.Effects.Add(info);
                            }

                            // VSTi?
                            if (info.CanReceiveVstMidiEvent)
                            {
                                mSettingsMgr.Settings.Instruments.Add(info);
                            }

                            if ((ctx.PluginInfo.Flags & VstPluginFlags.ProgramChunks) != VstPluginFlags.ProgramChunks)
                            {
                                MessageBox.Show(string.Format("{0} does not support chunks", info.Name));
                            }
                        }
                    }
                    catch
                    {
                        // Do nothing
                    }

                    // Files to exclude from future search
                    mSettingsMgr.Settings.KnownVSTPluginDlls.Add(file.FullName);
                    saveSettings = true;
                }
            }

            if (saveSettings)
            {
                mSettingsMgr.SaveSettings();
            }
        }
Beispiel #13
0
        private VstPluginContextWrapper OpenPlugin(string pluginPath)
        {
            try
            {
                if (File.Exists(pluginPath))
                {
                    HostCommandStub  hostCmdStub = new HostCommandStub();
                    VstPluginContext ctx         = VstPluginContext.Create(pluginPath, hostCmdStub);
                    if (ctx.PluginInfo.AudioInputCount != 2)
                    {
                        return(null);
                    }
                    if (ctx.PluginInfo.AudioOutputCount != 2)
                    {
                        return(null);
                    }
                    if ((ctx.PluginInfo.Flags & VstPluginFlags.CanReplacing) == 0)
                    {
                        return(null);
                    }

                    hostCmdStub.PluginCalled += (s, e) =>
                    {
                        HostCommandStub stub = (HostCommandStub)s;

                        // can be null when called from inside the plugin main entry point.
                        if (stub.PluginContext.PluginInfo != null)
                        {
                            //Debug.WriteLine("Plugin " + hostCmdStub.PluginContext.PluginInfo.PluginID + " called:" + e.Message);
                        }
                        else
                        {
                            //Debug.WriteLine("The loading Plugin called:" + e.Message);
                        }
                    };

                    // 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(Program.CurrentSamplingRate);
                    ctx.PluginCommandStub.MainsChanged(true);
                    ctx.PluginCommandStub.StartProcess();
                    initVECCSS();
                    return(new VstPluginContextWrapper(ctx));
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(Exception))
                {
                    throw;
                }
                else if (ex.GetType() == typeof(SystemException))
                {
                    throw;
                }

                //ignore
            }

            return(null);
        }
Beispiel #14
0
 /// <inheritdoc />
 public void Set <T>(string keyName, T value)
 {
     context.Set <T>(keyName, value);
 }