[SDL] accurate audio timing
Bob Pendleton
bob at pendleton.com
Fri Jan 4 09:39:24 PST 2008
On Fri, 2008-01-04 at 08:41 +0000, Richard Henwood wrote:
> Hi Folks;
>
> I have a design question relating to a timing/dance based game I might
> return to work on. Such a game relies on sound/music playing with high
> degrees of accuracy since the ear can easily pick up millisecond errors.
> The basic gameplay would have a metronome with the user required to perform
> actions in time with it.
>
> I played around with SDL some time ago (over a year) to try and get this
> working and ran into problems generating an metronome with wav samples.
>
> In short, if I want to make a reliably timed, cross-platform metronome,
> which route should go; threads, callback, something else?
>
> Sorry for the unspecific nature of my question;
> any thoughts/suggestions are appreciated
Create a long looped track of a metronome. Not just one tick, but
several minutes long and loop it. Or it can be generated through the SDL
sound call back so that its rate can be varied. That will get the sound
out at the rate you want with very little if any random delay between
ticks. The trick is to keep the sound running constantly, not starting
and stopping it at the times when you want a tick. Then the rest of the
program can deal with any delays in timing caused by the OS. That means
you will have to be fairly tolerant of the timing of actual input
events.
The alternative would be to use a true real time OS or code directly to
the metal, but that defeats the idea of having a cross platform game.
Bob Pendleton
>
> best regards,
> richard
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
--
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob at Pendleton.com +
+ web: www.GameProgrammer.com +
+ www.Wise2Food.com +
+ nutrient info on 7,000+ common foods +
+--------------------------------------+
More information about the SDL
mailing list