Professional-grade audio analysis tool with EBU R128 loudness measurement
Project description
rs_audio_stats
Professional-grade audio analysis tool with EBU R128 loudness measurement for Python.
Overview
rs_audio_stats provides comprehensive audio analysis capabilities including loudness measurement according to EBU R128 standard (ITU-R BS.1770-4), true peak detection, RMS calculations, and audio normalization functions.
Installation
pip install rs_audio_stats
Quick Start
import rs_audio_stats as ras
# Analyze audio file
info, results = ras.analyze_audio("audio.wav", True, False, False, False, True, False, False)
print(f"Integrated Loudness: {results.integrated_loudness:.1f} LUFS")
print(f"True Peak: {results.true_peak:.1f} dBFS")
# Batch analyze directory
results = ras.batch_analyze_directory("audio_folder/", True, False, False, False, True, False, False)
for file_path, (info, analysis) in results.items():
print(f"{file_path}: {analysis.integrated_loudness:.1f} LUFS")
Core Features
📊 Audio Information
- ✅ Sample rate, channels, bit depth (-sr, -ch, -bt)
- ✅ Duration in seconds and formatted time (-du, -tm)
- ✅ Total samples and format detection (-f, -fe, -fea)
🎚️ Loudness Analysis (EBU R128)
- ✅ Integrated loudness measurement (-i)
- ✅ Short-term loudness (-s)
- ✅ Momentary loudness (-m)
- ✅ Loudness range (LRA) (-l)
- ✅ True peak detection (-tp)
- ✅ RMS maximum and average (-rm, -ra)
🎛️ Audio Normalization
- ✅ True peak normalization (-norm-tp)
- ✅ Integrated loudness normalization (-norm-i)
- ✅ Short-term loudness normalization (-norm-s)
- ✅ Momentary loudness normalization (-norm-m)
- ✅ RMS maximum normalization (-norm-rm)
- ✅ RMS average normalization (-norm-ra)
📁 Export Formats
- ✅ CSV export (-csv)
- ✅ TSV export (-tsv)
- ✅ XML export (-xml)
- ✅ JSON export (-json)
🔄 Batch Processing
- ✅ Single file analysis
- ✅ Directory batch processing
- ✅ Recursive file discovery
- ✅ Multiple format support
API Reference
analyze_audio()
info, results = analyze_audio(
file_path: str,
integrated_loudness: bool = False,
short_term_loudness: bool = False,
momentary_loudness: bool = False,
loudness_range: bool = False,
true_peak: bool = False,
rms_max: bool = False,
rms_average: bool = False
)
batch_analyze_directory()
results = batch_analyze_directory(
directory_path: str,
integrated_loudness: bool = False,
short_term_loudness: bool = False,
momentary_loudness: bool = False,
loudness_range: bool = False,
true_peak: bool = False,
rms_max: bool = False,
rms_average: bool = False
)
Normalization Functions
# True peak normalization
normalize_true_peak(input_path: str, target_dbfs: float, output_path: str)
# Integrated loudness normalization
normalize_integrated_loudness(input_path: str, target_lufs: float, output_path: str)
# Short-term loudness normalization
normalize_short_term_loudness(input_path: str, target_lufs: float, output_path: str)
# Momentary loudness normalization
normalize_momentary_loudness(input_path: str, target_lufs: float, output_path: str)
Export Functions
# Export analysis results
export_to_csv(results, output_path: str)
export_to_tsv(results, output_path: str)
export_to_xml(results, output_path: str)
export_to_json(results, output_path: str)
Use Cases
Broadcasting
# Check compliance with broadcast standards
info, results = ras.analyze_audio("broadcast.wav", True, False, False, True, True, False, False)
if results.integrated_loudness < -23.0:
print("Meets EBU R128 broadcast standard")
Music Production
# Analyze dynamics and prepare for mastering
info, results = ras.analyze_audio("song.wav", True, True, True, True, True, True, True)
print(f"Dynamic Range: {results.loudness_range:.1f} LU")
Podcast Processing
# Batch normalize podcast episodes
episodes = ras.batch_analyze_directory("episodes/", True, False, False, False, True, False, False)
for file_path, (info, analysis) in episodes.items():
if analysis.integrated_loudness < -16.0:
output_path = file_path.replace(".wav", "_normalized.wav")
ras.normalize_integrated_loudness(file_path, -16.0, output_path)
Supported Formats
- WAV (all PCM variants)
- FLAC
- MP3
- AAC/M4A
- OGG/Vorbis
- And many more via Symphonia decoder
Requirements
- Python 3.10+
- Windows, macOS, or Linux
License
MIT License
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 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 rs_audio_stats-1.1.7-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: rs_audio_stats-1.1.7-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fcb248b1e31b92b4de55189aad229d7ba28c47eec32ea13e4b763c7aa0bdde8
|
|
| MD5 |
8ed0f002bf445a5d9e40f89470e05f01
|
|
| BLAKE2b-256 |
9bf9ddb705d4468876362a8f99d2112be119b05ceb553dab809c0c6d3c1a43c0
|