[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Mixer latency



Well, this code gives the same results as pygame. That definitely lends to your thoughts that the latency is from somewhere else. While this is not directly related to pygame, I suppose the next question would be, do you have any thoughts on how to measure (and discover the source) of this latency?

Since pygame sounds don't block when they are played, it is not possible to just measure time.clock() before and after the sound.play(). One could wait for the end sound event, but I doubt that these events themselves are sent with zero latency, so that would just add another potential source of latency.

I have done tests on both the serial port and the sound processing code (i.e, that which determines which sound to play, all the way up to sound.play() itself), and both of those components appear to have minimal latency (less than 1 ms). The only source I can think of for this latency is the mixer / playing routines themselves.

Anyways, I thank you all kindly for your help.

Cheers

Brian Fisher wrote:
That's a fascinating way to measure the latency - however it may not
be a good way to measure pygame mixer's own latency specifically (it's
really odd if you can't see a difference with different mixer buffer
settings). If you believe "gamer keyboard" sales people marketing,
depending on the hardware keyboards can have latencies up to like
100ms all on there own.
http://www.pcmag.com/article2/0,1759,1908876,00.asp

Also, I wonder what results the same test would give using something
other than pygame to play the sound?  here's some code on the mac that
may be able to do that:
-------------------
   from AppKit import NSSound

  class MacSound:
     def __init__(self, filepath):
       self._sound = NSSound.alloc()
       self._sound.initWithContentsOfFile_byReference_(filepath, True)
     def play(self): self._sound.play()
     def stop(self): self._sound.stop()
     def is_playing(self): return self._sound.isPlaying()
--------------------
that way you'd have some other data point for comparison.


On Sun, Mar 30, 2008 at 9:26 PM, Wyatt Olson <wyatt.olson@xxxxxxxxx> wrote:
 Once the application starts, type "0:1023" (without quotes), and hit
 enter.  A drum sound will play.  I am measuring latency by recording the
 whole thing in an audio recorder, and measuring the difference in time
 between the sound of me hitting enter and the sound of the sample being
 played.  In my tests, it seems to average to about 65 or 70 ms, with a
 maximum of about 100ms.


Attachment: signature.asc
Description: OpenPGP digital signature