This project has moved. For the latest updates, please go here.

Display parameters

Sep 16, 2009 at 2: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

Coordinator
Sep 16, 2009 at 7:31 AM
Edited Sep 16, 2009 at 7: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.

Marc

Sep 16, 2009 at 10:45 AM

Thank you for your answer. I tryied write some code, but without success. I tried implement this sample http://bytes.com/topic/c-sharp/answers/492902-inter-thread-message-queue-c, 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

Coordinator
Sep 16, 2009 at 11:18 AM

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.

 

Coordinator
Sep 16, 2009 at 11:19 AM
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 3: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.

Coordinator
Sep 21, 2009 at 9: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 ;-)

Coordinator
Sep 24, 2009 at 7: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.