RomanKubiak / ctrlr

Ctrlr
BSD 3-Clause "New" or "Revised" License
500 stars 58 forks source link

Plenty of undefined values on my VST2 export #654

Closed dervur closed 2 weeks ago

dervur commented 4 weeks ago

Hello there,

Is it normal that there are plenty of undefined values as the controllable values for automation in Cubase? I only have one knob in the project, but I can see 64 parameters (the list of undefined goes up to 63, plus the actual knob with its name).

image

Just to specify this is on the restricted export version of the dll, I was just doing some tests with only one knob because I had the same issue on another project and I can't understand if it has something to do with the settings I have or not. Because I changed the VST index in order to have the order as I want it. But I noticed that if I just copy paste the knob on a new project the default VST index is 57, so I don't know if this is the issue.

damiensellier commented 3 weeks ago

Not sure if it's going to work but there's a general property called "max Exported VST Parameters" in the Ctrlr Preferences. Try if you could change it to 1.

Capture d’écran, le 2024-06-27 à 14 16 51

dervur commented 3 weeks ago

Mmmh I will try that, I have to say though that I left that unchanged and once I added more than 64 parameters I found myself with all the parameters (around 160), the only unassigned left was the 0 one because I began from VST index 1, but that's fixable, easily but will take me long since I have to do them one by one...

damiensellier commented 3 weeks ago

SEE : https://forums.steinberg.net/t/vst-index-for-parameters-starts-at-0-or-1/833462

dervur commented 3 weeks ago

Uh, that's weird lol, good I distributed my VST2 in a few forums with nothing assigned at index 0 then... I'll try tomorrow for the other unassigned values and in case I'll mark this issue as solved.

dobo365 commented 3 weeks ago

Indeed, you need to adapt your Export flag and renumber components according to the order you want to see them in the DAW. If we assign from 1 then 0 may be listed as "undefined" if the DAW lists from index 0. Not a real issue, imho If you assign 3000 to 4000 then you will get 2999 undefined.

damiensellier commented 3 weeks ago

I just checked and the index starts at 0 for vstindex 0, It was my mistake to start my index from 1 this is why I had undefined_0 on index 0: Capture d’écran, le 2024-06-28 à 12 21 37

Capture d’écran, le 2024-06-28 à 11 58 40

If you need to reassign all your modulator vstindex just use the modulator list or copy paste the xml file of your panel and ask gemini or chatGPT to decrease the value of vstindex by 1.

dervur commented 2 weeks ago

Not sure if it's going to work but there's a general property called "max Exported VST Parameters" in the Ctrlr Preferences. Try if you could change it to 1.

Capture d’écran, le 2024-06-27 à 14 16 51

It seems that this value is available only in the settings of the .exe but not the .dll If I change it in the exe, close Ctrlr and reopen it, it seems that the value remains saved. However, if I open the dll and export my restricted instance, the VST still has plenty of unassigned values. If I then open the exe of Ctrlr, that value went back to 64. Therefore not only the dll does not have that value, it also seems to reset it to its default 64... Is there something I'm missing or is it a bug?

damiensellier commented 2 weeks ago

It's probably a bug. I don't really know how this parameter is supposed to work, especially when it needs to pass the modulators as parameters to the Host in VST. I'll check that, I'm pretty sure there's a way to iterate through all the modulators and have only the required amount of parameters fixed to the vstindex max value.

dobo365 commented 2 weeks ago

Sorry but I don't understand the issue... even if there is maybe a bug with max exported parameters.

I mean: you have a way to control what parameters to export or not and you have a way to sort them as you want by using the VST index (I'm sorting / renumbering them with the Modulator list). So, what do you want more? If using max exported parameters, it could be that you are setting some parameters to be exported but that at the end they will not be in the export because you set a limit. Seems more a problem than a benefit.

Is it something I missed or that I don't understand?

dervur commented 2 weeks ago

Sorry but I don't understand the issue... even if there is maybe a bug with max exported parameters.

I mean: you have a way to control what parameters to export or not and you have a way to sort them as you want by using the VST index (I'm sorting / renumbering them with the Modulator list). So, what do you want more? If using max exported parameters, it could be that you are setting some parameters to be exported but that at the end they will not be in the export because you set a limit. Seems more a problem than a benefit.

Is it something I missed or that I don't understand?

Hi, I know that. But if you see in my post I only have one modulator, assigned to index 0 and allowed to be exported as VST… I still have 63 unassigned values exported. So it clearly does not export only the one you ask to, but it also exports a bunch of useless values. I mean it is not a problem per se, automating those unassigned values would do nothing, it is more of a “it would be nice to have in the list of values of the VST only the ones I exported and not a bunch of useless ones too”

Besides, the maximum parameters which is by default 64 does not work anyway because I managed to export a panel with 170+ modulators just fine. Therefore it seems that maximum value is really a minimum value of exported parameters because if less than 64, you will have 64 in the output in total, if more than 64 they will export all the ones you have (i.e., more than 64).

damiensellier commented 2 weeks ago

I think I know why the parameter "Max exported VST params" ctrlrMaxExportedVstParameters doesn't work properly. It's a Ctrlr preference not a panel one. If you export a panel as vst restricted instance, from the function getNumModulators() the highest vstindex should set the limit. But it's not if the vstindex highest number is above 64. From what I can see, it falls back to the default settings from global Ctrlr preferences (64) :

overridesTree.setProperty (Ids::ctrlrMaxExportedVstParameters, 64, 0);

int CtrlrProcessor::getNumParameters()
{
    if (ctrlrManager)
        return (jmax(ctrlrManager->getNumModulators(true), (int)overridesTree.getProperty (Ids::ctrlrMaxExportedVstParameters)));
    else
        return (CTRLR_DEFAULT_PARAMETER_COUNT);
}

CtrlrMacros.h

#define CTRLR_DEFAULT_PARAMETER_COUNT 128

int CtrlrManager::getNumModulators(const bool onlyVstParameters)
{
    if (onlyVstParameters)
    {
        if (ctrlrManagerVst.get())
            return (ctrlrManagerVst->getLargestIndex() + 1);
        else
            return (CTRLR_DEFAULT_PARAMETER_COUNT);
    }
    else
    {
        return (ctrlrModulators.size() + 1);
    }
}

I think the ctrlrMaxExportedVstParameters parameter is useless and should be removed unless it is declared at the panel level.

To confirm, can you please check if you have 64 or 128 paramaters in Cubase?

damiensellier commented 2 weeks ago

PS : Cubase shows 64 parameters anyway 0 to 63

Capture d’écran, le 2024-07-03 à 14 33 00

damiensellier commented 2 weeks ago

It can't work because it uses the comparator jmax which is supposed to return the highest value between the highest vstindex and the default 64. if you have 4 parameters, 4 < 64 so the number of controlled passed to the host will be 64 anyway.

int CtrlrProcessor::getNumParameters()
{
    if (ctrlrManager)
        // return (jmax(ctrlrManager->getNumModulators(true), (int)overridesTree.getProperty (Ids::ctrlrMaxExportedVstParameters)));
        return (jmax(ctrlrManager->getNumModulators(true), (int)overridesTree.getProperty (Ids::ctrlrMaxExportedVstParameters)));
    else
        return (CTRLR_DEFAULT_PARAMETER_COUNT);
}

We don't need jmax, but we need jmin

/** Returns the larger of two values. */
template <typename Type>
constexpr Type jmax (Type a, Type b)                                   { return a < b ? b : a; }

i'll try with jmin and see if it works...

damiensellier commented 2 weeks ago

or even without comparator and just get the max vstindex value :

int CtrlrProcessor::getNumParameters()
{
    if (ctrlrManager)
        // return (jmax(ctrlrManager->getNumModulators(true), (int)overridesTree.getProperty (Ids::ctrlrMaxExportedVstParameters)));
        return (ctrlrManager->getNumModulators(true)); // Updated v5.6.31.
    else
        return (CTRLR_DEFAULT_PARAMETER_COUNT);
}
dervur commented 2 weeks ago

I think just using the maximum vstindex value is the most reasonable thing, and that, as you said before ctrlrMaxExportedVstParameters should be deleted. It just makes everything confusing in my opinion and it does not make sense to me that someone would want to export less values than what they actually created (and surely they do not want more).

I'll try to build a version tomorrow with the code in your last comment to see if it works as expected. I'll write a comment tomorrow to say what is the outcome.

damiensellier commented 2 weeks ago

@dervur it will work well for exported instance if you set everything properly beforehand. but it won't work as intended if you just load panel files in your ctrlr.vst. Up to you...

damiensellier commented 2 weeks ago

I'll try that, to make everybody happy :) :

int CtrlrProcessor::getNumParameters()
{
    if (ctrlrManager)
        if (ctrlrManager->isSingleInstance())
        {
            return (ctrlrManager->getNumModulators(true)); // Added v5.6.31.
        }
        else
        {
        return (jmax(ctrlrManager->getNumModulators(true), (int)overridesTree.getProperty (Ids::ctrlrMaxExportedVstParameters))); // updated 5.6.31 because VST Host was returning 64 params most of the time since panels hardly have more than 64 parameters passed as vst controls
        }
    else
        return (CTRLR_DEFAULT_PARAMETER_COUNT);
}
dervur commented 2 weeks ago

@dervur it will work well for exported instance if you set everything properly beforehand. but it won't work as intended if you just load panel files in your ctrlr.vst. Up to you...

Yeah that is my plan, I do not really care for the VST Ctrlr, I use that only to export instances, I do not edit or use hardware from there anyway

damiensellier commented 2 weeks ago

FIXED I got it working with the following statement :

int CtrlrProcessor::getNumParameters() // Updated 5.6.31
{
    if (ctrlrManager)
        if (ctrlrManager->isSingleInstance())
        {
            return (ctrlrManager->getNumModulators(true)); // Added v5.6.31. 
        }
        else
        {
        return (jmax(ctrlrManager->getNumModulators(true), (int)overridesTree.getProperty (Ids::ctrlrMaxExportedVstParameters))); // Updated 5.6.31.
        }
    else
        return (CTRLR_DEFAULT_PARAMETER_COUNT);
}

When opening a panel in ctrlrx.vst we have 64 parameters ready to go as default :

Capture d’écran, le 2024-07-03 à 16 16 15

When using a panel as vst instance we only have the max vstindex number of parameters passed to the host (here 4): Capture d’écran, le 2024-07-03 à 16 18 52

Hope it helps. Damien

dervur commented 2 weeks ago

Amazing! Thank you so much!

damiensellier commented 2 weeks ago

Thanks, I prefer this way too, I don't have 10 pages of useless parameters on my MIDI MCU controller now. that's cleaner.

Capture d’écran, le 2024-07-03 à 16 32 14

VS

Capture d’écran, le 2024-07-03 à 16 31 01