COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 03-08-2009, 05:12 AM   #1
Andrew J
Human being with feelings
 
Join Date: Mar 2009
Posts: 11
Default Bitmap strip knob control for IPlug

Someone shoot me if it's already in there, but I couldn't find a bitmap strip style knob control in IPlug (wdl_20090118). So I knocked one up by adding the following to IControl.h:

Code:
// A bitmap strip knob - Andrew J, 8-Mar-2009
class IKnobBitmapStripControl : public IKnobControl
{
public:

	IKnobBitmapStripControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap,
		double minAngle = -0.75 * PI, double maxAngle = 0.75 * PI, 
		EDirection direction = kVertical, double gearing = DEFAULT_GEARING)
	:	IKnobControl(pPlug, &IRECT(x, y, pBitmap), paramIdx, direction, gearing), 
		mBitmap(*pBitmap), mMinAngle(minAngle), mMaxAngle(maxAngle) {}
	~IKnobBitmapStripControl() {}

	bool Draw(IGraphics* pGraphics);

private:
	IBitmap mBitmap;
	double mMinAngle, mMaxAngle;
};
And to IControl.cpp:

Code:
// A bitmap strip knob - Andrew J, 8-Mar-2009
// Assumes that bitmap strip goes from top to bottom, starts at South and goes clockwise 360deg
bool IKnobBitmapStripControl::Draw(IGraphics* pGraphics)
{
    int i = 1;
    if (mBitmap.N > 1) {
		double angle = mMinAngle + mValue * (mMaxAngle - mMinAngle);
		i = 1 + int(0.5 + (double) ((mBitmap.N - 1)/2 * (1 + angle/PI)));
	    i = BOUNDED(i, 1, mBitmap.N);
    }
    return pGraphics->DrawBitmap(&mBitmap, &mRECT, i, &mBlend);
}
Not thoroughly tested, but seems to work fine for me...

-Andrew
Andrew J is offline   Reply With Quote
Old 03-09-2009, 12:09 AM   #2
bvesco
Human being with feelings
 
bvesco's Avatar
 
Join Date: Jun 2007
Posts: 125
Default

You must have overlooked the IKnobMultiControl!

Code:
    IBitmap bitmap = pGraphics->LoadIBitmap(KNOB_ID, KNOB_IMG, KNOB_FRAMES);
    int knobIndex = pGraphics->AttachControl(new IKnobMultiControl(this, knobX, knobY, paramIdx, &bitmap));
__________________
Audio tutorials and articles: http://www.benvesco.com/tonemonster/
My VST plugins: http://www.vescofx.com/
bvesco is offline   Reply With Quote
Old 03-09-2009, 12:49 AM   #3
Andrew J
Human being with feelings
 
Join Date: Mar 2009
Posts: 11
Default

Quote:
Originally Posted by bvesco View Post
You must have overlooked the IKnobMultiControl!
I actually tried that first but didn't get it to work - must look again when I'm feeling less stupid.

Where's a good blush smilie when you need one? Ah, right there...

Last edited by Andrew J; 03-09-2009 at 12:56 AM.
Andrew J is offline   Reply With Quote
Old 03-09-2009, 12:56 AM   #4
Andrew J
Human being with feelings
 
Join Date: Mar 2009
Posts: 11
Default

Actually, just looked again. The difference is that the multi control doesn't map the knob angle to the bitmap index for you. IKnobBitmapStripControl takes care of that all by itself.
Andrew J is offline   Reply With Quote
Old 03-10-2009, 08:46 AM   #5
bvesco
Human being with feelings
 
bvesco's Avatar
 
Join Date: Jun 2007
Posts: 125
Default

It's not supposed to map angle to the bitmap. It is supposed to map your parameter value to the bitmap. You set the value normalized from [0.0, 1.0] and it calculates the knob position from that value. So 0.0 is the first frame, 1.0 is the last frame, 0.5 is the "middle" frame and everything else in between. Maybe you have your parameters defined incorrectly?
__________________
Audio tutorials and articles: http://www.benvesco.com/tonemonster/
My VST plugins: http://www.vescofx.com/
bvesco is offline   Reply With Quote
Old 03-10-2009, 08:46 AM   #6
bvesco
Human being with feelings
 
bvesco's Avatar
 
Join Date: Jun 2007
Posts: 125
Default

Oh, also check out http://www.plugindeveloper.com/ for some other IPlug related stuff that might help out.
__________________
Audio tutorials and articles: http://www.benvesco.com/tonemonster/
My VST plugins: http://www.vescofx.com/
bvesco is offline   Reply With Quote
Old 03-11-2009, 03:23 AM   #7
Andrew J
Human being with feelings
 
Join Date: Mar 2009
Posts: 11
Default

Thanks Ben, I had already found that and registered. Some handy stuff there so far...
Andrew J 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 06:28 AM.


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