simpleaudio now has playOgg, Mp3, Wav with resampling and can access multiple soundcards on Linux, adrdox gets ddoc on function params

Posted 2020-11-09

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

What Adam is working on

simpleaudio improvements

Resampling

IRC user ketmar ported some resampling code to D a long time ago and offered it to me for my simpleaudio module, but I didn't get around to adapting and merging it in until now.

As a result, the existing playOgg and playMp3 functions, as well as the new playWav (I wrote wav.d ages ago but never wrote the convenience function again), now work with sample rates that don't match the output.

This means you can open just about any output device and just about any input file and it just works. Still some convenience we can add later, but with this working, you can fairly easily play some pre-recorded samples in your games and such.

Sound card selection

Previously, the constructors would take an int argument that must be 0 for sound card selection; it would pick the default and you couldn't change it, but I wanted some kind of signifier for future use (and since default construction is illegal in D, I needed something anyway).

Well, I decided to add a string overload that actually works - on Linux, for now, I'll see about adding a Windows thing later - to choose the device. It uses the ALSA syntax like hw:0,0 and has no function to query options or prettier strings for user interfaces yet, but at least it works. (I got sick of changing the enum and recompiling for my different use cases lol.)

adrdox param documentation

Upon request, I added support for reading doc comments on function params, like this:

///
void foo(
	/// Some note
	int a,
	/// some other doc
	int b
)

The doc gen will rewrite that into

/++
	Params:
		a = Some note
		b = some other doc
+/
void foo(int a, int b)

And generate the same code. So it is just an alternate way to write the same thing. If you have both a Params block and inline ddoc on parameters, it will try to append, but the results may not be what you intended. Similarly, ditto blocks may not be ideal - this is best for documenting a single function without mixing styles.