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

Display parameters

Sep 16, 2009 at 3:56 AM

Hello, i would like thank you for your work.

I have one problem, that i couldnt resove. I would like create some vst plugin, that show defined text by defined income midi event (cc, note or program change). I did take MidiNoteMapper as base for trying do it. I add one label on MidiNoteMapperUI and i need change his text value from MidiProcessor, but i dont know how.

Of cource for the future i make better gui and mapping midi parameters to right text will be defined in xml file, but for start i need interconnect MidiProcessor and MidiNoteMapperUI. i thinked, the way can be fire some event in the MidiProcessor and catch it in MidiNoteMapperUI, but i dont know how do it.

What i need: i want create for my music playing some configurable display screen, that i will se, which synthetiser will play and other informations, becuase i use 3 midi controlers and 10 vst synthetisers and i need view, what is setup at the moment. so i neew by the some midi event display some predefined text. I have everything thinked, configuration, how it will be designed, etc, i only need comunicate from midi processor to the ui... i use modular software with vst support and make own vst will be the best chance do it.


Thank you for answer

Sep 16, 2009 at 8:31 AM
Edited Sep 16, 2009 at 8:33 AM

I assume you work with WinForms (that is what the MidiNoteMapper sample uses) and that you know how to work with the WinForm Controls (Buttons, Lists, Labels etc.)

The most important thing to remember is that the thread the IVstMidiProcessor.Process method (MidiProcessor) is called on, is a different one than the thread used to display the plugin's UI. You cannot call directly into the UI from another thread (except the one that created the Form/controls).

So you need some way to pass instructions from one thread (MidiProcessor) to the other (UI). One way of doing that is using a Queue. The queue can contain actions or tasks that the MidiProcessor creates and the UI executes. So you need to define a task with the necessary data for each type of operation you require on the UI. During the Process call of the MidiProcessor you start creating these tasks and adding the to the queue. This should be light weight and fast so you don't suffer any performance issues.

It is crucial that the queue is thread-safe! It will be called from multiple threads.

Next you need a 'trigger' on the UI that reads in these tasks and start executing them. You have two choices:

1) From within the MidiProcessor call the Invoke method on the UserControl to call some method (indirectly through the delegate) that does the work.
This is probably the simplest way to try things out with.

2) In the IVstPluginEditor.ProcessIdle (PluginEditor) method you read these tasks and perform the appropriate action on the UI. You will need to link up to the UI UserControl (retrieve the reference from the _uiWrapper).

After a task has been read from the queue it is automatically removed (that is what a queue does ;-) so you don't execute the same task multiple times.

Hope it helps.


Sep 16, 2009 at 11:45 AM

Thank you for your answer. I tryied write some code, but without success. I tried implement this sample, but i am not familiar with threading. So it dont work.

I would like ask, if you dont want add to the midi mapper example simple functionality that show in label under buttons in MidiNoteMapperUI incoming note number. I thing it will be very usefull not only for me.

Thank you

Sep 16, 2009 at 12:18 PM

If you're programming a VST plugin you should be familiar with threading. A VST Plugin is accessed by multiple threads (common for most hosts), so its essential that you know your threading.

Instead of using the sample you linked to, you could consider using a SynchronizedCollection<T> as a queue. Add to the end of the collection and retrieve from the front (index=0) of the collection. You have to manually delete the entry when you've retrieved it.

Unfortunatly I don't have the time currently to work on VST.NET so I wont be able to write that code for you.


Sep 16, 2009 at 12:19 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 20, 2009 at 4:19 PM

Thank you for your advice, that is perfect for my using.

Now i have my own vst plugin, that do exactly that i need. I was not aspire be a vst plugin programer, but i needed this functionality for my live playing, and thank you for your project, i have it.

If you want, i send you my code, maybee you can add it to the expamples, but it has diferent namespaces of course.

Sep 21, 2009 at 10:40 AM

I'm glad it worked out for you!

I hope you found it relatively easy to accomplish the task.

Sure, send over your source code and I will look at it and see if its a good sample ;-)

Sep 24, 2009 at 8:55 PM

I've implemented the sample code you asked for in the MidiNoteMapper sample (and fixed the persistence which wasn;t working at all :-| ).

The changeset 27121 contains these changes.

Hope it helps.