问题
I've successfully simplified the Vst.net host sample to directly load a vst instrument. Mostly I've just stripped out the GUI and made it automatically fire a few test notes. This code works when I build it as a console application.
using System;
using Jacobi.Vst.Core;
using Jacobi.Vst.Interop.Host;
using NAudio.Wave;
using CommonUtils.VSTPlugin;
namespace Jacobi.Vst.Samples.Host
{
///<Summary>
/// Gets the answer
///</Summary>
public class pianoVST
{
///<Summary>
/// Gets the answer
///</Summary>
public static VST vst = null;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
}
/// <summary>
/// Play some test notes.
/// </summary>
public void playTest()
{
var asioDriverNames = AsioOut.GetDriverNames();
if (asioDriverNames.Length > 0)
{
MidiVstTest.UtilityAudio.OpenAudio(MidiVstTest.AudioLibrary.NAudio, asioDriverNames[0]);
MidiVstTest.UtilityAudio.StartAudio();
vst = MidiVstTest.UtilityAudio.LoadVST("[path-to-vst-dll]");
for (int i = 0; i < 3; i++)
{
vst.MIDI_NoteOn(60, 100);
System.Threading.Thread.Sleep(1000);
vst.MIDI_NoteOn(60, 0);
System.Threading.Thread.Sleep(1000);
}
}
}
}
}
However, when I build this as a dll, import it into Unity and then attach it to a simple GameObject, I'm not able to get it to run or build. The error message I get is:
ArgumentException: The Assembly Jacobi.Vst.Interop is referenced by Jacobi.Vst.Samples.Host ('Assets/Jacobi.Vst.Samples.Host.dll'). But the dll is not allowed to be included or could not be found.
I've rebuilt the C++ interop dll from source but nothing I do makes it work with Unity.
Is there something I can do to make the Jacobi.Vst.Interop dll work nicely with Unity?
回答1:
VST.Net has a dependency on the VC110.CRT package. That error could be a result of not have the VC runtime installed.
https://github.com/obiwanjacobi/vst.net/blob/master/docs/Using_VST.NET.md
来源:https://stackoverflow.com/questions/50437265/using-vst-net-with-unity3d-to-create-a-simple-vst-host