Rust audio api binding for python
Project description
rpaudio
rpaudio
is a Rust-based Python library for handling audio operations, designed to provide simple and efficient audio management. It leverages Rust's performance and concurrency safety to offer a robust solution for Python audio applications.
API
- AudioSink: Simple audio access and control for individual files.
- AudioChannel: Handle and process audio files in a queue via channels.
- ChannelManager: Multi-channel grouping and management.
- AudioSink.metadata Access information about audio files if present.
Supports: MP3, WAV, Vorbis and Flac (mp4 + AAC will also be supported in a future release)
Python 3.8+
Getting Started (Read the Docs)
import rpaudio
import asyncio
def on_audio_stop():
print("Audio has stopped")
async def play_audio():
handler = rpaudio.AudioSink(callback=on_audio_stop).load_audio("Acrylic.mp3")
# Set a fade in on the audio sink
handler.set_fade_in(5.0, 0.1, 0.2)
handler.play()
count = 0
while True:
await asyncio.sleep(1)
count += 1
if count == 4:
# Pause the audio for 2 seconds
print ("Pausing audio")
handler.pause()
if count == 6:
# Resume the audio, but turn down the volume
print("Resuming audio, lowering volume")
handler.set_volume(0.5)
handler.play()
if count == 8:
# Seek to 10 seconds
print(f"Current position: {handler.get_pos()}")
handler.try_seek(10.)
await asyncio.sleep(1)
print(f"Position after seek: {handler.get_pos()}")
if count == 10:
# Change the playback speed to 1.5
handler.set_speed(1.5)
print(f"Playback speed: {handler.get_speed()}")
await asyncio.sleep(1)
handler.stop()
async def sleep_loop():
for i in range(10):
print(f"Sleeping {i}")
await asyncio.sleep(1)
async def main():
await asyncio.gather(play_audio(), sleep_loop())
asyncio.run(main())
OS Dependency Installation Instructions
Windows
No additional OS-level dependencies are required for rpaudio
on Windows. Ensure you have the latest version of Python installed, and you can directly use pip
to install the library:
pip install rpaudio
macOS
To install rpaudio
on macOS, you need to install gettext
:
Install gettext
:
brew install gettext
brew link gettext --force
Linux
To install rpaudio
on Linux, you may need to install some dependencies based on your distribution:
For Debian/Ubuntu-based distributions:
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev
For Red Hat/CentOS-based distributions:
sudo yum install -y pkg-config alsa-lib-devel
After installing the necessary OS-level dependencies, you can install rpaudio
using pip
:
pip install rpaudio
Contributing
Please read CONTRIBUTING.md for guidelines on how to contribute.
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 Distributions
Built Distributions
Hashes for rpaudio-0.0.5-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cde0df44bf3eab566d7e1e6004a1004a3ac3a69aa6b983090ea6f79c1508fa7 |
|
MD5 | f5b8bfd2bd681c22aab15640a2824298 |
|
BLAKE2b-256 | aa471a1abf68e39d1c603063dd89e38b884564bd2b92d28092b9264a1711389e |
Hashes for rpaudio-0.0.5-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3015a06f3315db0cb7a7e9b0641cddf1ce465595638a0baf1a7b8b7070e0384 |
|
MD5 | 3701803e4519fe01a7e16aea0b927025 |
|
BLAKE2b-256 | b2798698e5f9d92d041e621025cc25be1398307129bb8efba58eb0541da1046f |
Hashes for rpaudio-0.0.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 352c951180105c32c1180ed9d904c9ca2375d1d3b3026430db65db3172fed86d |
|
MD5 | 167f7831d4d4449bd989b2b904c807e4 |
|
BLAKE2b-256 | 9cd079503fcd2f46fbbfe7d85b6f72cd8585343fc9ab82dfebe13e4d488d2baa |
Hashes for rpaudio-0.0.5-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0791423be1e6fdbb272a369f4c2ddfe40378280f6517b51ede9d7f1c8ca39fb |
|
MD5 | baa08d018fb6d7824683b72297fc1120 |
|
BLAKE2b-256 | 0cb394531192299e354156ff8b58326a680d48b32173ea99c4dafca8ec87f616 |
Hashes for rpaudio-0.0.5-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6a02805b8d84710c5f13eb23004990c8cd805a766c697b8301409c39f78559d |
|
MD5 | 95079bb3f839097ab77f8466185e4507 |
|
BLAKE2b-256 | 43dd641330e145ac3f63ab0b797592f68dcbfb8b4126dbfd16210883a5d75620 |
Hashes for rpaudio-0.0.5-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96001a16f1212bbcf8c9c8c9276be9ee6f479c7ffc0aea2a7e15d3ebc5ee846c |
|
MD5 | 9dce79308d9d363679e9b5dbcf8c059f |
|
BLAKE2b-256 | f2bce0bc77a8d5732f27928cef67bb5cfb72de98fbc4df4425420a7542b76213 |