[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libmikmod woes..
> hello there,
> i`m currently writing a couple of games for linux.. i have
> found that libmikmod is ideal for playing the modules and sound efects
> in the games, BUT..... it seems to play sound after about a second
> delay..... i think this is due to the size of the mixing buffer being
> too big..... question is how do i change the size of it???? if anyone
> has idea on how to overcome this problem, then please, please tell
[Yes - correct - this *IS* another PLIB plug...I can't help it...
people keep asking questions about things I've already solved!]
Just adjusting the amount the program mixes each time around isn't
enough. The library has to find out how much data is still in the
buffer and only mix enough to top it up to the desired length. I
think this is the major problem with MikMOD (but I could be wrong).
PLIB's SL audio sub-system carefully only mixes just as much audio as
you ask it to...you say something like "my code does graphics redraws
at 30Hz" - so I'll tell PLIB to only produce enough audio so that there
is 33.33 milliseconds worth of data in the output buffer. So long as
code gets around to calling the audio update routine within 33.33ms,
get no nasty delays between pressing "Fire!" and hearing "Bang!"...and
also no sound breakup due to data starvation.
In practice, you'd better make the safety margin a bit more than your
expected frame rate since a little extra delay is always better than
audio break-up. I find 100 milliseconds to be quite acceptable.
This is why my game doesn't use MikMod.
[Seriously: If my continual mention of my PLIB stuff is getting
please let me know and I'll shut up...you have to believe
I'm not deliberately plugging it!]
Steve Baker http://web2.airmail.net/sjbaker1
firstname.lastname@example.org (home) http://www.woodsoup.org/~sbaker