Skip to content

Instantly share code, notes, and snippets.

@atsushieno
Created June 20, 2010 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atsushieno/445909 to your computer and use it in GitHub Desktop.
Save atsushieno/445909 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using Jacobi.Vst.Core;
using Jacobi.Vst.Interop.Host;
using Jacobi.Vst.Samples.Host;
namespace Commons.Music.Midi.Vst
{
public class Driver
{
public static void Main (string [] args)
{
var player = new VsqPlayer (args [0]);
}
}
public class VsqPlayer
{
public VsqPlayer (string pluginPath)
{
GetContext (pluginPath);
}
VstPluginContext GetContext (string pluginPath)
{
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();
return ctx;
}
void HostCmdStub_PluginCalled (object sender, PluginCalledEventArgs e)
{
HostCommandStub hostCmdStub = (HostCommandStub) sender;
// can be null when called from inside the plugin main entry point.
if (hostCmdStub.PluginContext.PluginInfo != null)
Debug.WriteLine ("Plugin " + hostCmdStub.PluginContext.PluginInfo.PluginID + " called:" + e.Message);
else
Debug.WriteLine ("The loading Plugin called:" + e.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment