Here's a JavaScript sound generator. The SFXR.js module can easily be used in other projects that want to load sounds created with the SFXR program. I translated the core of it from the SFXR program itself, which is written in C.
This demo shows what some of the loading screen logic might be to generate the actual Sound object. It also provides a UI to allow the user to play the sounds once they're generated. SFXR files are 105 bytes each, so they are a very compact way to keep game sound effects.
It takes a second or 2 to generate the Sound object from the parameters in the .sfs file, but as this example demonstrates, it's possible to do that without blocking the main thread, so your loading screen can have animations or progress bars. In this example the opacity of the buttons change on progress messages, as well as the text to give a numeric progress. Once a sound is generated, it can be played while the other sounds are still generating.
Adding new sounds to this example is as easy as putting the file in Resources/Sounds, and putting the file name in the list in the UI.js component.
Here's a JavaScript sound generator. The SFXR.js module can easily be used in other projects that want to load sounds created with the SFXR program. I translated the core of it from the SFXR program itself, which is written in C.
This demo shows what some of the loading screen logic might be to generate the actual Sound object. It also provides a UI to allow the user to play the sounds once they're generated. SFXR files are 105 bytes each, so they are a very compact way to keep game sound effects.
It takes a second or 2 to generate the Sound object from the parameters in the .sfs file, but as this example demonstrates, it's possible to do that without blocking the main thread, so your loading screen can have animations or progress bars. In this example the opacity of the buttons change on progress messages, as well as the text to give a numeric progress. Once a sound is generated, it can be played while the other sounds are still generating.
Adding new sounds to this example is as easy as putting the file in Resources/Sounds, and putting the file name in the list in the UI.js component.