Rubygame 3: Day 34

I'm definitely crazy. But I'm crazy in the way that gets things done, so it's all good.

I've designed the API for the new Sound class, which will replace the Mixer::Sample class and several of the Mixer module methods (regarding channel allocation and playback).

Sound is a fairly high-level, object-oriented wrapper around SDL_mixer's Channel and Chunk classes, simplifying their use. No need for the user to allocate channels or decide which channel to play a sound on; all that stuff is taken care of under the hood, using an available channel if there is one, or allocating a new one if needed.

There will also be a simple but effective system that allows multiple Sound objects to reference the same audio data, so that you can have many Sound objects, each with their own volume and effects, but without having to load the sound file multiple times (which would use lots of memory).

It's pretty exciting, but I'm taking care to rein myself in and not get carried away. For Rubygame 3.0.0, Sound will just have the basic stuff that Mixer and Mixer::Sample can do now (which one simple addition: changing volume!). The idea is to take advantage of the break in backwards compatibility to set up a new, nicer foundation. Then, later versions can add more features on top of the foundation.

Back to the grind with me, now.


Have something interesting to say about this post? Email your thoughtful comments to