Excerpts from WEB-build and Itch.io deploy of CGE Project journey

Audio playback on the web is also close to being done:)

Right now on branch webaudio (not master).

Initial notes:

Tested on examples:

  • platformer game
    • though note TODOs: initial menu music doesn’t play
  • audio/doppler_demo
    • though note TODOs: Doppler effect is not done by WebAudio

Some TODOs before I merge this:

  • Playing non-WAV formats (like OggVorbis) right when the buffer was loaded (e.g. playing iniital game music) will fail with Cannot play sound "%s" because it is still decoding. . We must handle this better, start playback once the OggVorbis finished decoding, instead of aborting.

    This causes the “initial menu music doesn’t play” problem for platformer now.

  • We use JS promises in naive way but that’s not good: We need to make sure that we cancel the promise (building a mechanism on top of JS to cancel any promise, maybe just ignoring result), as we must cancel a promise if the Pascal instance interested in the promise no longer exists (which may happen e.g. if you switch views before a promise was realized).

    From what I see, various example JS code snippets using promises or async/await have this TODO too :slight_smile: It will not crash in garbage-collected languages, but still may do all sorts of weird things.

    One needs to remember that application keeps working, possibly changing state, while we wait for promise to be delivered. Our WebAudio backend should account for it, to not crash in edge-cases when promises succeed/fail with large delay.

    This affects now decodeAudioData done asynchronously. In theory, you can crash it, changing views fast after staring to load OggVorbis. We should secure from it.

  • (DONE) platformer weird shot.wav playback must be investigated and fixed.

  • game_3d_sound crashes (for reasons unrelated to audio, it seems?).

  • play_sounds crashes.

  • Support other audio formats, like MP3. Also FMOD supports them. IOW, we are not limited to WAV / OggVorbis formats on some audio backends, and we should expose more audio formats, just with warning (that they are not cross-platform supported by CGE).

2 Likes