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.
- Effects : FadeIn, FadeOut, ChangeSpeed
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
from rpaudio import FadeIn, FadeOut, ChangeSpeed
kill_audio = False
AUDIO_FILE = r"C:\Users\16145\Desktop\exc.mp3"
def on_audio_stop():
global kill_audio
kill_audio = True
print("Audio has stopped")
async def play_audio():
handler = rpaudio.AudioSink(callback=on_audio_stop).load_audio(AUDIO_FILE)
print(handler.metadata)
await asyncio.sleep(0.5)
fade_in_effect = FadeIn(start_val=0.0, end_val=1.0, apply_after=handler.get_pos(), duration=3.0)
fade_out_effect = FadeOut(duration=6.0, apply_after=handler.get_pos() + 7.0)
speed_up = ChangeSpeed(apply_after=3.0, end_val=1.5, duration=3.0)
effects_list = [speed_up, fade_in_effect, fade_out_effect]
handler.apply_effects(effects_list)
handler.set_volume(0.0)
handler.play()
while not kill_audio:
await asyncio.sleep(1)
async def sleep_loop():
global kill_audio
i = 0
while not kill_audio:
await asyncio.sleep(1)
i += 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.6-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7006391e558a3178e2def9f046bf97ee516af3861affd7636242802306a2369a |
|
MD5 | 0a31944cd12882572bd9f457994e8a8c |
|
BLAKE2b-256 | 625cbd665ae02e3d3b6e86224ef3036cff28e7b70a21b9dd34dae8be923ff7f4 |
Hashes for rpaudio-0.0.6-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14db454133fad472b3ba69b14b9e51a708c37a35d82a292578efd720532897d1 |
|
MD5 | bc1766bea6648745a1c69c32f630f50c |
|
BLAKE2b-256 | 51bfa65b21c29fe29b5924a9d1484c6c40537854368d2c72593587c605b97347 |
Hashes for rpaudio-0.0.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3633eb66ed98226d1740cc17d1187796a79666e316e404d8d1cad36612058fe3 |
|
MD5 | 5e99668a7d36f55ffef33c532c255881 |
|
BLAKE2b-256 | 23fd779f3bc53ea97fec59e32b4ef72c106ef5cf150d031319bb9b0251c542cc |
Hashes for rpaudio-0.0.6-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1272167e23618327f7f283110c69b777bd3db17ed3be9233dbe9b46c3a31f67 |
|
MD5 | 96b17a4be3d035ff1192a66c31fa19f6 |
|
BLAKE2b-256 | 79804e5a9203d767613bb29515ba200f301815af4f2b05631e0744bba661880f |
Hashes for rpaudio-0.0.6-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 006704ddffcaa8da81cb44805e69a935de22c122a6dfabf91fe1e116166ffe86 |
|
MD5 | 5169c890c45906aa71a767d0207ee288 |
|
BLAKE2b-256 | 53fdfb689ccca9e6eb20ff6ba20397da4c45c4cb62daa4b5695fb78d42a01c13 |
Hashes for rpaudio-0.0.6-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abaa1dc8a162cf8963ea89304aee642bcb8c83537939f84d99cf0ba946190079 |
|
MD5 | 7d9f4af6d58069e0750b04a63ee8c4fc |
|
BLAKE2b-256 | 89a312d79a9f87c52f819e70b4a3e821de0cdfab54ddd589c1767c5714e79308 |