This project has moved and is read-only. For the latest updates, please go here.

VST Instrument with UI Sample

Jul 4, 2015 at 5:02 AM
Hi,

Delay is a great audio effect sample. The CorePlugin is an example of a UI example but it doesn't seem to have any audio implementation.

Is there an implementation of an instrument the accepts midi etc., has a UI, and outputs audio?

Thankyou!
Jul 4, 2015 at 8:28 AM
Also, I've been playing around with the Core sample. The problem that I'm having with WPF is that no matter what controls I put on screen, they are always disabled!

I tried to capture a button click event, and I couldn't get it. Then, I put a checkbox on screen and I couldn't even check it. What's the deal here?
Jul 4, 2015 at 8:31 AM
Apparently, we have to enable the window after wards? This form MSDN doco:

Windows Styles
https://msdn.microsoft.com/en-us/library/ms632600

WS_DISABLED0x08000000L
The window is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use the EnableWindow function.
Jul 4, 2015 at 8:31 AM
The Core plugin demonstrates how to write a plugin that only uses the Core API so it doesn't use Jacobi.Vst.Framework. It is not meant to be a functional audio plugin. It also demonstartes how to setup a UI with WPF.

I (still) don't have an instrument plugin sample, but there are several that use Midi and have Custom UI. I would look at the MidiNoteRecorder which is a sort of sampler and can play a recorded piece of audio when a Midi note is received.

Basically you interpret Midi notes in the ProcessEvents. You have to remember the actions until Process is called (usually right after ProcessEvents) where you can output the audio samples into the out buffers.

Have look at the sample and if you have more questions, I am happy to help you as much as I can.

Hope it helps,
Marc
Jul 4, 2015 at 8:36 AM
Tried this:
    [DllImport("user32.dll")]
    public static extern IntPtr EnableWindow(IntPtr hWnd, bool bEnable);
        public void Open(IntPtr hWnd)
        {
            _instance = new T();
            _instance.Width = _width;
            _instance.Height = _height;

            HwndSourceParameters hwndParams = new HwndSourceParameters("VST.NET Wpf Editor");
            hwndParams.ParentWindow = hWnd;
            hwndParams.Height = _height;
            hwndParams.Width = _width;
            hwndParams.WindowStyle = 0x10000000|0x40000000; // WS_VISIBLE|WS_CHILD
            


            _hwndSource = new HwndSource(hwndParams);
            _hwndSource.RootVisual = _instance;


            NativeMethods.EnableWindow(hWnd, true);
        }
No dice.
Jul 4, 2015 at 8:47 AM
False alarm!

The event handler was throwing an exception and therefore making it look as though the control wasn't working. I've switched to VS2015 and I didn't have break on all exceptions turned on when I thought I did. They've changed it on me.