How to prevent data duplication in Banks?

Is there any possibilities in FMOD Studio to prevent data duplication in Banks?

I am worried about this, because having large amount of events it is very easy to assign different events with the same audio files to different banks and thereby duplicate the data in those banks.

Is there any ways to prevent this?

If there is no built-in possibilities to do that I guess alternatively I could ask our programmer to write a script which will be doing something like:
1 Take an audio file name from Audio Bin.
2 Search in Events project folder what events are using that file.
3 Search which events containing our file belongs to different banks and flag them.
4 Take the next audio file and repeat the procedure.
And run this script on regular basis.

Audio source data shared between Events that are in separate Banks will be duplicated in each Bank. There is no way around this because we allow people to load individual banks.

This will cost you extra download and install space, but it won’t cost you any extra memory at runtime. It will detect that an audio asset is already in memory from a previous Bank and avoid loading it twice. If you unload the previous Bank it will make sure the shared audio remains until any referencing Banks are unloaded.

1 Like

Thank you for your answer Nicholas.
Yes, I understand the idea behind thins. You can deliberately duplicate data in banks for your own needs but also you can do this accidentally for example if you populating events from Audio Bin and there a thousands files in there. And HDD space is also a crucial segment of optimization.
I think having the possibility to detect duplicated data would be a nice feature.
You can check your banks and if there are copies you can think about moving detected events in one bank.

Is there any tool in FMOD Studio to currently report when an audio file is included in multiple banks?
This is quite an important feature for our project to have, because size constraints on mobile affect your app performance.

Hi,

Unfortunately, there isn’t a build in feature. However, I have made a Studio script which can find assets that have been included in multiple banks.

Find Duplicate Audio Files.js
studio.menu.addMenuItem({
    name: "FMOD Examples\\Find Duplicate Audio Files",
    execute: function () {
        var banks = studio.project.model.Bank.findInstances();
        var audioFileMap = {};

        function trackAudioFile(audioFile, bankName) {
            if (!audioFile) return;

            var key = audioFile.id;
            if (!audioFileMap[key]) {
                audioFileMap[key] = {
                    name: audioFile.assetPath,
                    banks: []
                };
            }

            if (audioFileMap[key].banks.indexOf(bankName) === -1) {
                audioFileMap[key].banks.push(bankName);
            }
        }

        function extractAudioFromInstrument(instrument, bankName) {
            if (!instrument) return;

            if (instrument.audioFile) {
                trackAudioFile(instrument.audioFile, bankName);
            }

            if (instrument.sounds) {
                instrument.sounds.forEach(function (subInstrument) {
                    extractAudioFromInstrument(subInstrument, bankName);
                });
            }

            if (instrument.sound) {
               extractAudioFromInstrument(instrument.sound, bankName)
            }

            if (instrument.event) {
                var subEvent = instrument.event;
                if (subEvent.groupTracks) {
                    subEvent.groupTracks.forEach(function (track) {
                        if (track.modules) {
                            track.modules.forEach(function (mod) {
                                if (mod) {
                                    extractAudioFromInstrument(mod, bankName);
                                }
                            });
                        }
                    });
                }
            }
        }

        banks.forEach(function (bank) {
            var events = bank.events;
            events.forEach(function (event) {
                if (!event.groupTracks) return;
                event.groupTracks.forEach(function (track) {
                    if (!track.modules) return;

                    track.modules.forEach(function (module) {
                        if (module) {
                            extractAudioFromInstrument(module, bank.name);
                        }
                    });
                });
            });
        });

        console.log("=== Identified Audio Files ===");
        Object.keys(audioFileMap).forEach(function (key) {
            var entry = audioFileMap[key];
            if (entry.banks.length > 1) {
                console.log("Audio File: " + entry.name + " used in banks: " + entry.banks.join(", "));
            }
        });
    }
});

The script can be put here to be available to all FMOD Studio versions:

"C:\Users\User\AppData\Local\FMOD Studio\Scripts\FindAudioFiles.js"

Make sure to reload the scripts if FMOD hasn’t been restarted


The output it logged in the console window:


Please let me know if you have any issues with the script.

1 Like

We’ll try and report back.

I would strongly suggest to put this as a built in script.

May I also ask if there’s some IDE where I can get autocomplete when writing scripts?

1 Like

I will certainly pass it onto our development team to investigate further.

You are able to code directly in the FMOD console which does provide some auto completion:

Hope this helps

1 Like