Veloura
Veloura is a reusable Python audio transition engine for smooth queue playback. It provides FFmpeg-backed PCM decoding, equal-power crossfades, transition analysis, beat-aware planning, and a small CLI for local inspection.
Veloura is framework-agnostic. Use it in streamer tools, radio pipelines, desktop music apps, Discord/Twitch bots, or backend automation without tying your project to one bot implementation.
Features
- Equal-power crossfade mixing for signed 16-bit PCM audio
- Lossless file transition rendering to FLAC, WAV, ALAC, or AIFF
- Discord-independent PCM queue player with snapshots and playback controls
- Smart transition planning based on track duration, silence trim, and loudness
- Beat/BPM analysis with beat-aware transition plans
- Project-local or user-cache transition analysis storage
- Optional
yt-dlpstream resolution for URLs and search queries - Optional Discord audio source compatibility
- Pure-Python PCM fallback for Python builds without
audioop
Requirements
- Python 3.12 or newer
- Veloura installs
imageio-ffmpegby default and uses its bundled FFmpeg executable when systemffmpegis not available - System
ffplayis only needed for the standalone local player example yt-dlponly when resolving online stream/search inputsdiscord.pyandPyNaClonly when using the Discord audio source directly
0.6.2 Hardening Snapshot
| Area | Fixed behavior |
|---|---|
| Playback failures | Bad FFmpeg streams now surface through queue snapshot errors instead of disappearing silently. |
| CLI health checks | python -m veloura doctor rejects invalid configured FFmpeg paths. |
| Cross-platform playback | PCM stream reads no longer depend on Unix-only pipe select() behavior. |
| Short clips | Crossfade lengths are bounded for very short tracks and lossless renders. |
| Lossless renders | Prepared gain and tempo settings are applied in file renders. |
| Cache safety | Corrupt transition cache values are ignored instead of crashing preparation. |
| Metadata | AudioTrack.from_source() now maps common fields like artist and album directly. |
Installation
Install the core package:
pip install veloura-audio
Install stream resolution support:
pip install "veloura-audio[stream]"
Install Discord voice support:
pip install "veloura-audio[discord]"
Install every optional integration:
pip install "veloura-audio[all]"
Verify the installed package:
python -c "import veloura; print(veloura.__version__)"
python -m veloura doctor
Quick Start
from veloura.audio import AudioTrack, PCMQueuePlayer, transition_preset
config = transition_preset("streamer")
track = AudioTrack.from_source(
"/music/current-song.flac",
title="Artist - Current Song",
duration=184,
)
player = PCMQueuePlayer(volume=0.65, crossfade_seconds=config.base_crossfade_seconds)
player.enqueue(track)
frame = player.read_frame()
For online sources, install veloura-audio[stream] and resolve a playable stream:
import asyncio
from veloura.audio import resolve_stream_track, transition_preset
async def main():
track = await resolve_stream_track(
"artist song official audio",
transition_config=transition_preset("streamer"),
)
print(track.title, track.stream_url)
asyncio.run(main())
CLI
Veloura exposes the same core tools through python -m veloura or the
veloura console script:
python -m veloura presets
python -m veloura doctor
python -m veloura prepare ./song.mp3 --preset streamer
python -m veloura analyze ./song.mp3
python -m veloura plan ./current.mp3 ./next.mp3 --preset broadcast
python -m veloura render-transition ./song-a.flac ./song-b.flac ./transition.flac
For YouTube/search inputs, install veloura-audio[stream] and add --resolve:
python -m veloura plan "current song" "next song" --preset streamer --resolve
Transition analysis is cached under ~/.cache/veloura by default, or under the
directory set in VELOURA_CACHE_DIR. Use --cache-dir for a project-local
cache, or --no-cache when comparing fresh analysis.
Presets
streamer: balanced transitions for livestream/background musicbroadcast: longer, smoother radio-style blendslow-latency: shorter analysis windows for weaker machines or fast queuesautomix: beat-aware pair planning with conservative tempo matching
Aliases such as streamer-safe, broadcast-smooth, auto-mix, and fast are also
available.
For adjacent tracks, call prepare_automix_transition_pair before playback of
the next track starts. It analyzes beat windows, applies a pair-specific
crossfade length, trims weak intro audio on confident matches, and nudges tempo
only within a small safe range.
Apps that manage playback through PCMQueuePlayer can call
player.prepare_next_transition_pair(...) when the current and next track are
known. Discord bots can keep using CrossfadeAudioSource as an adapter for
Discord voice playback.
Lossless Transition Rendering
For local renderers, music apps, and release-prep workflows, Veloura can render two sources into a lossless transition file:
python -m veloura render-transition ./track-a.flac ./track-b.flac ./transition.flac --crossfade 8
Supported output extensions are .flac, .wav, .m4a, .alac, .aif, and
.aiff. The renderer decodes inputs to high-precision float PCM inside FFmpeg,
uses an equal-power-style crossfade curve, and writes a lossless output codec.
Programmatic use:
from veloura.audio import LosslessTransitionConfig, render_lossless_transition
render_lossless_transition(
"track-a.flac",
"track-b.flac",
"transition.flac",
LosslessTransitionConfig(crossfade_seconds=8),
)
This is lossless file transition processing, not bit-perfect copying, because crossfading intentionally changes the waveform. Discord voice output is still encoded by Discord.
Discord Bot Integration
Keep your bot commands, queue state, and permissions in your Discord project. Use Veloura as the audio transition layer:
from veloura.audio import CrossfadeAudioSource, resolve_stream_track, transition_preset
config = transition_preset("streamer")
source = CrossfadeAudioSource(crossfade_seconds=config.base_crossfade_seconds)
track = await resolve_stream_track(
"artist song official audio",
transition_config=config,
)
source.enqueue(track)
voice_client.play(source)
Slash Command Example
Veloura includes a minimal Discord slash-command bot at
examples/discord_slash_bot.py. It provides /play, /queue, /now, /skip,
/stop, and /volume.
pip install "veloura-audio[all]"
export DISCORD_TOKEN="your-bot-token"
export DISCORD_GUILD_ID="your-test-server-id"
python examples/discord_slash_bot.py
DISCORD_GUILD_ID is optional, but recommended for development because server
slash-command sync is much faster than global sync.
When inviting the bot, enable the bot and applications.commands scopes and
grant Connect/Speak voice permissions.
For public bots, treat user search terms and URLs as untrusted input. Keep
permission checks in the bot, rate-limit stream resolution, and avoid exposing
yt-dlp resolution to users who should not be able to trigger network lookups.
Standalone Example
The example player resolves local files or stream queries, prepares transition
analysis, mixes the queue, and pipes PCM into ffplay. This example needs a
system FFmpeg install with ffplay available:
python examples/streamer_player.py ./song-a.mp3 ./song-b.mp3 --preset streamer
python examples/streamer_player.py ./song-a.mp3 ./song-b.mp3 --cache-dir ./veloura-cache
Free Transition Demos
The website includes small playable transition clips rendered from CC0 music
sources. One demo is rendered through PCMQueuePlayer; the lossless demo is
rendered through python -m veloura render-transition into FLAC and WAV output.
Regenerate them with:
python examples/generate_transition_demo_audio.py
Demo music sources:
- Empacotatron by Fupi: https://opengameart.org/content/empacotatron
- Rhythm Garden by congusbongus: https://opengameart.org/content/rhythm-garden
Both source pages list the license as CC0. Attribution is not required by CC0, but Veloura credits the sources so the demo has clear provenance.
Troubleshooting
- Run
python -m veloura doctorto verify FFmpeg and optional integrations. - Set
VELOURA_FFMPEG=/path/to/ffmpegif you want Veloura to use a specific FFmpeg executable instead of the bundled provider. - Set
VELOURA_YTDLP_SOURCE_ADDRESSonly when you needyt-dlpto use a specific outbound network interface. - Install system FFmpeg if you want to use the standalone
ffplayexample. - Install
veloura-audio[stream]when resolving YouTube URLs or search queries throughyt-dlp. - Install
veloura-audio[discord]when usingCrossfadeAudioSourcedirectly with Discord voice playback. - Run
python -m veloura presetsto confirm the CLI entry point is installed.
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 veloura_audio-0.6.2.tar.gz.
File metadata
- Download URL: veloura_audio-0.6.2.tar.gz
- Upload date:
- Size: 56.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a18d93f54a7613fb2f1db599e3ee45689baa240bbd908fe30c04c70412d0ed68
|
|
| MD5 |
4d8f06db5c4bc8dbb8c5c08da4fb9c9f
|
|
| BLAKE2b-256 |
e4ce1482e77fc0f11b2c42281f6433803f7a0ef2f2456fb1ee3c104d3bbc80f1
|
Provenance
The following attestation bundles were made for veloura_audio-0.6.2.tar.gz:
Publisher:
release.yml on VelouraAudio/veloura-audio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
veloura_audio-0.6.2.tar.gz -
Subject digest:
a18d93f54a7613fb2f1db599e3ee45689baa240bbd908fe30c04c70412d0ed68 - Sigstore transparency entry: 1859134074
- Sigstore integration time:
-
Permalink:
VelouraAudio/veloura-audio@21cc44947c3b16ab85462f4e42be29ca0bd47ba6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/VelouraAudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@21cc44947c3b16ab85462f4e42be29ca0bd47ba6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file veloura_audio-0.6.2-py3-none-any.whl.
File metadata
- Download URL: veloura_audio-0.6.2-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d855178a5bb951e4b7efe9b28d3ab9455a09cf904c0769bc1136a05833080f8d
|
|
| MD5 |
ac7c51f60f80c31a550360e1f8f8fa19
|
|
| BLAKE2b-256 |
9f38d29672d2b9ecece08034b4bfca420e5bce234cee99c4bbbfa0ecd9ea171a
|
Provenance
The following attestation bundles were made for veloura_audio-0.6.2-py3-none-any.whl:
Publisher:
release.yml on VelouraAudio/veloura-audio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
veloura_audio-0.6.2-py3-none-any.whl -
Subject digest:
d855178a5bb951e4b7efe9b28d3ab9455a09cf904c0769bc1136a05833080f8d - Sigstore transparency entry: 1859134099
- Sigstore integration time:
-
Permalink:
VelouraAudio/veloura-audio@21cc44947c3b16ab85462f4e42be29ca0bd47ba6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/VelouraAudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@21cc44947c3b16ab85462f4e42be29ca0bd47ba6 -
Trigger Event:
workflow_dispatch
-
Statement type: