Recipe10.11.Checking Your Windows Sound System


Recipe 10.11. Checking Your Windows Sound System

Credit: Anand Pillai

Problem

You need to check whether the sound subsystem on your Windows PC is properly configured.

Solution

The winsound module of the Python Standard Library makes this check really simple:

import winsound try:     winsound.PlaySound("*", winsound.SND_ALIAS) except RuntimeError, e:     print 'Sound system has problems,', e else:     print 'Sound system is OK'

Discussion

The sound system might pass this test and still be unable to produce sound correctly, due to a variety of possible problemsstarting from simple ones such as powered loudspeakers being turned off (there's no sensible way you can check for that in your program!), all the way to extremely subtle and complicated ones. When sound is a problem in your applications, using this recipe at least you know whether you should be digging into a subtle issue of device driver configuration or start by checking whether the loudspeakers are on!

See Also

Documentation on the Python Standard Library winsound module.



Python Cookbook
Python Cookbook
ISBN: 0596007973
EAN: 2147483647
Year: 2004
Pages: 420

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net