View Single Post
Old 01-28-2010, 07:36 PM   #32
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

While doing some VST hosting experiments, I came up with something like this :

Code:
if (m_aeffect)
        {
            m_vstParamIndex=paramIndex;
            char paramDisplay[256] = {0};

            m_aeffect->dispatcher (m_aeffect, effGetParamDisplay, m_vstParamIndex, 0, paramDisplay, 0);
            if (m_paramValueLabel)
                m_paramValueLabel->setText(paramDisplay);
            // store current param value from plugin
            qreal val=m_aeffect->getParameter(m_aeffect,m_vstParamIndex);
            m_vstParamMapping.clear();
            for (int i=0;i<1000;i++)
            {
                qreal normalizedVal=1.0/999.0*i;
                m_aeffect->setParameter(m_aeffect,m_vstParamIndex,normalizedVal);
                m_aeffect->dispatcher (m_aeffect, effGetParamDisplay, m_vstParamIndex, 0, paramDisplay, 0);
                QString dispStr(paramDisplay);
                // we hope dividing the parameter display string by spaces mostly works
                QStringList sl=dispStr.split(" ");
                bool ok;
                for (int j=0;j<sl.size();j++)
                {
                    qreal value=sl[j].toDouble(&ok);
                    if (ok)
                    {
                        m_vstParamMapping.append(QPair<qreal,qreal>(normalizedVal,value));
                        // if the first valid number found isn't the correct one,
                        // there's hardly any point in finding more numbers, we could not
                        // decide anyway (easily) what is the correct one
                        // perhaps could scan for only changing number elements in the string, though
                        
                        break;
                    }

                }
            }
            qDebug() << m_vstParamMapping;
            qDebug() << "vst param"<<m_vstParamIndex<<"produced"<<m_vstParamMapping.size()<<"scaled values";
            // restore param in plugin
            m_aeffect->setParameter(m_aeffect,m_vstParamIndex,val);

        }
This needs to be done for each parameter in the VST plugin. The current code can completely fail if the parameter strings outputted by the plugin are not suitable. However, the string scanning code could of course be refined further. This could potentially cost a lot of memory per plugin too. Think of a plugin that has 10000 parameters. Each will be scanned for 1000 values which might all end up in the tables. edit : Still, this would be more memory efficient in many cases than storing all 1000 values as text strings, assuming the strings would on average be longer in memory than 2 floating point values. Obvious downside with this approach is that the plugin parameter unit names are not displayable.

edit : Anyway, I just posted this here to demonstrate the somewhat involved nature of the problem. (Not suggesting Cockos to use something like the above code to hack around the problem with usual VST plugins! )

Cockos VST extensions by the way work great for envelope tooltips and such! I only wish more developers besides Loser and Voxengo would support it...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 01-29-2010 at 03:54 AM.
Xenakios is offline   Reply With Quote