Script to place assets

Hi,

I have created a script that will allow you to assign multiple sound files based on numerical digits within each file’s name and corresponding parameter value numbers.

Assign Multiple Assets Script
studio.menu.addMenuItem({
    name: "User Scripts ...\\ Assign Assets",

    execute: function () {
        function assignAssets(widget) {
            selectedEvent = studio.project.lookup(widget.findWidget("m_EventPathText").text()) //Assign the event's file path for later
            parm = selectedEvent.parameters[parseInt(widget.findWidget("m_EventParmNum").text(), 10)] //Retrieve the event parameter that you want to assign the audio files to
            audioFilesArr = studio.window.browserSelection() //Retrieve the currently selected audio files

            //Loop through the array
            audioFilesArr.forEach(function(file, index) {
                if (file.isOfType("AudioFile")) {
                result = audioFilesArr[index].assetPath.match(/\d+/) //Pick out the digit from the file string
                number = parseInt(result[0], 10) //Convert the result to an int value

                newInstrument = selectedEvent.groupTracks[0].addSound(parm, 'SingleSound', number, 1) //Create a single instrument on parameter's sheet, matching the file name digit and parameter value
                newInstrument.audioFile = file //Assign the matching audio file to the single instrument
                }
            });
        }

        //widget UI design
        studio.ui.showModalDialog({
            windowTitle: "Assign Multiple Assets To First Parameter Sheet",
            windowWidth: 180,
            windowHeight: 150,
            widgetType: studio.ui.widgetType.Layout,
            layout: studio.ui.layoutType.VBoxLayout,
            items: [
                { widgetType: studio.ui.widgetType.Label, widgetId: "m_EventPathLabel", text: "EventPath :" },
                {
                    widgetType: studio.ui.widgetType.LineEdit,
                    widgetId: "m_EventPathText",
                    text: "",
                    onTextEdited: function () { },
                },
                { widgetType: studio.ui.widgetType.Label, widgetId: "m_EventParmLabel", text: "Parameter Number :" },
                {
                    widgetType: studio.ui.widgetType.LineEdit,
                    widgetId: "m_EventParmNum",
                    text: "",
                    onTextEdited: function () { },
                },
                {
                    widgetType: studio.ui.widgetType.PushButton,
                    text: "Apply",
                    onClicked: function () {
                        assignAssets(this);
                        this.closeDialog();
                    }
                },
            ],
        });
    }
});

Please follow these steps to use the script, also note that I haven’t put much error handling within the code.

  1. Add the script to the local APP directory so it is available in all FMOD versions: C:\Users\YourUserName\AppData\Local\FMOD Studio\Scripts

  2. Then in FMOD Studio, create an event and add a discrete parameter sheet to it.

  3. Right click on the event and copy the file path for later use by selecting Copy Path

  4. Open the Assets browser and select all target sound files.

  5. Reload and run the script with the Asset browser opened and audio files selected.

  6. Input the file path you just copied and the index of the parameter sheet, hit Apply

For more information, you could also take a look at a similar post which I will link it here:

Let me know if you have any questions, and please feel free to modify the script according to your needs.