This is an inquiry regarding bulk replacement of audio files within an FMOD Studio project.
My FMOD Studio project contains over 1000 events. These events were originally linked to audio source files of various formats, including but not limited to:
.mp3
.wav
.aac
.ogg
The Process:
I used external software to equalize the volume and apply effects to all sound assets. Consequently, all output files have been unified into the OGG (.ogg) format.
The Core Problem:
I want to replace the old source files in the project with these new OGG files. Since the file paths and base file names have not changed, but the file extensions are different (e.g., sound.wav is now sound.ogg), a direct paste-and-overwrite action leads to the following:
Files that were already .ogg: These are unaffected and are correctly overwritten.
Files that were not .ogg (e.g., .mp3, .wav, .aac): The corresponding FMOD Studio events lose their association with the original files (resulting in “Missing” or “Lost Audio” status) because the project is still looking for the old file extensions.
Is there a fast, batch method or tool that allows FMOD Studio to automatically re-link the “missing” events to the new .ogg audio files located in the same path and with the same base name?
The best way to do this is to us the Studio scripting API. I unfortunately don’t have a script that exactly addresses your situation. However, I do have this Studio script that can handle the replacement part - it will use the selected assets to replace all other assets with the same name in the same directory:
studio.menu.addMenuItem({
name: "Search and replace based on selected assets",
isEnabled: function(){
return studio.window.browserSelection().length > 0
},
execute: function(){
studio.window.browserSelection().forEach(function (asset){
if (asset.isOfExactType('AudioFile')){
ReplaceBasedOnSelectedAsset(asset);
}
});
}
});
function ReplaceBasedOnSelectedAsset(newAsset){
var assets = studio.project.workspace.masterAssetFolder.assets;
assets.forEach(function (asset){
if (asset.isOfExactType('AudioFile')){
if (GetFullAssetPath(asset) === GetFullAssetPath(newAsset) && !(GetAssetExtension(asset) === GetAssetExtension(newAsset)))
asset.sounds.forEach(function (sound){
sound.audioFile = newAsset;
});
}
});
}
function GetAssetName(asset){
var assetPath = asset.getAssetPath().split('/');
return assetPath.pop()
}
function GetFullAssetPath(asset){
var assetPath = asset.getAssetPath();
var lastIndexOf = assetPath.lastIndexOf('.');
return assetPath.slice(0, lastIndexOf);
}
function GetAssetExtension(asset){
var assetName = GetFullAssetName(asset);
var lastIndexOf = assetName.lastIndexOf('.');
return assetName.slice(lastIndexOf + 1);
}
To be safe, make a back-up your existing FMOD Studio project. The script is not undoable.
Steps to use:
Save the above code to a “.js” file in a “Scripts” folder in your FMOD Studio project or install directory
Ensure that all new “.ogg” files are located in the same directories as their “.mp3”, “.wav”, or “.aac” counterparts
Open your FMOD Studio project
Open the Assets tab
In the search bar, search for “.ogg”
Enable the “flatten” mode at the bottom of the tab
Select all .ogg files
From the Scripts menu, execute “Search and replace based on selected assets”
This should replace all usages of old assets with the “.ogg” file with the same name in the same directory.
Afterwards, you will need to delete all the old assets manually. To do this, you can:
Open the Assets tab
In the search bar, search for “.mp3”, “.wav”, or “.aac”
Enable the “flatten” mode at the bottom of the tab
Select all the non-“.ogg” assets and delete
Give that script a try and let me know how it goes, and whether you run into any issues!