#50961 - wiz - Sun Aug 14, 2005 10:15 pm
Hello once again,
Following Deku's sound tutorial, I now have a sound mixer running (and sort of a mod playing in early stages)
I have imported the sound code to a small game but I notice when I play a sound it doesnt feel like is quite right.
Like a collision will sound very slightly after the collision was made.. I think this is to do with the double buffering?
Does this make sense?
if so, how can I avoid the delay? =/
Thank you!!
#50968 - DekuTree64 - Sun Aug 14, 2005 11:21 pm
Yeah, that's the double buffering. You can't really fix it entirely, although you can make the delay shorter by using a timer interrupt to mix samples instead of VBlank, and triggering it more often.
Timer interrupts are usually more bug-prone though, so I'd suggest ignoring the problem :)
Another possibility is if your music is mono, then you can get immediate response on a single sound effect by playing it on the other hardware channel.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#50978 - wiz - Mon Aug 15, 2005 12:12 am
ah, you'll have to bare with me as I'm very new to this area. do you mean set up another timer and dont buffer the other channel which will be used purely for sfx?
how important is it to have a double buffering sound mixer? reason I ask is because I took out the switching of the buffer and everything still appears to play fine.
#50980 - tepples - Mon Aug 15, 2005 12:17 am
If your double buffering sound mixer is done right, you'll only get a maximum of 17 milliseconds of delay. Many implementations switch buffers every vblank. For example, with the timer set to -924 and the buffer length set to 304, you'll get a 18157 Hz playback that lasts exactly one frame so that you can switch buffers in your interrupt handler.
If you're mixing an entire row of the .mod file at a time, mix it to a separate buffer and then feed a snippet into the main mixer once every vblank.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#51003 - FluBBa - Mon Aug 15, 2005 8:15 am
wiz: are you testing this in an emulator, if so you will probably experience a lot more lag than on the real deal.
_________________
I probably suck, my not is a programmer.
#51033 - wiz - Mon Aug 15, 2005 6:59 pm
FluBBa: Spot on, I was testing in VBA and soon as I got home I tried it on hardware and it looks absolutely fine! That'll teach me to do more testing in future.
Tepples: Thanks for that, I guess 17 millisecs is no problem at all :)
and again, many thanks DekuTree64 for the sound tutorial, I have learned a lot from reading it!
#51062 - tepples - Tue Aug 16, 2005 12:29 am
And about emulation: I get some noticeable controller->audio lag on the GameCube Game Boy Player, but not nearly as much as on VBA. The amount of lag that VBA introduces makes Konami's rhythm games unplayable.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.