fluidsynth icon indicating copy to clipboard operation
fluidsynth copied to clipboard

[Feature request] Support for OpenAL backend

Open s-d-m opened this issue 2 years ago • 3 comments

The audio backend "natively" supported by webassembly is OpenAL, which fluidsynth does not support at the moment. Adding it would make using fluidsynth on web applications easy.

Current alternatives are: 1/ trying to use SDL audio as fluidsynth backend, and hook SDL audio output to webassembly but that makes for a complicated setup. 2/ use fluid_synth_write_s16 to get audio data from fluidsynth into a buffer, and then push that buffer to openAL. You can see this in action here https://gist.github.com/take-cheeze/43f026d07547b9399738 or in my personal toy project at https://github.com/s-d-m/lilyplayer/blob/dba2dfd5484c71b5de49a96e9a18e2d8776f5c1c/src/sound_player.cc#L89-L114

To make fluidsynth available to webassembly, on top of OpenAl support, the changes at https://github.com/jet2jet/fluidsynth-emscripten are also useful.

s-d-m avatar Jun 21 '22 20:06 s-d-m

You're welcome to file a PR for that. I currently don't have time for it.

derselbst avatar Jul 02 '22 19:07 derselbst

Reading a bit into how openAL works (I admittedly didn't extensively went through it), it looks to me that the proper way to do it is by using the alternative #2 I wrote above. Unless someone with better understanding of openAL can come and correct me here, I think this feature request is a non-issue and can be closed.

s-d-m avatar Aug 01 '22 11:08 s-d-m

OpenAL (Soft) used to have MIDI support so perhaps there's anything useful in the old code that was removed: https://github.com/kcat/openal-soft/commit/6689c61ff474657109c5a73827b8733aba7dfd45 I for one would also like FluidSynth to support OpenAL, but for a different reason: (3D) spatial audio and (EAX) reverb. If every instrument (or even note) was treated as an OpenAL sound emitter/object, it could be spatialized using attributes like note balance and pitch for the X and Y coordinates or something like this https://youtu.be/h8og1oL8JVY or https://youtu.be/EmuWIuI9e-c

ThreeDeeJay avatar Mar 06 '23 20:03 ThreeDeeJay