Categories
Game Design Game Development Geek / Technical

Freshly Squeezed Progress Report: Managing Mixer Tracks

Last time, I reported that I was still migrating my code to SDL3, specifically SDL3_mixer, for a Major Update(tm) for my strategic leaf-raking business simulation game, Toytles: Leaf Raking.

Alas, I am still, STILL working on it.

Sprint 2025-MJ_6: Preproduction

In progress:

  • Update SDL2 to SDL3

Again, the main migration work that I have left is audio-related. To make things easier, I decided to create a MixTrackManager to manage my MIX_Track objects.

Basically, when I initialize my game, I will also configure a set of tracks, grouped by name.

For example, I might have one track for all user interface sound effects. Every button click and swooshing transition will likely play on its own. That is, if you clicked a button, you couldn’t have clicked a second button simultaneously, so won’t need a second track to play both sounds. One track will work just fine for “UI” sounds.

However, maybe there will be lightning crashes, the sound of rain hitting a roof, and the sound of wind. All of these might be “ambient” sounds that could play together, so I should have at least as many tracks available.

SDL_mixer lets you tag tracks, but the main use is to treat a bunch of tracks that are so-tagged as a collective group of tracks to play at once, for instance.

What I want is to be able to say “Play this sound effect on the first available track in the ‘ambient’ tracks”, and hence the MixTrackManager.

The old SDL_mixer just let me specify -1 as the channel to play on, and it would play on the first available channel rather than require me to specify a specific channel. I wanted to have something similar while also retaining the ability to have separate sets of tracks for different purposes.

So MixTrackManager allows me to create a set of tracks for a given tag, but I use my tags differently from how SDL_mixer is using them.

But maybe calling them “tags” even though the purpose is to just name a set of tracks (and even as I use that name to use SDL_mixer’s tagging functionality, too) is confusing things.

I might consider renaming things, but the functionality it will allow is the key: I will be able to play audio more or less the way I did before.

It’s taking me a long time to get to this point, and frankly I am not sure why exactly it has taken me so long, but I’m almost there.

Thanks for reading, and stay curious!

Want to learn about future Freshly Squeezed games I am creating? Sign up for the GBGames Curiosities newsletter, and download the full color Player’s Guides to my existing and future games for free!

One reply on “Freshly Squeezed Progress Report: Managing Mixer Tracks”

Leave a Reply

Your email address will not be published. Required fields are marked *