Thread: AAX and knobs
View Single Post
Old 11-16-2017, 04:33 PM   #27
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 315
Default

Around line 267 in IPlugAXX.cpp is the following:
Code:
    if (GetGUI())
    {
      GetGUI()->SetParameterFromPlug(paramIdx, iValue, true);
    }
I commented this out and it helps. I have been updating to the latest Youlean code, so I haven't gotten to fully test AAX yet.

I also overrode OnMouseUp, OnMouseDown, OnMouseWheel, and OnMouseDrag for my switch control. I made the switch change only when the OnMouseUp happens, the control is dragged, or the wheel is used. I use a simple bool (isMouseClick) to prevent the control from firing twice with drags. I also have some switches that work reverse and/or horizontal, so that is the other junk in there.

This is what I am using for a few of my switches.
Code:
              LVC_Switch::LVC_Switch(IPlugBase * pPlug, int L, int T, int paramIdx, IBitmap * pBitmap, bool isreverse, bool isvertical, IChannelBlend::EBlendMethod blendMethod)
                    : ISwitchControl(pPlug, L, T, paramIdx, pBitmap, blendMethod)
                {
                    isReverse = isreverse;
                    isVertical = isvertical;
                    mValue = GetParam()->GetNormalized();
                    isMouseClick = false;
                }

                bool LVC_Switch::Draw(IGraphics* pGraphics) {
                    int i = 1;
                    if (mBitmap->N > 1)
                    {
                        i = 1 + int(0.5 + mValue * (double)(mBitmap->N - 1));
                        i = BOUNDED(i, 1, mBitmap->N);
                    }

                    return pGraphics->DrawBitmap(mBitmap, &mDrawRECT, i, &mBlend);
                }
                void LVC_Switch::OnMouseWheel(int x, int y, IMouseMod * pMod, int d)
                {
                    isMouseClick = false;
                    if (isReverse) d = -d;
                    mValue += (double)BOUNDED(d, -1., 1.) / (double)(mBitmap->N - 1);
                    SetDirty();
                }

                void LVC_Switch::OnMouseDrag(int x, int y, int dX, int dY, IMouseMod * pMod)
                {
                    isMouseClick = false;
                    if (!isVertical) {
                        if (!isReverse) dY = -dY;
                        mValue += (double)BOUNDED(dY * 0.025, -1., 1.) / (double)(mBitmap->N - 1);
                    }
                    else {
                        if (isReverse) dX = -dX;
                        mValue += (double)BOUNDED(dX * 0.025, -1., 1.) / (double)(mBitmap->N - 1);
                    }
                    SetDirty();
                }

                void LVC_Switch::OnMouseUp(int x, int y, IMouseMod * pMod)
                {
                    if (isMouseClick) {
                        {
                            if (mBitmap->N > 1)
                            {
                                mValue += 1.0 / (double)(mBitmap->N - 1);
                            }
                            else
                            {
                                mValue += 1.0;
                            }

                            if (mValue > 1.001)
                            {
                                mValue = 0.0;
                            }
                            SetDirty();
                        }
                    }
                    isMouseClick = false;
                }

                void LVC_Switch::OnMouseDown(int x, int y, IMouseMod * pMod)
                {
                    isMouseClick = true;
                }
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote