Duplicate an event with FMOD javascript / import multiple audio files from external source

#1

Heyo, trying to automate some audio import for our audio team. We’ve got a few hundred files coming in, and they will all basically be the same event, just with different audio files assigned.

What I’d like to do is to have an FMOD script that just pulls all audio files from a specified folder, chucks them into FMOD, imports them, and then, for each of those files, create a -duplicate- of the template event which uses that file instead of the file previously assigned to the event.

I need help with a couple of pieces:
Is there a javascript function that will duplicate an event for me? There must be, there’s a “Duplicate” in the dropdown, I’m just not savvy enough to find it. I already have a reference to the template event that I want to duplicate.
While we’re here, is there a quick way to swap out audio references? We can make the assumption that the template event only has a single audio file linked to it. I used dump() on the template event but nothing immediately jumped out at me.

I have a string representing the folder where all the new audio files are currently located. I need to find the paths of all files inside this folder and all subfolders (they’re guaranteed to all be audio files). I have extremely little javascript experience - is this something I would find in FMOD or do i need to go to a standard javascript library somehow?

#2

Welcome to the FMOD community!

The current setup you are describing (a few hundred identical events just with different audio files) sounds like a prime candidate for using programmer instruments. This is much more scalable, flexible, and easier to maintain. Take a look at the “event:/Character/Dialogue” event in the Examples project, coupled with the “programmer_sound.cpp” example in the FMOD Studio API examples.

https://www.fmod.com/resources/documentation-studio?version=2.0&page=working-with-instruments.html#programmer-instruments

https://www.fmod.com/resources/documentation-api?version=2.0&page=studio-api-eventinstance.html#fmod_studio_event_callback

https://www.fmod.com/resources/documentation-unity?version=2.0&page=examples-programmer-sounds.html

There is no native “duplicate” function in scripting. The “Duplicate” you are seeing in the dropdown menu is the application’s native copy & paste function. Trying to create a template via scripting would involve setting up an event’s properties in the script (eg. number of tracks, any effects, locations of instruments, etc.) and then looping that for any number of times needed. But, again, it would be a much better workflow to utilize programmer instruments.

1 Like
#3

Oh, wow, that’s some amazing tech right there! Thank you very much, I’ll definitely be using that.

I just wish we’d known sooner, haha. We already have so many implemented.
Such is life. :slight_smile:

#4

One more followup - we’re still in fmod 1.10.09.

How does one attach an audio table to a programmer instrument? In 2.0, we can drag an audio table in, but in …09, it seems there’s no way to attach an audio table to an instrument [we’ve tried dragging the audio table, but clicking the audio table selects it and there’s no way to actually drag it]

We’d like to avoid upgrading (because early access and we’d have to verify all our custom tweaks are still accurate) if possible, at least for now.

#5

You don’t attach audio tables to programmer instruments. In 2.0 you are able to use audio tables as placeholders (note that it says “Placeholder” above the waveform in the deck), but it doesn’t do anything other than that.

Basically what happens at runtime is the programmer instrument will produce a callback. You can then use this callback to load in an audio file that is bundled into the audio table you’ve built. We have examples on how to do this in our Unity and UE4 integrations:

https://www.fmod.com/resources/documentation-unity?version=2.0&page=examples-programmer-sounds.html

https://www.fmod.com/resources/documentation-ue4?version=2.0&page=user-guide.html#programmer-sounds-via-api

1 Like
#6

Ah, okay. Well we’ll give it a try and see what happens. Thanks again!