PDA

View Full Version : instrument exampleproject?


debian
09-04-2009, 02:32 PM
Hi, thanks for a great framework IPlug :-)

Has any one got a simple instrument exampleproject to share?
Regards

Tale
09-20-2009, 02:17 PM
Here you go, a simple IPlug instrument project:

http://www.taletn.com/temp/IPlugInstrument.zip

It's a monophonic synth that plays non-band-limited square waves (with plenty of aliasing), so it probably isn't of much practical use. But it does show you how to handle basic MIDI messages (note on/off with velocity, CC and channel mode messages).

There's one thing that doesn't work as intended: When I send CC#7 to it, its volume parameter changes. However, this change isn't directly visible in the UI (at least not in REAPER). Should I perhaps let the host know the parameter has changed? This is a GUI-less plug BTW, but that shouldn't really matter, right?

cc_
09-21-2009, 12:07 AM
Nice.


There's one thing that doesn't work as intended: When I send CC#7 to it, its volume parameter changes. However, this change isn't directly visible in the UI (at least not in REAPER). Should I perhaps let the host know the parameter has changed?

You need to call InformHostOfParamChange() after you've updated the parameter.

Also, when the GUI is added, the call to SetNormalized() will need to be changed to SetParameterFromPlug() otherwise the GUI controls will not get updated.

Tale
09-21-2009, 12:57 AM
You need to call InformHostOfParamChange() after you've updated the parameter.
Thanks! I've just tried that, but it doesn't seem to work. However, another of my VSTi test projects made with only the VST SDK also doesn't update the GUI-less UI in REAPER, so perhaps this is a REAPER bug?

Also, when the GUI is added, the call to SetNormalized() will need to be changed to SetParameterFromPlug() otherwise the GUI controls will not get updated.
Like this you mean?

this->vol = value / 127.;
if (GetGUI())
GetGUI()->SetParameterFromPlug(kVol, this->vol, true);
else
GetParam(kVol)->SetNormalized(this->vol);
InformHostOfParamChange(kVol, this->vol);

Tale
09-28-2009, 01:14 PM
I have updated my instrument example (http://www.taletn.com/temp/IPlugInstrument.zip), so it now respects MIDI timing for note on/off messages. I have also replaced my own MIDI message parsing code with IPlug's IMidiMsg struct, and I have included the InformHostOfParamChange() call. The latter now successfully updates the volume parameter on screen in REAPER, but only when the parameter is shown in the track controls. But I do think this is a REAPER issue, not an IPlug issue.

A side note: A couple of CCs are missing from the IMidiMsg struct enum list (in IPlugStructs.h), namely most channel mode messages, so I had to "hard code" these in my example.

debian
09-29-2009, 01:14 AM
Hi Tale,
Thanks a lot! An example is really helpful,
I'm looking forward to test your example.


I have had a few rats as pets :)
Rats are intelligent and are nice pets.

sorry for off topic.

Tale
10-08-2009, 02:51 PM
I've once again updated my example (http://www.taletn.com/temp/IPlugInstrument.zip) project:

* All MIDI messages are now handled with sample timing accuracy, because ProcessMidiMsg() no langer handles them, but rather just adds the messages to a queue. This queue is then processed in ProcessDoubleReplacing().

* I've added the required mutex locks (although without a GUI they are not stricly needed, I think).

Off topic: Yeah, rats make great pets. I have 4 males at the moment, I can hear them nibbling on something behind me. (I do hope it's not my internet cable though...)

Jeffos
11-02-2009, 05:45 AM
Thanks for sharing Tale!

The latter now successfully updates the volume parameter on screen in REAPER, but only when the parameter is shown in the track controls. But I do think this is a REAPER issue, not an IPlug issue.


I confirm this issue in "generic UI mode". I also think it's a reaper bug: the fact that the param is present as a track control seems to force the refresh as well as clicking the "UI" button...
[edit] issue reported here: http://forum.cockos.com/project.php?issueid=1438

Jeffos
02-22-2010, 11:06 AM
..another thread reminded me this one.

Update:
Even if the issue I reported above ended as "Live with it" (which is ok for me), I managed to make this thing work thanks to Reaper's API (btw, only works with that daw): the trick is to call TrackFX_SetParam() rather than InformHostOfParamChange(). The first reason I did that is not to polluate Reaper with useless undo points, but, as the cherry on the pie, it also makes the generic UI updating.. nice for "light" plugs..