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

Re: [pygame] Mixer latency



Yes, I have tried all sorts of buffer sizes (all the way down to 8). I can't see any difference in performance with any of these. As for the source, I tool a look at mixer.c, but to be honest I am not as up to date on my C as I would like - I have concentrated on higher level languages for a bit too long, and have forgotten the details of these older ones. 8-(

As for the program, you can access it at http://drummaster.thecave.homeunix.org/files/DrumSlave_Minimal.zip . This only has one sample (a snare drum) for testing, which is mapped to port 0. Other than that, it is exactly as I am using it.

To run, unzip and use the command:

python drum_slave.py --keyboard rock

It should run on python 2.4 or 2.5, with any semi-recent version of pygame.

The application is meant to be the slave for a hardware board I developed, which talks to the computer via a serial port. To allow testing, I added the keyboard mode, in which you can manually type the commands which otherwise would come over the serial port.

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.

As for program layout, the initialization is done in slave.py. drum_slave.py is just the command line wrapper. Pygame Sound objects are played in hardware/sensor.py. I don't think that anything else would be relevant to this discussion, but it should be simple enough to find your way around in, if you are interested - the program is not very large.

All my testing so far has been done on OS X. I am planning to try some tests on Linux, once I can get a box put together. If anyone does test this on a different platform, I would be very interested in hearing the results, and how they compare to mine.

Thanks for all your help!

Cheers

René Dudfield wrote:
Hello,

Do you have a link to your code?

You've tried setting a really small buffer size?  Like 512 or something?

Have a look at src/mixer.c to see how SDL is used.

cheers,



On Mon, Mar 31, 2008 at 2:50 PM, Wyatt Olson <wyatt.olson@xxxxxxxxx> wrote:
 Upgraded to pygame 1.8 / python 2.5 - still the same latency.

 I am thinking that it may be related to SDL itself, and not the python
wrapper per se... I have seen some suggestions on lowering the chunk size in
SDL.  Does this map directly to the buffer size in pygame, or is there some
magic happining behind the scenes?

 Thanks



 Wayne Koorts wrote:

 Does anyone have any suggestions on what I can try?

 Wouldn't hurt to upgrade to Pygame 1.8 for a start.

Regards,
Wayne



Attachment: signature.asc
Description: OpenPGP digital signature