Skip to main content

ALSA C library bindings using ctypes for Python

Project description

pythonalsa

Python bindings for ALSA (Advanced Linux Sound Architecture) using ctypes. Control audio mixers, volume levels, and mute states directly from Python without external dependencies.

Features

  • Pure Python implementation using ctypes (no compiled extensions)
  • Control volume levels (raw values and percentages)
  • Mute/unmute audio channels
  • List all available sound cards and mixer elements
  • Clean, Pythonic API with context managers

Requirements

  • Python 3.9 or higher
  • Linux system with ALSA (libasound.so.2)

Installation

pip install pythonalsa

Usage

from pythonalsa import Card, Mixer, list_cards

# Get the default card
card = Card()
print(f"Default card: {card.name}")

# Or get a specific card
card = Card(0)

# List all cards
for card in list_cards():
    print(f"Card {card.index}: {card.name}")

# List mixers for a card
for mixer in card.list_mixers():
    print(f"Mixer: {mixer.name}")

# Get a specific mixer
mixer = card.get_mixer("Master")

# Or create mixer directly
mixer = Mixer(card=card, name="Master")

# Volume control
print(f"Current volume: {mixer.volume_percent}%")
mixer.volume_percent = 75

# Raw volume
min_vol, max_vol = mixer.volume_range
print(f"Volume range: {min_vol} - {max_vol}")
mixer.volume = 23

# Mute control
print(f"Muted: {mixer.muted}")
mixer.muted = True
mixer.muted = False

API Reference

See docstrings for Card, Mixer, list_cards, and ALSAError.

License

GPL-3.0-or-later

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythonalsa-0.1.1.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pythonalsa-0.1.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file pythonalsa-0.1.1.tar.gz.

File metadata

  • Download URL: pythonalsa-0.1.1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pythonalsa-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fd3ad2a318d26f65c02b5965a449a6dac8dc09ed5a30f5bb0b325767074e5dc5
MD5 ffe2aeda4a02f01730467b26bf5a6bef
BLAKE2b-256 6e1ae091060b838d6fec5fcdd91aa8ac0b3ef04ec58e9ea85a8291eba34f3659

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythonalsa-0.1.1.tar.gz:

Publisher: publish.yml on 865charlesw/pythonalsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pythonalsa-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pythonalsa-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pythonalsa-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec7bf403f116a5052ce04a2aa9557b04c58dadf6b7f36763cbd7bfba298b76a2
MD5 f7463c635d8d5af8acc681de0ab49796
BLAKE2b-256 391575ffd9882a1393b56a48a452c88e6e852b4d14c36d0650a280b3c430e303

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythonalsa-0.1.1-py3-none-any.whl:

Publisher: publish.yml on 865charlesw/pythonalsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page