Re: [GD-General] Audio latency
Brought to you by:
vexxed72
From: Brian H. <ho...@bo...> - 2004-06-30 04:54:10
|
> Professional audio guys scoff at anything above 3-4 ms Well, maybe TODAY they do, but I remember not too long ago that if you could get down to 15ms that you were considered doing great. In fact, even today "zero-latency monitoring" is considered a must have. But I digress. > professional audio software achieve this by using professional > grade audio APIs like ASIO - which the drivers for consumer audio > cards don't support (or lie about supporting them - yes, I'm > talking about you, NVIDIA!). Right, there are up to three layers depending on the platform: - the application: 1. Delay between input and dispatching sound 2. Delay between dispatching sound and delivering to API - the API 1. Delay between receiving sound and sending to hardware - the hardware 1. Delay between receiving buffer and generating output Let's say you have a steady 60Hz application. On average the latency to _detect_ a key press is about 8 ms. So that's your floor, on average. If you're doing software mixing you might be looking at an average of 5-50ms of latency depending on how much buffering you need/want (which in turn depends on the underlying system's hardware). Let's call it a 10ms buffer with an audio worker thread that sleeps at 5ms intervals. So now we're at 18ms on average if we're doing our own mixing. Then the API receives an updated buffer, and that in turn probably gets run through a software mixer before heading out to the hardware. Then the hardware gets a shot at it, etc. In the theoretical best case you've got samples and you're mixing straight into the hardware's DMA output buffer, but I don't believe that's reliable in a cross-platform manner (one reason I use software mixing and audio servicing threads -- I just flat out don't trust drivers or APIs anymore after seeing the most trivial things break, e.g. DSound notifications). So call it 25ms latency if you're doing well, and significantly worse if not. I'm not sure if that's acceptable for a rhythm oriented game, which is probably most closely analogous to fighting games. Feh. Brian |