Timing for rhythm/music creator app

Hey guys. I’ve been working on a little rhythm/music creator app, but now I’m blocked by timing issues when playing the beats/notes. Basically, when you are playing a rhythm fairly quickly, the 16 millisecond error range from one frame to the next is plenty long enough to cause audible hiccups in the rhythm. I don’t know how to get around that.

As an experiment, I tried limiting the time between beats to integer multiples of the frame time. That cleared up most of the issue, but not quite all, presumably due to occasional framerate changes. Also it’s not really acceptable to limit the playback speed to only those increments; most similar apps on the market allow changing the speed by +/- 1 BPM (beats per minute).

So . . . any ideas? I’m totally boggled as to how people can write apps that play back such precise rhythms.

1 Like

That requires rendering the mix of sounds manually into a single buffer and feeding it into the sound engine such as OpenAL. That way you are not affected by the frame rate, only by the buffer size.

2 Likes

Ahhh! OK. That’s basically how I planned to record and save off the output, which I can do in Lua, but I didn’t think about playing sound that way. I guess it might be too slow with Lua. Thanks! I will start digging into OpenAL more, and yet again . . . wait for Native Extensions on all platforms. :slight_smile:

2 Likes

You can write C code that will load your sound samples and mix them according to the Lua commands. Not slow this way.

3 Likes