Audio Format Support

Your goal is to design or seek out a library designed to convert input samples of a pre-defined audio format to destination samples of another, on-the-fly as samples are provided. But if you are feeling lazier than a goat, just design an “on-the-top” solution that will convert an entire buffer of samples.

Some Thoughts

Why: The SPC emulator writes to a buffer of:

  1. little endian
  2. signed 16/bit
  3. 2 channel interleaved stereo

Currently, the emulator can only dynamically account for different sample rates.

Thus, the 2 solution options truly become:

  1. Solution above – see “Audio format emulation layer”
  2. Modification to libgme/spc emulator to allow various flavors of audio formats.
  3. Create a new library specifically for converting samples on-the-fly, that libGME and others could use in their sample functions.

I rather like 2 because it fixes @ the source, speedier performance solution – also probably a lil’ more difficult (I also have a new saying “if you’re going for better performance, forget about it” — it needlessly complicates. HOWEVER – this whole post is a waste because I think the native audio format is the most popularly supported. Please research the most popular audio formats regarding endianess and bit-width. Irregardless, I would like to see support being offered to any lonely souls [computers].

For 2 – There is a func. where samples are filled into a buffer. This is a very repetitive function, which I needlessly thought about optimizing for performance sake – by having one-time logic checks beforehand and then executing a predefined code path based on the logic calculated at init.. But the saying comes to mind again — It’s difficult to know whether a compiler is already optimizing certain things I consider manually optimizing.. I will probably make another blog post about this research. Ultimately it became a question of function calls costing more than a boolean check anyways, and that the effort is not worth the potential gain in performance.

Thus, I propose the best solution, — 3 — design 1 as its own component which GME can use, as well as other projects that would want to add support for other audio formats, based on an input format. Much can be learned in doing these by investigating into SDL2’s audio format conversion techniques


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s