Use FMOD Scripting to duplicate a set of global parameters

We have a collection of global parameters that we use on a regular basis to create audio logic internally to FMOD Studio. The parameter values/settings are all the same, but we need to duplicate them in order to give them different names.

Is there a duplicate parameter function inside the FMOD Studio scripting library? I’ve looked, but I’m not seeing anything off hand.

Hi,

The following code will let you duplicate a parameter on an event and give it a new name:

Duplicate Paramter
studio.menu.addMenuItem({
    name: "Duplicate parameter",
    execute: function() { DuplicateSelectedParam(); }
})

function DuplicateSelectedParam() {
    var event = studio.window.browserCurrent();
    var paramIndex = studio.system.getText("Index: ", "index");
    var proxy = event.parameters[paramIndex];
    var copy = event.addGameParameter(proxy);
    var preset = copy.preset; 
    var owner = preset.presetOwner; 
    owner.name = studio.system.getText("Duplicate Name: ", "Name");
}

It is also possible to duplicate parameters in the Preset Browser window:
image
Right-click on the desired parameter and select duplicate:


So there are a couple of ways to duplicate parameters.

Hope this helps!

Thanks Conner! We have need to do a big batch duplication with auto-renaming, so the scriptable version is our desired method! I’ll be looking into whether or not extrapolating from your script will be the best course or if we need to consider creating the parameters from scratch.

Unfortunately, the paramIndex variable is returning Undefined and causing a script error. The values I’m inputing for the “Index” getText() must be incorrect. Can you clarify what that value is meant to be?

I see, would you be duplicating multiple parameters at once or one at a time? I may be able to rework the code with a bit more info.

The index is which parameter you would like to duplicate on the event. But that may not work for your situation.

Hey Connor! We would be duplicating a batch of them at the same time. Based on your script example and some of the existing scripts inside the FMOD Studio package contents, I was able to create this (messy) script. It allows us to duplicate the parameters selected from the Presets browser and automatically set up the parameter automation we need certain parameters to have.

The input values are being managed by the showModalDialog() UI function (not shown in the code below). I think this direction will work after cleaning it up a bit. The requirements of the duplication/parameters has expanded a bit and we should be able to grow it from here!

Thanks for all your help and let me know if you have any questions or suggestions!

Cheers mate!

 
var allParameters = studio.window.browserSelection();
var reelStopParametersArray = [];

function CreateParameters(widget, isReadyToCreate)
        {
            
            var markerNameGlobal = widget.findWidget("markerName").text();
            var willCountAllMarkers = widget.findWidget("countEachSymbol").isChecked();

            if (!willCountAllMarkers)
            {
                markerValueGlobal = 1;
            }
            else
            {
                var markerValueGlobal = widget.findWidget("markerCount").value();
            }
            
            if (isReadyToCreate)
            {
                for (i = 0; i < allParameters.length; i++)
                {
                    if (allParameters[i].name.match("_marker"))
                    {
                        var reelMarkerParameter = studio.project.workspace.addGameParameter({
                            name: allParameters[i].name.replace("PLACEHOLDER", markerNameGlobal.toLowerCase()),
                            type: allParameters[i].parameter.parameterType,
                        });
                        
                        reelMarkerParameter.minimum = 0,
                        reelMarkerParameter.maximum = markerValueGlobal + 1,
                        reelMarkerParameter.isGlobal = allParameters[i].parameter.isGlobal;
                        reelStopParametersArray.push(reelMarkerParameter);
                    }
                }
                
                for (i = 0; i < allParameters.length; i++)
                {
                    if (allParameters[i].name.match("Counter"))
                    {
                        var paramName = "";
                        var counterParameter = studio.project.workspace.addGameParameter({
                            name: paramName = allParameters[i].name.replace("PLACEHOLDER", markerNameGlobal.toUpperCase()),
                            type: allParameters[i].parameter.parameterType,
                        });
                    
                        var paramAutomator = counterParameter.addAutomator("cursorPosition");
        
                        var automationListArray = []
        
                        if (paramName.match("0"))
                            automationListArray.push(0);
                        if (paramName.match("1"))
                            automationListArray.push(1);
                        if (paramName.match("2"))
                            automationListArray.push(2);
                        if (paramName.match("3"))
                            automationListArray.push(3);
                        if (paramName.match("4"))
                            automationListArray.push(4);
        
                        counterParameter.minimum = 0;
                        counterParameter.maximum = (automationListArray.length * markerValueGlobal) + 1;
        
                        counterParameter.isGlobal = allParameters[i].parameter.isGlobal;
                        
                        for (j = 0; j < automationListArray.length; j++)
                        {
                            var currentMarker = reelStopParametersArray[automationListArray[j]];
                            var automationCurve = paramAutomator.addAutomationCurve(currentMarker);
        
                            var parameterIncreaseAmount = automationListArray.length;
        
                            for (k = 0; k < currentMarker.maximum; k++)
                            {
                                automationCurve.addAutomationPoint(k, parameterIncreaseAmount * k);
                            }
                        }
                    }
                }
            }
        }```

Thank you for sharing your code! It looks good and works well, nothing I can add!

If you have any more questions please let us know!