views:

184

answers:

1

There are several different audio libraries, however, none of them meet my exact needs:
- It needs to be cross-platform.
- It needs to be able to use the ALSA, PulseAudio or any other common default mixer under Linux.
- It needs to be able to autodetect the sample frequency.
- It needs to be (fairly) simple in usage, if instead someone can give me an extra script that will MAKE it easier for me that's accepted too.
- The only functionality I need is play/pause, seeking is a nice bonus.
- It needs to be able to play MP3 and OGG. No other formats are important to me.

The libraries I've tried so far:
PyGame - doesn't support detecting the song's frequency
PyAudiere - promising, but only loads OSS in Linux, with which I have serious mixing problems
Built-in modules - don't support MP3 and OGG as far as I'm aware
PyMedia - promising, but complicated. Also couldn't find out what mixing devices it uses.
PySonic - relies on a closed-source library.
PyQt4.phonon - promising, but wouldn't play anything. Got the following error:

gst_element_make_from_uri: assertion `gst_uri_is_valid (uri)' failed

Any help on this would be appreciated.

+2  A: 

Use gstreamer.


  • It needs to be cross-platform.
  • It needs to be able to use the ALSA, PulseAudio or any other common default mixer under Linux.

Check - From gstreamer website:

GStreamer has been ported to a wide range of operating systems, processors and compilers. This include but are not limited to Linux on i86,PPC, ARM using GCC. Solaris on x86 and SPARC using both GCC and Forte, MacOSX, Microsoft Windows using MS Visual Developer and IBM OS/400.

GStreamer can bridge to other multimedia frameworks in order to reuse existing components (e.g. codecs) and use platform input/output mechanisms:

  • Linux/Unix: OpenMAX-IL (via gst-openmax)
  • Windows: DirectShow
  • MacOS X: QuickTime


  • It needs to be able to autodetect the sample frequency.

Okay.

  • It needs to be (fairly) simple in usage, if instead someone can give me an extra script that will MAKE it easier for me that's accepted too.

Gstreamer has a lot of documentation and examples, and a strong community to give you support.

  • The only functionality I need is play/pause, seeking is a nice bonus.
  • It needs to be able to play MP3 and OGG. No other formats are important to me.

Then those are overwhelmed!

Go get yours!

nosklo
PERFECT! I got audio working in mere minutes! Audio switching is also a breeze. Thanks a lot! :)Now I wonder why gstreamer is mentioned as "platform dependent" on <a href="http://wiki.python.org/moin/Audio/">this page</a>...
DaVince
Oops, no link tag allowed on StackOverflow apparently.
DaVince
@DaVince: The information that it is platform-dependent was added in 2007-11-23 14:30:37, that is, more than 2 years ago. Maybe things changed since then.
nosklo
No native windows builds.
Nazarius Kappertaal
Nazarius: Huh? http://www.gstreamer-winbuild.ylatuya.es/doku.php?id=download
nosklo