MATLAB Examples

Investigate Parameter/Property Mapping

Parameter display values are related to normalized parameter values by unknown mapping rules internal to the plugin. You can investigate the relationship between the normalized parameter values and the displayed values by creating a sweeping function. You can use the sweeping function to map parameter values to their displayed output.

The properties display mode of hosted plugins uses a similar approach to enable you to interact directly with the real-world (displayed) values, instead of the normalized parameter values.

Save the displayParameterMapping function in your current folder. This function performs a simplified version of the parameter sweeping used to create the property display mode for hosted plugins.

function displayParameterMapping(hPlugin,prmIndx)
x = 0:0.001:1; % Normalized parameter range

[~,prmInfo] = getParameter(hPlugin,prmIndx);
if isnan(str2double(prmInfo.DisplayValue))
    % Non-Numeric Displays - prints normalized parameter range associated
    % with string
    setParameter(hPlugin,prmIndx,0);
    [~,prmInfo] = getParameter(hPlugin,prmIndx);
    txtOld = prmInfo.DisplayValue;
    oldIndx = 1;
    
    for i = 2:numel(x)
        setParameter(hPlugin,prmIndx,x(i))
        [~,prmInfo] = getParameter(hPlugin,prmIndx);
        txtNew = prmInfo.DisplayValue;
        if ~strcmp(txtNew,txtOld)
            fprintf('%s: %g - %g\n',txtOld, x(oldIndx),x(i-1));
            oldIndx = i;
            txtOld = txtNew;
        end
    end
    fprintf('%s: %g - %g\n',txtOld, x(oldIndx),x(i));
else
    % Numeric Displays - plots normalized parameter value against displayed
    % parameter value
    y = zeros(numel(x),1);
    for i = 1:numel(x)
        setParameter(hPlugin,prmIndx,x(i))
        [~,prmInfo] = getParameter(hPlugin,prmIndx);
        y(i) = str2double(prmInfo.DisplayValue);
    end
    if any(isnan(y))
        warning('NaN detected in numeric display.')
    end
    plot(x,y)
    xlabel('Normalized Parameter Value')
    ylabel(['Displayed Parameter Value (',prmInfo.Label,')'])
    title(prmInfo.DisplayName)   
end

end

Load the readelay-standalone.dll plugin into MATLAB®. Call the displayParameterMapping function with the hosted plugin and a parameter index.

hostedPlugin = loadAudioPlugin('readelay-standalone.dll');
displayParameterMapping(hostedPlugin,1);

If you use the displayParameterMapping function with a nonnumeric parameter, the relationship displays in the Command Window:

displayParameterMapping(hostedPlugin,3)
OFF: 0 - 0.499
ON: 0.5 - 1