Script to place assets

For a project I am trying to place around 100 assets (already imported to project) on a discrete parameter sheet and match the filename with the value of the parameter. Very similar to the Unity Piano FMOD example.

The parameter goes from 0-100, the filenames contain a number at the end of the file, think: sound_01.wav, sound_02.wav etc. After the script is run the file sound_01.wav should be place at parameter value 1, the sound_02.wav at parameter value 2 etc.

Could someone from FMOD team help me with a script to make this happen?
That would be amazing!

Does someone from he FMOD team have an idea for this? Thanks a lot!


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{
    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
            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 () {

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.

Thanks so much! I had to simplify my naming, but this works! Awesome!

1 Like