Query: total length of all used audio assets

As a part of our game project’s certification for Sony they want to know how much (in total length) of which audio codec(s) are used in the game’s assets.

Is there a way to query the Asset Bin so that you could get the total length of all the used (and only used) audio assets in the project?


Hi Peter,

You can use the following code to get the length of all used audio files in your FMOD Studio project.

    var allAssets = studio.project.model.AudioFile.findInstances();
    var totalLength = 0.00;

    allAssets.forEach(function (asset) {
        // All assets have an empty array for sounds, 
        // so use sounds.length to see if it's empty or not

        if(asset.sounds.length) {
            totalLength += asset.length;

    alert("Total length of all used assets:\n\n    " + totalLength + " seconds\n\n    " + totalLength/60 + " minutes\n\n    " + (totalLength/60)/60 + " hours");

We haven’t heard of this requirement from Sony before. Is this a new requirement?


1 Like

Thank you so much Richard for providing a script!

Does this script check that the asset is used (ie if you use the “NOT #unused” query)? I’m not a script programmer so I can’t tell if I can see that part in the syntax. Or does it start checking through the Events rather than the Asset Bin? Does it then check if the event is assigned to a bank?

We haven’t heard of this requirement from Sony before. Is this a new requirement?

The request came to us from Sony Japan during the certification of a game project. And it came from Sony Japan only, the others did not ask this. The form asked to specify how many minutes of each codec is used in the game’s assets. We use ATRAC9 on all assets on the PS4 so that simplified the query.

Hi Peter,

Yes, I can confirm this only checks if the audio asset is used (not tagged with #unused). In an audio file’s properties asset.sounds is an array that contains all the instruments this audio file is used in. asset.sounds.length will check to make sure it is more than 0.

Thank you for providing details about the certification. I will pass this information onto our API team.