[python-win32] Python sound playback threading control?

Tim Roberts timr at probo.com
Thu Feb 14 19:04:42 CET 2013


Jacob Kruger wrote:
> Well, it's currently making use of the sound_lib module - not sure which API 
> it's using as such -

It's a wrapper around the "BASS" library, which is itself a wrapper
around the lower-level APIs.  The BASS library itself is an abstraction
-- it lets you think in terms of whole files, rather than individual PCM
packets.  As a result, you give up a certain amount of low-level control.

However, you should be able to "pause" and "stop" the streaming.


> but am using the stream object's play_blocking() 
> method, which seems to be meant to interrupt other playbacks, 

Not at all!  A blocking function means that it starts the playback, and
then waits until the entire file is played, so that it cannot be
interrupted.  If you want to interrupt things, that's exactly the WRONG
interface.  You should be using "play".


> Alternatively, any thoughts on something simple could try using that would 
> offer something similar in terms of just, at least being able to manipulate 
> playback pitch, at least 2D panning, pausing/stopping on demand, etc.?

You've crossed a number of different domains there.  You have certainly
exited from the realm of "something simple".  sound_lib will help you
manage your streams (play, pause, stop, etc).  Manipulating the pitch
requires that you manipulate the sound files themselves.  You will have
to decode the files by hand, and run an algorithm on the decoded byte
streams.  2D panning requires low-level access to the speaker
configuration, which is yet another domain.

You might start looking here to see if you can find the type of
resources you need.
    http://wiki.python.org/moin/PythonInMusic

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list