Delphi VstSdk plugin <-> editor thread question
-
- KVRist
- Topic Starter
- 56 posts since 16 Jan, 2003
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?
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.
-
- KVRist
- Topic Starter
- 56 posts since 16 Jan, 2003
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?
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?
-
- KVRAF
- 3723 posts since 17 Apr, 2002 from Scotland
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.
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.
-
- KVRAF
- 3723 posts since 17 Apr, 2002 from Scotland
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...........
-
- KVRist
- 64 posts since 29 Oct, 2003 from London
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...
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...
-
- KVRer
- 16 posts since 14 May, 2003
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
...
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
-
- KVRian
- 880 posts since 11 Jun, 2001 from Munich, Germany
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,
Hope that helps...
Cheers
Toby
www.tobybear.de
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;
Cheers
Toby
www.tobybear.de
-
- KVRer
- 16 posts since 14 May, 2003
-
- KVRist
- Topic Starter
- 56 posts since 16 Jan, 2003
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.
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.