Hello, currently is possible to play a sound generated at run time in WASM?
If not, it could be a desirable feature to extend Wwise capabilities?
You could set L:VARS in WASM to then trigger Wiise events via those variables.
Best,
Raul
So I have to use RTPC? Excuse me but this part of the documentation seems not very clear to me for my use case
From what I understand I could use custom_sound_ N WwiseEvent
as described here: Wave Data Sounds Properties (flightsimulator.com)
In this case a filename must be specified in the sound.xml. So I should replace this file at runtime in order to play a runtime generated sound?
You can use also WAV files too and trigger them via an L:VAR indeed…
Best,
Raul
OK but I’m missing how to link in the WASM code the procedurally generated WAV with the L:VAR, I mean I can for example create a white noise WAV in C++ and make it save in the work folder.
But then how this new file can be triggered by the Wwise event?
You cannot create a .WAV via WASM, you would create a .WAV with the sound you need, configure your sounds.xml with relevant simvars for it… and use WASM to load the variable so the sounds play.
MSFS Sounds requires a sound.xml pointing to either a WIISE package or .WAVs files already prepared to be triggered.
See the aircraft SDK samples…to understand the sound system better.
R.
OK thank you for the explanation but I strictly need to create a WAV via WASM on the fly and play it.
Maybe it could be a topic for further MSFS sound developments?
that’s up to Microsoft / Asobo. But quite frankly I don;t see how this could work properly with the core sounds and sound.xml , etc.
R.
OK maybe an option would be to allow WAV files in the writable work folder.
That way the sound.xml could point to a dummy .wav file in the work folder that can then be modified at runtime
Hello @MaxHype
In the MSFS SDK, there is a sample regarding the call of Wwise events through WASM and LVars. The sample is called SoundAircraft, located on the Samples\DevmodeProjects\SimObjects\Aircraft folder. It has what you need, check it out.
As Raul (@SimbolFSReborn) said, you can’t create nor embed a WAV file into a WASM, so you must either have a WAV file next to the sound.xml, or include the WAV file in the Wwise soundbank.
Do not hesitate to ask for further assistance. Good luck!
Kind regards,
Carlos Daniel González Gómez
CEO, Founder & Lead Developer
NextGen Simulations
That sounds like a really great idea indeed. Let’s hope it will be possible in later iterations of MSFS.
This means the sound should stay in the package, and present in the layout.json of the package, right?
Do you know what happens if you change the .WAV file dynamically at runtime and play it again? Will the updated file play, or does the sim “caches” the sound, so it wouldn’t recognize it changed on further plays?
Exactly, Umberto (@Umberto67). Either the WAV file listed in the package and next to the sound.xml file, or included within the Wwise soundbank listed on the package and referenced on the sound.xml file, as long as the sound event and the LVar are referenced in the XML file, then just invoke that sound from the LVar like in that SoundAircraft sample.
To be honest, I am not sure if there is a possibility to dynamically change the WAV file at runtime, and if there is a method for it, I am totally unaware of how this can be done. I know you can maybe modify or replace the WAV file but with the sim closed, but dynamically and updating at runtime, I do not know, honestly.
Regards,
Carlos Gonzalez
NextGen Simulations
Well, it’s a file so, it surely can be created in some way, possibly even in WASM, although I guess you’ll have to write a custom .WAV writing routine in pure C++/Posix.
Clearly, doing it from an external .EXE would be much easier, since you could use all sorts of 3rd party libraries to read, write and convert audio formats, but then it would restrict the app to PC only and no Marketplace, of course.
I’m sure you can change files belonging to a package on the fly, but not all of them, some just work, other need tricks, for example you force the sim to reload an XML behavior of an object, if you “touch” the filedate of one of its .GLTF files, so I was wondering if anybody tried with dynamically generated .WAV files loaded this way.
A possible application of this method would be, for example:
Making a http request to connect to some external server with an API (ex. AI Text to Speech), which returns audio data in some format (might have to be converted to .WAV first) then write that .WAV to a fixed filename that has been included in the package as a dummy file, so it could be played back “refreshed”.
If that works, it might be possible to have a WASM-only solution that would work on Marketplace/Xbox, for any kind of application that needs WAV audio generated programmatically. AI Text to speech is the prime example.
Please correct me if I am wrong, but I guess something like this: you download the WAV file to let’s say the work directory of the WASM module in question, then the audio playback library embedded (which of course must be WASM-compatible) can grab the WAV file previously downloaded from the HTTP request, read it and play it, and adjust it dynamically on the fly, right?
Regards,
Carlos Gonzalez
NextGen Simulations
Unfortunately, no, I don’t think it would work. Playing it directly would require accessing some kind of Windows API, which WASM can’t use.
And in order to play it using the using the “external WAV” method, we would have to copy it in the package folder, and neither WASM nor Javascript can write to it.
It would be enough if we could just play a sound from the Work folder too.
Out of sheer curiosity - why would this be needed? Can you provide a use-case scenario?
Wwise is an extremely powerful tool if leveraged properly and efficiently, although it’s not without its limitations. I am honestly interested as to why you’d want to go through the hassle of this with regard to aviation specifically. (though I do have some ideas)
Well, consider the possibility that some advanced add-on aircraft would want to generate engine and other sounds completely dynamically with slight differences depending on the exact operating environment and current engine parameters.
I agree with @Tyler about Wwise. If it is properly and efficiently leveraged, it can create such an amazing soundbank for using with the addon in question, but it is also respectable how developers decide to work with sounds for their addons development, as described by @TangoMikeLima or @Umberto67, so this should also be available.
Regards,
Carlos Gonzalez
NextGen Simulations
You can already do that (without generating dynamically) but you can modify the audio based on a wide array of inputs into Wwise. You can set up L:Vars to interface with wwise by using custom RTPC to control volume, pitch, or other things like effects, busses, etc.