SDL Drums

SDL Drums

Source




A drum machine made in SDL. I know, SDL has gotten quite a bit of attention here on this site so far. But it's fun to work with! It's like making a video game - which is kind of what SDL is made for I guess.

But it's also kind of impractical for any serious software development. It doesn't have any GUI functionality - I hade to write my own Button class which works off coordinate calculations, and draw all the buttons myself. So. Much. Drawing! And you can forget about menus! I Ain't doing that! But on the other hand it's such a low-level thing you can just start hacking away. Get your events, start drawing on the screen, do whatever! There is a little bit of magic in that. And it can deal with audio!

So in essence, this is a project that just went a little too far. It started off as an off-shoot from the Odd Metronome project - which I will maintain is a good project for SDL because it is so simple - but since I had the playback set up as a separate thread and since the metronome is basically a sequencer playing two different samples, I figured I'd try loading in more samples and creating a sequencer for those. And a little drum machine was born.

Since then it's been collecting features, little by little, and accumulating more low-level spaghetti code that I swear I'm going to clean up on day.

It's not very useful for doing actual audio work, even if you come at it with the best faith possible and the patience of a saint. Most notably it's missing export (i.e. sound recording) functionality and you can't save patterns either (although it'll keep the last thing you made when it shuts down). Also you can't replace the samples. These come from the Viscount drum machine, by the way, courtesy of Samples From Mars. I hope I don't get in trouble distributing these for free... But on the other hand this is just a small part of the whole package and you should definitely got check out Samples From Mars. They're awesome!

It's also missing the possibility of muting / unmuting drum tracks, which is a classic feature of pretty much every drum machine out there, and the are no volume controls.

But then again, this is just a little laundry list of missing features. If i got them done one by one, I might actually use it myself someday to make Real Music one day. Maybe...

On the other hand it has a delay effect, which you can opt-in on each drum channel. And it has a cool little visualizer in the middle. Here is the delay effect in action:




On a technical level SDL supplies you with a callback function that lets you do some post-processing of the audio stream. This is useful for effects, for example It's pretty powerful actually, provided you're not trying to make a DAW or a VST or something, but maybe something like a... let's say video game? It's served as a good vehicle for teaching myself a little dsp. Grinding away at those circular buffers for the delay effect...