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

Re: [pygame] varying sound playback rate



Hi Dave,

Looking at the SDL docs it does look like it's a limitation of that, as you say. Pygame relies upon SDL so it would appear to put the lid on it.

And thanks for the cool suggestions.

I particularly like the idea of altering the WAV header. It has been a while now, but I have a feeling the playback rate is kept in just a single word value. Alter that and I could have what I want. A bit hackish, but nice and simple. Time to hit the docs about WAV headers methinks.

I am a little reluctant to force my end-users to have extra python libs, but if pysonic (or some other library) gives me much greater control I might end up going for that option. I'll look into that.

Perhaps, in the end, using the sound array functions might turn out to be a usable (though far less than optimal) way to go. Some of the other things I want to do (later) require a sound to be filtered in realtime.

It is just frustrating that modern sound cards provide a lot of this stuff in hardware nowadays, and it is sitting there unused and out of reach.

Thanks again for the suggestions.

Best wishes,

	- Miriam


Dave LeCompte (really) wrote:
> 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
>