View Full Version : IPlug - any example simple MIDI plugins?
captain caveman
12-29-2010, 09:31 AM
Hi
I have been tinkering around with and compiling the IPlugExample plugin, but was wondering if there are any examples of doing MIDI processing with IPlug to get me started off hacking some plugs together?
Basically I'd just like to know how to get the MIDI and how to send it on, modified or otherwise.
--------
edit1:
Okay, I've managed to get a plugin that eats MIDI, using....
ProcessMidiMsg(IMidiMsg* pMsg){}
.... with nothing in the function. I don't know how to get MIDI info though. Any tips would be great.
--------
Also, are the VST plugins compiled with IPlug using the VST SDK automatically cross platform or is there something else to do for OSX (if at all possible from a PC) compatibility?
Cheers for any assistance.
edit2:
Another n00b question - how do I get the plugin to compile not in DEBUG mode with the debug text in the GUI and plugin name?
Okay, I've managed to get a plugin that eats MIDI, using....
ProcessMidiMsg(IMidiMsg* pMsg){}
.... with nothing in the function. I don't know how to get MIDI info though. Any tips would be great.
Here is a short snippet that will block all CCs on MIDI channel 1, but send all other messages back out:
ProcessMidiMsg(IMidiMsg* pMsg)
{
int event = pMsg->mStatus >> 4;
int channel = pMsg->mStatus & 0x0F;
int cc_or_note = pMsg->mData1;
int value_or_velocity = pMsg->mData2;
if (!(event == IMidiMsg::kControlChange && channel == 0))
{
SendMidiMsg(pMsg);
}
}
For more about IMidiMsg see IPlugStructs.h.
Also, are the VST plugins compiled with IPlug using the VST SDK automatically cross platform or is there something else to do for OSX (if at all possible from a PC) compatibility?
If you don't do anything too Windows-specific, then your code should be cross platform (and else there is SWELL). I am able to compile my ComboV project on Win32, Win64, OS X ppc, OS X i386, and OS X x86_64 (VST and AU) from just a single codebase.
Another n00b question - how do I get the plugin to compile not in DEBUG mode with the debug text in the GUI and plugin name?
You will have to select the Release build somewhere.
captain caveman
12-30-2010, 05:18 AM
Thanks very much indeed for the detailed reply Tale, that was exactly the information I needed. I have to admit that I don't get the syntax used with pointers, for some reason whenever I encounter it in a C++ tutorial my brain freezes over. :)
Thanks again, I'll have a good play around with the functions in that header file to see what it's all about.
captain caveman
12-30-2010, 03:00 PM
Well, I can get a functioning MIDI plugin! :)
The only issue is that I am not using the stuff in IPlugStructs, I am getting the changed MIDI into the stream by doing....
pMsg->mData1 = cc_or_note;
.... in MyPlugin.cpp. I'd rather use the functions etc from the framework to avoid any issues when things get more complicated (and for cross-platform (poss AU)) stuff in future.
What is the syntax I would use in MyPlugin.cpp to make use of (eg)....
void MakeControlChangeMsg(EControlChangeMsg idx, double value);
int Velocity() const;
... from IPlugStructs?
Although using IPlug's functions may improve code readability (and perhaps is less bug-prone), you don't have to use them if you don't want to. Not using them won't necessarily cause cross-platform issues.
What is the syntax I would use in MyPlugin.cpp to make use of (eg)....
void MakeControlChangeMsg(EControlChangeMsg idx, double value);
int Velocity() const;
... from IPlugStructs?
Here is a code snippet that will create and send out a MIDI message to set the modulation wheel (CC#1) to 64:
pMsg->MakeControlChangeMsg(IMidiMsg::kModWheel, 0.504); // 0.504 * 127 =~ 64
SendMidiMsg(pMsg);
Or if you don't want to overwrite the received message you could do:
IMidiMsg MyMsg;
MyMsg.MakeControlChangeMsg(IMidiMsg::kModWheel, 0.504);
SendMidiMsg(&MyMsg);
Velocity() returns the Note On or Off velocity, or -1 if the MIDI message isn't a Note On or Off message:
int velocity = pMsg->Velocity(); // 0..127 (or -1)
captain caveman
12-30-2010, 06:34 PM
That's great Tale, thank you once more for being a true coding wing man with JS and now C++! :)
This will give me lots to play with now, much appreciated!
(poss AU)
Just to let you know MIDI out from AU plugins doesn't work because no hosts seem to support it. Non-IPlug based AU plugins that do MIDI out use the IAC driver - a pretty horrible hack that is not implemented in IPlug. Maybe I'll do it some day... or pay someone else to!
captain caveman
01-01-2011, 06:13 PM
That's good to know, thanks very much for bringing that up.
captain caveman
01-04-2011, 10:06 AM
Rather than polluting the forum with yet another thread, I thought I'd ask this here.
Is there a way to get knobs and faders to snap to the parameters range of values or does that have to be done with multi-images like a switch or with _cc's mod? eg if a parameter goes from 1 to 5 the knob/fader would snap to 5 equally spaced positions instead of smoothly rotating round?
I guess using a 5-frame multi-image would be the easiest solution.
Alternatively you could create a custom control, based on one of the standard knob or fader controls. This is what I did to create an organ drawbar (a 9-step vertical fader).
RRokkenAudio
01-04-2011, 04:41 PM
I usually use a 5 step image. But its a real pain if you want to have 5 knobs with different step positions. I haven't looked into making a custom control, would love to just have a "step" argument.
~Rob.
captain caveman
01-04-2011, 04:57 PM
Thanks for the replies guys.
I came across this utility that could possibly take a lot of the inconvenience away from making multi-stepped knob(/fader) controls.....
http://www.g200kg.com/en/software/knobman.html
..... I haven't tried it in practice though. The thing that concerns me is (eg) that when entering 16 steps it makes 31 frames instead of 16 so I don't know how compatible that would be with IPlug. It's very interesting though and can make multi-layered horizontal/vertical sliders with or without text as well as knobs.
You guys probable know about it though. :)
I do agree Rob that a stepped parameter would make stuff easier for standard faders and knobs.
So Tale, is this custom control in your git? :D
The thing that concerns me is (eg) that when entering 16 steps it makes 31 frames instead of 16 so I don't know how compatible that would be with IPlug. It's very interesting though and can make multi-layered horizontal/vertical sliders with or without text as well as knobs.
KnobMan can output vertical multi-images, so this makes it fully compatible with IPlug. I think you need to change the number of rendered frames in the output image. You will find this setting under Preference (above the layers list). Frames(render) is the one you need to set to 16. (Don't forget to click the Set button after changing it!)
So Tale, is this custom control in your git? :D
Yeah sure. You will find it in IDrawbarControl.h.
olilarkin
01-05-2011, 04:00 AM
i have a control that inherits from IKnobControl and does this to achieve what you want:
bool Draw(IGraphics* pGraphics)
{
int i;
if (mStepped)
{
i = 1 + int(0.5 + mPlug->GetParam(mParamIdx)->GetNormalized() * (double) (mBitmap.N - 1));
i = BOUNDED(i, 1, mBitmap.N);
}
else
{
i = 1 + int(0.5 + mValue * (double) (mBitmap.N - 1));
i = BOUNDED(i, 1, mBitmap.N);
}
pGraphics->DrawBitmap(&mBitmap, &mImgRECT, i, &mBlend);
...
captain caveman
01-05-2011, 06:03 AM
KnobMan can output vertical multi-images, so this makes it fully compatible with IPlug. I think you need to change the number of rendered frames in the output image. You will find this setting under Preference (above the layers list). Frames(render) is the one you need to set to 16. (Don't forget to click the Set button after changing it!)
Ha ha, that was totally invisible to me until you described where it was! :)
Nice one, that's a great tool isn't it? I used IKnobMultiControl with a KnobMan created control for this (note-off catching so not completely crap (edit: that's a lie actually, since changing the array from being global the note-off catching doesn't work)) test plugin....
http://stash.reaper.fm/v/7484/Channelise.dll
Yeah sure. You will find it in IDrawbarControl.h.
He he, I underestimated Git but thanks a lot for the offer of letting me look for it. :)
captain caveman
01-05-2011, 06:21 AM
i have a control that inherits from IKnobControl and does this to achieve what you want:
bool Draw(IGraphics* pGraphics)
{
int i;
if (mStepped)
{
i = 1 + int(0.5 + mPlug->GetParam(mParamIdx)->GetNormalized() * (double) (mBitmap.N - 1));
i = BOUNDED(i, 1, mBitmap.N);
}
else
{
i = 1 + int(0.5 + mValue * (double) (mBitmap.N - 1));
i = BOUNDED(i, 1, mBitmap.N);
}
pGraphics->DrawBitmap(&mBitmap, &mImgRECT, i, &mBlend);
...
Thanks a lot for posting this. How would I use implement this though, I still haven't deciphered what to do with functions that have this pointer stuff as the parameter(s) to pass to it?
Cheers man.
RRokkenAudio
01-05-2011, 04:18 PM
ahhh thanks for the control olilarkin.. Yeah been using knobman since it came out, Pretty sure mostly everyone uses it, best there is.....
~Rob.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.