Delphi VstSdk plugin <-> editor thread question

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

I'm working on a midi plugin for translating incoming midi nrpn message into note and cc messages.

The plugin has a gui based on DIBControls. At this moment I have one challenge. As known by me the plugin constist of two threads: a plugin thread and editor (gui) thread.
Translating incoming midi messages from within the plugin thread based on parameters set in the editor thread and sending them out is no problem I have that working.

But now my question: how can I generate a outgoing midi message from within the plugin thread by initiated from a editor event (let's say a mousedown event on a DIBglyphbutton)?

Anyone?
Last edited by FerryB on Wed Jun 09, 2004 1:31 pm, edited 1 time in total.

Post

Probably the best place to do this would be in the idle() section of uplugin.pas.

this has access to both the GUI thread and the plugin thread. [/code]

Post

scuzzphut,

As always a swiftly anwser! But I experimented with with that withou succes. Let me illustrate case. I click on a gui object which lead to and event in the editor thread. In this event I want to call procedures which are part of plugin thread and aren't public.

Do you mean that this can't be done from within the editor and I have to use shared variables and monitor their changes from within the plugin thread and in the case of a change take action in the idle() procedure?

Post

I think that you would have to monitor the state of a GUI object (e.g. slider.position) from the idle() procedure and trigger a midi event from there.

I should temper all of this by saying that I haven't done this before. :?

If I want to trigger a plugin event using a GUI object, I usually just have the GUI object changed a parameter and watch for the parameter change in the plugin thread.

Post

alternatively you could have the glyphbutton onclick() routine toggle the state of a variable in the GUI thread and in the plugin thread's idle() routine you could watch for that variable changing...........

Post

I think I get the picture. I will try your tips right now.

Post

I'd just add that I've had some trouble accessing DIB components from idle().

In my example I wanted to change the image in an image container from within idle - but it just refused to work. In the end I had to change a(n invisible) text field within the editor from idle() and use the on change event of the text field to alter my image.

But then I'm not always 100% sure what I'm doing... :D
Image
ARPocalypse - AT - wiz - DOT - nildram - DOT co - DOT - uk

Post

KoobaRadio,

I will keep that trick in mind just in case :P

Post

FerryB if You're using Tobybears vst plugin example try adding 'uplugin.pas' or the unit containing the procedures for scheduling the midi events at the uses clause after 'implementation' and then cast the 'effect' variable ptr that youve set on 'editor.open()' as the class on top of AudioEffectX. eg.

...
implementation

uses
uPlugin, Maths, Windows ..;
...

procedure TPluginForm.SendButtonClick();
begin
(fEffect as TMyEffect).PutMidiEventOnStack();
end;

fEffect is the variable for public property Effect of the TPluginForm class which you set on editor.open() like in the template.
TMyVSTEffect is the class of your vst plugin, or APlugin in the templates

Post

The easiest way to trigger something in the plugin's thread from the editor's thread is simply by calling effect.setparameter()!

The index you use does not need to be inside the interval defined for the regular parameters.

As an example for a reset button implementation:

Let's say you have a plugin with two parameters, but want to have a reset button on your GUI that calls some internal routines in the plugin thread,

Code: Select all


// in config.inc or other global place
const kReset = 9999;
// (can be any number you want)

// in editor
procedure TMyForm.Button1Click(Sender: TObject);
begin
 if assigned(effect) then effect.setparameter(kReset, 1);
end;

// in plugin
procedure APlugin.SetParameter(index: integer; value: single);
begin
 case index of
 kReset:
  InternalResetProcedure; // your reset procedure
 ... // the regular parameter handler
 else
 end;
end;

Hope that helps...
Cheers

Toby

www.tobybear.de

Post

:D

Post

thanks to the Tobester :)

that clears that one up nicely :D

Post

Two possible ways to do the trick. One based on shear Delphi creativity the other based on knowing the vstsdk design.

Toby, I get it now. Thanks!

Thanks a lot guys for the feedback. It gives me a lot of energy. Programming a vst plugin is quite some work, I have found out. But it makes me very humble toward the real masters of this field...

Now I must be able to finish my baby in a few days.

Post Reply

Return to “DSP and Plugin Development”