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

Re: [pygame] varying sound playback rate



Jason Marshall was not optimistic about being able to specify playback
speeds:

> To crack that nut using Pygame software in real-time
> as you described, you'd have to use a steam roller.

Hm, perhaps - is this a limitation of SDL's Audio system running at a
fixed (and not exposed to PyGame) frequency?

As the original poster suggested, it would be really nice to specify the
playback rate at runtime (either dynamically, as the sound is playing, to
achieve doppler effects, or statically, before the sound starts, to get
polyphonic effects (or just to break up monotonous uniform sound effects,
like footsteps).


I've given some thought to this sort of thing over time, and I don't have
any ready solutions, but perhaps one of these would be of use to you:

- if you use WAV files, you could modify the header yourself. Python's
standard library includes the wave module:
http://docs.python.org/lib/module-wave.html

To be practical, you'd probably want to be able to modify the headers on
an in-memory version of the WAV file, or even better, PyGame's Sound
object.



- alternately, you could ditch PyGame's mixer altogether and use an
outside sound library. All of my third-party audio library experience have
been in the C/C++ world, so I can't comment on Python wrappers or
implementations. I am interested to experiment with PySonic someday:
http://pysonic.sourceforge.net/



Bottom line: I agree with the original poster - runtime frequency control
would be really nice.

-Dave LeCompte