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, iter_cards, and ALSAError.
License
GPL-3.0-or-later
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pythonalsa-0.1.2.tar.gz.
File metadata
- Download URL: pythonalsa-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69965e4dd6020d6dc21243d6cd28bab9314918b0d35252f812b3f245fe33f749
|
|
| MD5 |
dd87103c069ec5887d49d771192de44a
|
|
| BLAKE2b-256 |
61f9695b241b27066076b8c1325c72260917bf7a3f0ed6406b1703c9c6e127f1
|
Provenance
The following attestation bundles were made for pythonalsa-0.1.2.tar.gz:
Publisher:
publish.yml on 865charlesw/pythonalsa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pythonalsa-0.1.2.tar.gz -
Subject digest:
69965e4dd6020d6dc21243d6cd28bab9314918b0d35252f812b3f245fe33f749 - Sigstore transparency entry: 653046034
- Sigstore integration time:
-
Permalink:
865charlesw/pythonalsa@41c9b4e217f047025819d9eae5e4f6c5d478fd3b -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/865charlesw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@41c9b4e217f047025819d9eae5e4f6c5d478fd3b -
Trigger Event:
push
-
Statement type:
File details
Details for the file pythonalsa-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pythonalsa-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09599ca90ab119517b5afa22e224461a32e30be7b1b157e3f82a8eeb4c13d0fc
|
|
| MD5 |
7c27b5b6a1d09be85740d0b30ffbc9be
|
|
| BLAKE2b-256 |
780a91421ae0c5915d370f10566c8bd1e479db6c89777d00113c8b6e25429945
|
Provenance
The following attestation bundles were made for pythonalsa-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on 865charlesw/pythonalsa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pythonalsa-0.1.2-py3-none-any.whl -
Subject digest:
09599ca90ab119517b5afa22e224461a32e30be7b1b157e3f82a8eeb4c13d0fc - Sigstore transparency entry: 653046050
- Sigstore integration time:
-
Permalink:
865charlesw/pythonalsa@41c9b4e217f047025819d9eae5e4f6c5d478fd3b -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/865charlesw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@41c9b4e217f047025819d9eae5e4f6c5d478fd3b -
Trigger Event:
push
-
Statement type: