/pyxaudio

Basic Cython bindings for FFmpeg, Pulseaudio and Alsa

Primary LanguageCythonGNU General Public License v2.0GPL-2.0

pyxaudio

Abstract

pyxaudio provides audio support for Python on Linux. Audio processing is done using the FFmpeg library, Pulseaudio and Alsa can be used for playback. pyxaudio is intentionally kept basic and simple.

Dependencies

The version numbers merely reflect which versions I have been using during development.

Example

import sys
import pyxaudio

# Open the playback sink.
sink = pyxaudio.Sink()

for url in sys.argv[1:]:
    if sys.version_info.major == 2:
        # pyxaudio needs all strings as unicode objects.
        url = url.decode(sys.getfilesystemencoding())

    # Create a new decoding source for the url.
    source = pyxaudio.Source(url)

    # Configure the sink.
    sink.setup(source)

    while True:
        buf = source.read(8192)
        if not buf:
            break
        sink.write(buf)

    # Clean up.
    source.close()
sink.close()