COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 12-29-2010, 09:31 AM   #1
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default IPlug - any example simple MIDI plugins?

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?

Last edited by captain caveman; 12-29-2010 at 04:56 PM.
captain caveman is offline   Reply With Quote
Old 12-30-2010, 02:00 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

Quote:
Originally Posted by captain caveman View Post
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:
Code:
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.

Quote:
Originally Posted by captain caveman View Post
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.

Quote:
Originally Posted by captain caveman View Post
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.
Tale is offline   Reply With Quote
Old 12-30-2010, 05:18 AM   #3
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

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 is offline   Reply With Quote
Old 12-30-2010, 03:00 PM   #4
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

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....
Code:
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)....
Code:
void MakeControlChangeMsg(EControlChangeMsg idx, double value);   
int Velocity() const;
... from IPlugStructs?
captain caveman is offline   Reply With Quote
Old 12-30-2010, 04:04 PM   #5
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

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.

Quote:
Originally Posted by captain caveman View Post
What is the syntax I would use in MyPlugin.cpp to make use of (eg)....
Code:
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:

Code:
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:

Code:
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:

Code:
int velocity = pMsg->Velocity(); // 0..127 (or -1)
Tale is offline   Reply With Quote
Old 12-30-2010, 06:34 PM   #6
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

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!
captain caveman is offline   Reply With Quote
Old 12-31-2010, 12:04 PM   #7
cc_
Human being with feelings
 
Join Date: Mar 2009
Posts: 256
Default

Quote:
Originally Posted by captain caveman View Post
(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!
cc_ is offline   Reply With Quote
Old 01-01-2011, 06:13 PM   #8
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

That's good to know, thanks very much for bringing that up.
captain caveman is offline   Reply With Quote
Old 01-04-2011, 10:06 AM   #9
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

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?
captain caveman is offline   Reply With Quote
Old 01-04-2011, 03:48 PM   #10
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

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).
Tale is offline   Reply With Quote
Old 01-04-2011, 04:41 PM   #11
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

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.
RRokkenAudio is offline   Reply With Quote
Old 01-04-2011, 04:57 PM   #12
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

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?
captain caveman is offline   Reply With Quote
Old 01-05-2011, 01:46 AM   #13
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

Quote:
Originally Posted by captain caveman View Post
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!)

Quote:
Originally Posted by captain caveman View Post
So Tale, is this custom control in your git?
Yeah sure. You will find it in IDrawbarControl.h.
Tale is offline   Reply With Quote
Old 01-05-2011, 04:00 AM   #14
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

i have a control that inherits from IKnobControl and does this to achieve what you want:
Code:
	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);

...
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 01-05-2011, 06:03 AM   #15
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

Quote:
Originally Posted by Tale View Post
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....
https://stash.reaper.fm/v/7484/Channelise.dll

Quote:
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.

Last edited by captain caveman; 01-05-2011 at 03:43 PM.
captain caveman is offline   Reply With Quote
Old 01-05-2011, 06:21 AM   #16
captain caveman
Human being with feelings
 
Join Date: Feb 2008
Posts: 1,616
Default

Quote:
Originally Posted by olilarkin View Post
i have a control that inherits from IKnobControl and does this to achieve what you want:
Code:
	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.
captain caveman is offline   Reply With Quote
Old 01-05-2011, 04:18 PM   #17
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

ahhh thanks for the control olilarkin.. Yeah been using knobman since it came out, Pretty sure mostly everyone uses it, best there is.....

~Rob.
RRokkenAudio is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.