MIDI Plugin: Exception under Cubase

Topics: Getting Started, Midi, Plugin Development, VST.NET Core, VST.NET Framework, VST.NET Interop
May 9, 2013 at 6:42 PM
Edited Nov 8, 2013 at 3:14 AM
Hello,

This is my first try to build a midi plug-in with the help of VST.NET.

I made a project using the VST.NET Midi Template and referenced the CLR4 x86 DLLs.

The project is compileable and can be loaded into Cubase, but can't figure out, what the shown exceptions mean.

The project includes the referenced .dlls in a folder called DLL. When you download the project, you can open it with Visual Studio 2010 and should be compileable rightaway, because the .dlls are part of the project.

My question is: Would it be possible, that someone downloads the project, compile it and give it a try under Cubase, to figure out, what I have done wrong?

As the exception is really weird and complex, I made a screenshot, that you can see here:

Image

I think, it is some kind of UI error, because the GUI is only showing white space. I tried debugging under Cubase, which works, but I could not figure out, what the problem is.

Also, I am not sure, if I used the right *.dlls. My target platform would be Windows x86 and Cubase 5.1.

Thank you.
Coordinator
May 10, 2013 at 5:34 AM
Hi,

I'm sorry I don't have time to run and debug your program. But from what I see in the exception stack trace you have a PluginEditorView.BindParameter method that adds some sort of binding to some control. That is the point where it goes wrong. Try to debug you code with a break point in that method and see if 'something' is 'wrong' (like a null reference?). You can also try to comment out all BindParameter calls from your PluginEditorView.InitializeParameters method and see which parameter introduces the problem as you try them one by one.

Hope it helps,
Marc
May 12, 2013 at 7:15 PM
Hello Marc,

thank you for answer.

After reviewing, what is going on in the VST.NET Midi Template, I now have a bigger picture, how and and where MIDI data is processed. My first aim would be, to show a list of the incoming midi data in the UI. As I can see where the MIDI data is processed, I will start there.

What is really hard to get, is how to customize/change the UI. I have added a ListBox Control to the PlugInEditorView Control. The size of the control changed, the listbox is visible and everthing seems ok.

In the DAW, the control has still the original size and I just can not figure out, where to set width and height of the control. I can see the PluginEditor class, with the IVstPluginEditor Interface and you also described: "This object manages the custom editor (UI) for your plugin."

I am developer with 7 years experience and I was looking in the code, tested this and that, but I just don't get. I don't need a deep explanation, but it would be very helpful, if you give me hint, where to change the width and height of the UI. Just adding controls to UI doesn't seem to be the way, that I have to go. I also see, that you wrapped the PlugInEditor in the class WinFormsControlWrapper. I tried to return different values for the Rectangle, but nothing helped.

Thanks you.

Michael, Hamburg.
Coordinator
May 13, 2013 at 6:45 AM
Edited May 13, 2013 at 6:46 AM
I assume you are not building a resizable editor form. In that case it should be as simple as designing the WinForms UserControl that represents your Plugin Editor in Visual Studio. The size you make it in the designer, is the size it will be at runtime. Couldn't be simpler.

There are two objects at play. 1) The object that implement the IVstPluginEditor interface - remember to override the CreatePluginEditor method on the Plugin root object to return it there- and 2) the WinForms UserControl that represents your plugin UI. The WinFormsControlWrapper is just an adapter class that takes the WinForms UserControl (the root that represent your Editor) and attatches it to the parent window (frame) the Host provides. A basic PluginEditor implementation would look something like: https://vstnet.codeplex.com/SourceControl/latest#255902
Remember that the object that implement the IVstPluginEditor interface is NOT the UI itself. Its just an object that manages the interaction between the Host and your plugin UI.

So:
1) Create a WinForms UserControl that represents your plugin UI. Use normal Visual Studio practices - nothing special here.
https://vstnet.codeplex.com/SourceControl/latest#255897
partial class MidiNoteMapperUI : UserControl
{
  // use visual WinForms designer in Visual Studio.
}
2) Create an object that implement IVstPluginEditor that manages the interaction between the WinForm UserControl and the Host.
https://vstnet.codeplex.com/SourceControl/latest#255902
class PluginEditor : IVstPluginEditor
{
    private WinFormsControlWrapper<MidiNoteMapperUI> _uiWrapper = new WinFormsControlWrapper<MidiNoteMapperUI>();

    // rest of the impl of the IVstPluginEditor methods.
}
3) Override the Create function on the plugin root object (the object that implements IVstPlugin).
https://vstnet.codeplex.com/SourceControl/latest#255900
class Plugin : VstPluginWithInterfaceManagerBase, IVstPluginMidiSource
    {
        /// <summary>
        /// Creates a default instance and reuses that for all threads.
        /// </summary>
        /// <param name="instance">A reference to the default instance or null.</param>
        /// <returns>Returns the default instance.</returns>
        protected override IVstPluginEditor CreateEditor(IVstPluginEditor instance)
        {
            if (instance == null) return new PluginEditor(this);

            return instance;
        }

        // rest omitted...
    }
Take a look at the midi mapper plugin. It uses midi and a custom WinForms UI. Make a copy of that sample project and start playing with that. You should be able to get that going. https://vstnet.codeplex.com/SourceControl/latest#255897

Also make sure that when you are testing you are always testing the the assemblies you've just build. I usually add my project output directory (bin/debug) to the plugin path of the host I'm testing with - and press rescan (or similar) in the host - so it picks up the changed assemblies.

Hope it helps.
May 13, 2013 at 7:27 AM
Edited May 13, 2013 at 7:31 AM
Hello Marc,

thank you for your advise. I really appreciate your help.

I will look through it and test it out. As this is a "weekend fun" project for me, I will give you some feedback, when I find the time this week.

EDIT: What I found out, that Cubase is very sensitive in case of execptions. For that reason I downloaded Reaper, which is also a great VST host, fully functional and it just doesn't crash on exceptions.

Happy Coding.

Michael.
May 19, 2013 at 12:55 PM
Hello Marc,

I deleted my old project and have started a complete new approach. I works now. I can see, change and debug the UI under Cubase or Reaper.

So, at this point everything is going well and I can start with my "midi dream machine". I am absolutely sure, that I won't have started programming a VST Plugin without your work. The steinberg VST SDK is such a pain in the ass. I have no idea why they don't go your way and provide some simple DLLs with a template that just works.

Thanks again.
Coordinator
May 19, 2013 at 6:11 PM
Thanx! Good to hear that you've got it all working.