Who wrote Linux Audio Dev?

pehr anderson pehr at pehr.net
Wed Sep 20 07:29:24 CEST 2000

Dear Aaron,

I am using the pyesd library to add 
interactive audio to my apps under linux. 
It has worked very well for me so far.
I really like the pyesd interface and would
absolutely love it if we could turn that into
the de-facto cross-platform audio interface for python.
I'm sure some enterprising young windows hacker could 
create a shim layer that would make the windows code 
do the same thing.


I also use the Festival speech synthesizer 
but it doesn't sound as good as a human being ;)

Here is some example code of how I use pyesd if available, 
othewise calling the esd shell routines and taking 
a performance hit.
#NOTE: My example code here is not generalized! 
#It assumes that .WAV files have a specific set of paramters.

    # esd is provided by pyesd, which is a separate RPM file
    import esd,wave
    class Esound:
        """ If pyesd is installed, we can use the esdclient library
        to make playback faster
        cache = {}
        def __init__(self):
            """ Start the Esound Daemon """
            errcode = os.system("esd >& /dev/null &")
            self.s = esd.ServerSession()
        def play(self, soundfile):
            name = string.replace(soundfile,"/","-")
            name = string.replace(name,".","-")
            if self.cache.has_key(name):
                w = wave.open(soundfile,"r")
                audio = w.readframes(100000)
                sample = esd.Sample(esd.ESD_PLAY | esd.ESD_BITS16 |
                                    esd.ESD_DEFAULT_RATE, audio)
                self.cache[name] = self.s.cacheSample(sample,name)

except ImportError:
    # This should work, rain or shine
    class Esound:
        def __init__(self):
            """ Start the Esound Daemon """
            errcode = os.system("esd >& /dev/null &")

        def play(self, soundfile):
            os.system("esdplay %s >& /dev/null" % soundfile)

Aaron Berg wrote:
> I have a very important question. Who wrote linuxaudiodev??? First off
> it doesn's seem to work. Secondly there is no documentation. Please
> prove me wrong! :-)
> Anyways I would like to try using this module to do some sound work in
> linux. If anyone knows how it works or where I can find some
> documentation let me know. I am also willing to try document it or get
> it working 100% since I need both anyways. Thanks,
> Aaron C. Berg
> Aaron.Berg at mnsu.edu

More information about the Python-list mailing list