Script to import a WAV and create an event with that AudioAsset?

I could not find any examples on how to do this. I import a wav file using studio.project.importAudioFIle(), and can create an event using studio.project.create(“Event”), I can make a Group Track with event.AddGroupTrack()…but then I’m not sure how to connect these all together. I want to make an event using the imported WAV file.

Hi Ben,

A lot of what you’re trying to do is made simpler by having the functions returns return to a variable.

    var asset = studio.project.importAudioFile("C:/Path/To/Sound/Test.ogg");
    var event = studio.project.create("Event");
    event.name = "Test event";
    var track = event.addGroupTrack();
    var sound = track.addSound(event.timeline, "SingleSound", 0, 10);
    sound.audioFile = asset;
    sound.length = asset.length;

Thanks,
Richard

Sorry to reopen an old thread, but how can I achieve this in Unity with C#? I can’t seem to find the C# equivalent of studio.project.create. I need to create Events at run-time from sound files on disk. Thanks!

It’s not possible to create events at runtime. If you are looking to play loose sound files you will need to utilize FMOD::Sound. In Unity you will need to grab the Core system using FMODUnity.RuntimeManager.CoreSystem; first.

Just for future reference, it’s better to create a new topic for these questions and paste a link to solved questions if it needs more context.

https://www.fmod.com/resources/documentation-api?version=2.02&page=core-api-sound.html