Editing compression settings via script

Is there a way to script changing compression settings on individual waves via FmodScript?


I create a script to attach a new Encoding Settings to a wav file

Studio Script
    name: "Custom Scripts\\Change Enccoding",
    execute: function() {
        var audioFilesArr = studio.window.browserSelection();
        var platform = studio.project.workspace.projectSettings.activePlatform;

        if (audioFilesArr.lenth != 0)
            if (audioFilesArr[0].isOfType("AudioFile"))
                for (var i = 0; i < audioFilesArr.length; i++)
                    var encodingValue = studio.system.getNumber("Set Encoding Setting for: " + audioFilesArr[i].assetPath + " Options 0 - 3","0");
                    var settings = studio.project.create("EncodingSetting");
                    settings.platform = platform;
                    settings.encodable = audioFilesArr[i];
                    settings.encodingFormat = encodingValue;
                    if (settings.isValid)
                alert("Please select audio file(s)");

This will give you access to all the settings variables, which you can change as needed.

Let me know if this is the functionality you are looking for.

Thanks! This is great :slight_smile: But if I already have an encoding setting for that audio file, this script creates another encoding settings xml and then I have two conflicting encoding settings for the same audio file in the Metadata/EncodingSetting folder. Is it possible to grab a previously existing setting for that audio file if it exists?

Edit: Oh maybe I need to iterate through the event’s relationships.encodingSettings.

Ok I was able to get what I needed by parsing through audioFile.relationships.encodingSettings.destinations and looking for the right platform. If I didn’t find the platform encoding settings I would create a new encoderSetting as you did, except I grab the defaults from platform.encodingSettings. I can look up specific waves using studio.project.lookup(“asset:/phoo.wav”) so I should now be able to batch up some sample rate changes!

1 Like