In search for questions.

Content by Tyches.
Licensed under CC by.

Theme by nostrich, altered by Tyches.

7th April 2010

Text

Play an MP3 file with pymad and pyao

This is for Mac OS X, adapt to your needs:

import mad, ao, sys

mf = mad.MadFile(sys.argv[1])
dev = ao.AudioDevice('macosx', bits=32, rate=mf.samplerate(), channels=2)
buf = mf.read()
while buf != None:
    dev.play(buf, len(buf))
    buf = mf.read()