SoLoud audio plugin

Quoting the intro page: “SoLoud is an easy to use, free, portable c/c++ audio engine for games.”

This is a binding for that engine, and aims to be a faithful one, with only a few changes here and there to sand down the C++ edges into a more friendly Lua form.

If you scroll down on that page, the “How powerful?” section will give you a general overview of what’s available. From there, you can explore many of the side links to dig deeper.

Among other things: you get a bunch of formats (on all platforms); several built-in filters; properties like panning, play speed, 3D position; faders and oscillators on those properties; busses and queues; SFXR and speech synthesizers.

I’ve re-implemented SoLoud’s many examples and demos as a way to flush out the kinks in my binding. These are available here and can be used as a guide to get started; in particular, see its build.settings.

@BK_PANARA and @Siu have been doing some testing. For any interested Windows users, Siu has also adapted and built one of the samples: (3.2 MB)

(This uses an interesting project of his own.)

The “Latest Stable Release” (~47 MB) here has the assets needed by most samples: the audio and graphics directories (in bin) should be copied to the sample. If you’re on Windows, bin also contains the original samples, if you want to compare.

I DO NOT claim to have gotten everything faithfully ported; any major substantive discrepancies are probably things I need to fix. :grinning_face_with_smiling_eyes:

The welcome and space samples use the Openmpt audio source. Currently that only has Windows support. This just means those samples do a little less, and that you can’t yet use its capabilities on other platforms in your own projects.

At the moment the samples are the documentation, although of course I mean to address that.

I’ve tried to hew pretty close to what you see on the SoLoud page. Major differences include using strings instead of enums, and tables where there are multiple default values, the idea in both cases being to avoid seemingly “magic” numbers as input.

Yet to do / ideas:

There is support for custom audio sources, used in particular by the piano sample. (This was an utter beast to implement! :smiley:) The groundwork for that should mean custom filters are also possible, but I didn’t have an example to port and so haven’t done it yet. Ditto colliders and attenuators, and maybe file ops. I figured these wouldn’t be urgent.

As mentioned above, Openmpt needs porting. I figure this shouldn’t be too bad, especially on Mac, but just have to work out how to make it optional in each case, as it comes down to bundling another library.

I had the same thought as fungos here, and for plugin purposes am not so worried about the attribution issue, so might add TinySoundFont support.

I haven’t yet done the Ay and TedSid samples because I don’t have any handy audio files. :smiley: The ones listed in the original source are either missing or in a no-longer-supported .dump form. (This has conversion utilities but I haven’t mustered the will to try it.)

A sample or two use some audio source member values, e.g. sample rate and such, without going through any getters. I only exposed the ones that were needed for those purposes, but there might be others that are useful. Similarly, I added a few methods to float buffers to make certain operations in the piano sample quicker; there might be other useful ones too.

There might be a few naming inconsistencies left in the API, like optional buffersize in one place but then sampleRate in others. I think these are mostly in corner cases, in which case I might still amend them before I write up the normative docs.

Linux, web, and Switch implementations still to do.

I left in a few print statements. There was an occasional issue when you quit, related to the audio thread. I might have fixed it, though I’m bewildered that the circumstance in question never even seems to happen now. :smiley: If anybody sees something about “mutex = no”, I would like to know. :slightly_smiling_face: Anyhow, those are otherwise harmless and I expect to remove them in not too long.

The Henley sample is the only “original” one (actually adapted from something in Paul Graham’s Common Lisp). It seems to just stop at some point—maybe when too many short words get queued up?—but I imagine that’s my own fault. :smiley:

Some of the samples start with a little sound before the timer fixes it up, so I’ll need to fix that. Also, in general they should probably use scenes and allow going back to the menu, but that concern was out-of-sight, out-of-mind when porting them. :smiley: