April 2018 wrapup
(I am extremely late with this wrapup; my apologies.)

This is not what I set out to do at the start of the month, but I spent almost the entire time on MojoAL, as people started pulling it into their projects and reporting bugs, inefficiencies, and missing functionality.

The problem with software development is that you can build fun and interesting things, and say--eureka!--have fun with this! But Fred Brooks was right about damned near everything, and if you build a fun library in a month, you should expect to spend the next 30+ days making it useful.

As such, I did.

A dirty confession: last month, MojoAL mixed audio, but it didn't spatialize it. If you moved an object around in 3D space, it didn't sound any different, which is bad^Wnot ideal for a 3D audio library. Now it works, and believe me, that was a trial.

No one tells you this about programming, but all programmers learn it pretty darn quick: even though your job is literally just giving a CPU math equations to solve, almost all of them are adding or subtracting 1 over and over again. You can even work on pretty complex games and never do anything more than basic algebra!

And then, one day, you need to figure out the angle between two points in 3D space, and you just have no idea where to start.

The most complicated math I had in school was Trigonometry, and that was in high school 24 years ago, and I could not wait to sneak out of the class and into the computer lab to write QuickBASIC programs, and in April of 2018 it finally bit me in the ass.

(Although, if we're being fair, I came this close to failing out of high school because of a failure to convert from degrees to radians, but that's another story.)

People make fun of programmers that use Stack Overflow, but those people just haven't hit the problem they don't know how to wrap their head around, yet. If they have any ambition, some day they will.

Eventually I slapped like 12 different ideas together and still just had to, y'know, flip the sign bit on various vector elements until things just started to work the way I wanted. Honestly, I'm not really sure why the final result needed this vector element swapped, or why that element always came out unexpectedly negative. I was merely grateful to have limped over the finish line.

Long story short, eventually I got this working, after more effort than it should have taken, leaving a long trail of links in the comments to Stack Overflow, Wikipedia, and Khan Academy for crying out loud.

If you want to see^Whear it in action, another thing I did was port it to Emscripten, so you can hear it in your browser! (unless your browser is Chrome 66, because Google is terrible). You can see it here...drag the blue box to move a playing audio source, drag the green box to move the listener, hear audio get quieter when there is distance between them, and hear it move between your left and right speaker as they change positions.

After this, I set off to optimize the thing. I want to write this up as a separate post (and intended to by now, alas), but for now I'll say this: I wrote a little stress test that runs the mixer 2 million times as fast as possible: revision control on April 17th took 45 seconds to complete. What’s in revision control now takes 13. More than 3x faster is a win. We now have SIMD code for SSE (hello Intel processors!) and NEON (hello ARM processors!) burning up the 3D math and mixers.

In between all this effort, there were also a ton of bug fixes, some new extensions, test and demonstration programs written, and other cleanups and improvements. Half of programming is janitorial work. It's correction, not creation.

You can see the whole list of changes to MojoAL here. I was chuckling at an ancient artifact from Creative Labs, a wishlist of things we largely never did, and remember that everything has to stop somewhere. In line with that, I'm considering MojoAL usable for real games now, and done enough that I can do other projects on Patreon now.

Tier Benefits
Recent Posts