High-performance audio analysis library with EBU R128 loudness measurement, powered by Rust
Project description
rs_audio_stats
高性能オーディオ分析ライブラリ - EBU R128ラウドネス測定、Rustによる高速処理
概要
rs_audio_statsは、プロフェッショナルグレードのオーディオ分析ツールです。EBU R128標準に準拠したラウドネス測定と、高精度なオーディオノーマライゼーション機能を提供します。Rustで実装されており、高速かつ効率的な処理が可能です。
主な特徴
- EBU R128準拠: 業界標準のラウドネス測定アルゴリズム
- 高速処理: Rustによる最適化された実装
- 包括的な分析: 統合ラウドネス、短期ラウドネス、瞬間ラウドネス、ラウドネスレンジ、トゥルーピーク、RMS値の測定
- ノーマライゼーション: 様々な基準でのオーディオノーマライゼーション
- バッチ処理: 複数ファイルの一括分析
- 多形式対応: WAV、MP3、FLAC、AAC、OGG等、様々なオーディオフォーマットをサポート
- エクスポート機能: CSV、TSV、JSON、XML形式での結果エクスポート
インストール
pipを使用したインストール
pip install rs-audio-stats
要件
- Python 3.10以上、3.12以下
- Windows、macOS、Linuxをサポート
クイックスタート
基本的な使用方法
import rs_audio_stats
# オーディオファイルの分析
audio_info, results = rs_audio_stats.analyze_audio(
"audio.wav",
integrated_loudness=True,
true_peak=True
)
print(f"統合ラウドネス: {results.integrated_loudness} LUFS")
print(f"トゥルーピーク: {results.true_peak} dBFS")
# ターゲットLUFSレベルへのノーマライゼーション
rs_audio_stats.normalize_to_lufs("input.wav", -16.0, "output.wav")
# ディレクトリ内の全オーディオファイルを分析
results = rs_audio_stats.batch_analyze_directory(
"audio_folder",
integrated_loudness=True,
true_peak=True
)
主要機能
1. オーディオ分析
analyze_audio()
個別のオーディオファイルを分析します。
audio_info, results = rs_audio_stats.analyze_audio(
file_path="audio.wav",
integrated_loudness=True, # 統合ラウドネス測定
short_term_loudness=True, # 短期ラウドネス測定
momentary_loudness=True, # 瞬間ラウドネス測定
loudness_range=True, # ラウドネスレンジ測定
true_peak=True, # トゥルーピーク測定
rms_max=True, # 最大RMS測定
rms_average=True # 平均RMS測定
)
analyze_audio_all()
全ての測定項目を一度に分析します。
audio_info, results = rs_audio_stats.analyze_audio_all("audio.wav")
2. ノーマライゼーション
統合ラウドネスノーマライゼーション
rs_audio_stats.normalize_integrated_loudness(
input_path="input.wav",
target_lufs=-16.0, # ターゲットLUFS
output_path="output.wav"
)
トゥルーピークノーマライゼーション
rs_audio_stats.normalize_true_peak(
input_path="input.wav",
target_dbfs=-1.0, # ターゲットdBFS
output_path="output.wav"
)
短期ラウドネスノーマライゼーション
rs_audio_stats.normalize_short_term_loudness(
input_path="input.wav",
target_lufs=-18.0,
output_path="output.wav"
)
瞬間ラウドネスノーマライゼーション
rs_audio_stats.normalize_momentary_loudness(
input_path="input.wav",
target_lufs=-15.0,
output_path="output.wav"
)
3. バッチ処理
ディレクトリ一括分析
results = rs_audio_stats.batch_analyze_directory(
directory_path="audio_folder",
integrated_loudness=True,
short_term_loudness=True,
true_peak=True
)
for file_path, (audio_info, analysis_results) in results.items():
print(f"{file_path}:")
print(f" ラウドネス: {analysis_results.integrated_loudness} LUFS")
print(f" ピーク: {analysis_results.true_peak} dBFS")
複数ファイルの分析
files = ["file1.wav", "file2.mp3", "file3.flac"]
results = rs_audio_stats.batch_analyze(
file_paths=files,
integrated_loudness=True,
true_peak=True
)
4. エクスポート機能
CSV形式でエクスポート
rs_audio_stats.export_to_csv(
file_paths=["audio1.wav", "audio2.wav"],
output_path="results.csv",
integrated_loudness=True,
true_peak=True
)
JSON形式でエクスポート
rs_audio_stats.export_to_json(
file_paths=["audio.wav"],
output_path="results.json",
integrated_loudness=True,
short_term_loudness=True,
momentary_loudness=True,
loudness_range=True,
true_peak=True
)
5. ユーティリティ関数
オーディオ情報の取得
audio_info = rs_audio_stats.get_audio_info_py("audio.wav")
print(f"サンプルレート: {audio_info.sample_rate} Hz")
print(f"チャンネル数: {audio_info.channels}")
print(f"ビット深度: {audio_info.bit_depth}")
print(f"長さ: {audio_info.duration_seconds} 秒")
ラウドネスの取得(簡易版)
loudness = rs_audio_stats.get_loudness("audio.wav")
print(f"ラウドネス: {loudness} LUFS")
トゥルーピークの取得(簡易版)
peak = rs_audio_stats.get_true_peak("audio.wav")
print(f"トゥルーピーク: {peak} dBFS")
オーディオファイルの検索
audio_files = rs_audio_stats.find_audio_files("audio_directory")
print(f"見つかったオーディオファイル: {len(audio_files)}個")
実用例
例1: ポッドキャスト用オーディオの準備
import rs_audio_stats
# ポッドキャストの推奨レベル: -16 LUFS
input_file = "podcast_raw.wav"
output_file = "podcast_normalized.wav"
# 現在のラウドネスを確認
_, results = rs_audio_stats.analyze_audio(
input_file,
integrated_loudness=True,
true_peak=True
)
print(f"現在のラウドネス: {results.integrated_loudness} LUFS")
# -16 LUFSにノーマライズ(トゥルーピークは-1dBFS以下を維持)
rs_audio_stats.normalize_integrated_loudness(
input_file,
-16.0,
output_file
)
# ノーマライズ後の確認
_, results = rs_audio_stats.analyze_audio(
output_file,
integrated_loudness=True,
true_peak=True
)
print(f"ノーマライズ後: {results.integrated_loudness} LUFS")
print(f"トゥルーピーク: {results.true_peak} dBFS")
例2: アルバムのマスタリング分析
import rs_audio_stats
import os
album_directory = "album_masters"
# アルバム全体の分析
results = rs_audio_stats.batch_analyze_directory(
album_directory,
integrated_loudness=True,
loudness_range=True,
true_peak=True
)
# 統計情報の計算
loudness_values = []
peak_values = []
for file_path, (info, analysis) in results.items():
if analysis.integrated_loudness is not None:
loudness_values.append(analysis.integrated_loudness)
if analysis.true_peak is not None:
peak_values.append(analysis.true_peak)
print(f"{os.path.basename(file_path)}:")
print(f" ラウドネス: {analysis.integrated_loudness} LUFS")
print(f" レンジ: {analysis.loudness_range} LU")
print(f" ピーク: {analysis.true_peak} dBFS")
# アルバム全体の平均
if loudness_values:
avg_loudness = sum(loudness_values) / len(loudness_values)
max_peak = max(peak_values)
print(f"\nアルバム平均ラウドネス: {avg_loudness:.1f} LUFS")
print(f"アルバム最大ピーク: {max_peak:.1f} dBFS")
例3: ストリーミング配信用の一括処理
import rs_audio_stats
import os
# Spotify推奨: -14 LUFS
# Apple Music推奨: -16 LUFS
# YouTube推奨: -14 LUFS
def prepare_for_streaming(input_dir, output_dir, platform="spotify"):
targets = {
"spotify": -14.0,
"apple": -16.0,
"youtube": -14.0
}
target_lufs = targets.get(platform, -14.0)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# オーディオファイルを検索
audio_files = rs_audio_stats.find_audio_files(input_dir)
for file_path in audio_files:
filename = os.path.basename(file_path)
output_path = os.path.join(output_dir, filename)
print(f"処理中: {filename}")
# ノーマライズ
rs_audio_stats.normalize_integrated_loudness(
file_path,
target_lufs,
output_path
)
# 結果確認
_, results = rs_audio_stats.analyze_audio(
output_path,
integrated_loudness=True,
true_peak=True
)
print(f" → {results.integrated_loudness} LUFS, {results.true_peak} dBFS")
print(f"\n{len(audio_files)}個のファイルを{platform}用に最適化しました")
# 使用例
prepare_for_streaming("original_audio", "spotify_ready", "spotify")
データ構造
AudioInfo
オーディオファイルの基本情報を格納します。
class AudioInfo:
sample_rate: int # サンプルレート (Hz)
channels: int # チャンネル数
bit_depth: int # ビット深度
duration_seconds: float # 長さ(秒)
AnalysisResults
分析結果を格納します。
class AnalysisResults:
integrated_loudness: float | None # 統合ラウドネス (LUFS)
short_term_loudness: float | None # 短期ラウドネス (LUFS)
momentary_loudness: float | None # 瞬間ラウドネス (LUFS)
loudness_range: float | None # ラウドネスレンジ (LU)
true_peak: float | None # トゥルーピーク (dBFS)
rms_max: float | None # 最大RMS (dB)
rms_average: float | None # 平均RMS (dB)
サポートフォーマット
- ロスレス: WAV, FLAC, AIFF, ALAC
- ロッシー: MP3, AAC, OGG Vorbis, WMA
- その他: M4A, MP4 (audio), WebM (audio)
パフォーマンス
rs_audio_statsは高速処理を重視して設計されています:
- WAVファイル: 超高速モード使用で最大10倍の処理速度
- 並列処理: マルチコアCPUを活用した効率的な処理
- メモリ効率: ストリーミング処理による低メモリ使用量
- SIMD最適化: 可能な場合はSIMD命令を使用
トラブルシューティング
インストールエラー
# Rustコンパイラが必要な場合
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
メモリ不足エラー
大きなファイルを処理する際は、チャンク処理を使用:
# 大きなファイルの場合は分割処理を推奨
# バッチ処理を使用して複数のファイルを順次処理
ライセンス
MITライセンス
作者
Hiroshi Tamura
リンク
サポート
問題や質問がある場合は、GitHubのIssueページでお知らせください。
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
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.3.9-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 378.5 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4974af8333dfd8c4e5a66a173eb92eea7b871bd6c23e19ba1cf9b4226f83c04
|
|
| MD5 |
e4a50b574e2019d9bd35edfda44b5b81
|
|
| BLAKE2b-256 |
a95c8297125c12a583ff90bd7f8ce611e66675f4b744a8cca480337e896afc3a
|
File details
Details for the file rs_audio_stats-1.3.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 569.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04bfd4248b3f1982478aea0e77f16067173d989c6bc48f567165aeb88ed9b200
|
|
| MD5 |
2f304cdad6b291d0cdcf2fe8e469a951
|
|
| BLAKE2b-256 |
687620fd5698d02df91bb5cbd37a38663bc5d701f70c3f3592877a48d086a9ed
|
File details
Details for the file rs_audio_stats-1.3.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 600.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
461176cb86e3e7ee292c5f47837c91d06b44799a0db0aa280e35130c774cc799
|
|
| MD5 |
13614f0521923e47f4a85e12a72892e5
|
|
| BLAKE2b-256 |
a4c3dc549967d158ff8262f65e9ee624a6234f02af8c20e4c54b7cddf5a12082
|
File details
Details for the file rs_audio_stats-1.3.9-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 499.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e325c1e808b3fbf695c2c1f86349f05e1c14fd7fb9a01a3bb139e49b98ebef6b
|
|
| MD5 |
37b035ebac6f094c46e27e41b0540eae
|
|
| BLAKE2b-256 |
10dd8b514ba8bd7a9b37c6c80fd2048bd90024158573232c164d68d9781d58d9
|
File details
Details for the file rs_audio_stats-1.3.9-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 511.5 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2d80a357367b450a93da82d9145184b48eba22a1d011141f35264db804cfe03
|
|
| MD5 |
a2c949c5dffa811745a33d2536e4d265
|
|
| BLAKE2b-256 |
0563e572f43dc2c6d711d27ea92a53d6113007d7da9b7a06b13433cc01ceae2e
|
File details
Details for the file rs_audio_stats-1.3.9-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 369.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d641930770c848f3cc087ad9075496b91caea85bbe1cd81d9bde0270baa8eea
|
|
| MD5 |
9220597c32c7bd69b6f55ceb54dee5da
|
|
| BLAKE2b-256 |
cfb750be52382335995595c9934df08407820bdac01a581f6182b0ba1c4cfc76
|
File details
Details for the file rs_audio_stats-1.3.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 570.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6918fd4694149d473b1bed67c0b812808cf770e50e950b7181aada4e97aa8a1
|
|
| MD5 |
40f17b99541ff9c5b5e04bbf8b66fa2a
|
|
| BLAKE2b-256 |
6a4b51517c8358b969040235d3ad445da727be4513b1f8bcdc93533c7a1a2ae5
|
File details
Details for the file rs_audio_stats-1.3.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 600.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55e7645d94cf4fd4f0f6eff16a59b669f15abc73da6126b4960a4d4111e8afd2
|
|
| MD5 |
4d3e11f76eb302bd316ad789cbedb17a
|
|
| BLAKE2b-256 |
ce711f507773888b5e168a424a93820c18d194da232f439c08558a07a858735d
|
File details
Details for the file rs_audio_stats-1.3.9-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 501.7 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac5aa5bd60fdc0aceb8f74f39cd8e7ef4525ab3cbada2df7f14fb74b230eb057
|
|
| MD5 |
91a074d2174ac4122150428529f7c7a6
|
|
| BLAKE2b-256 |
dbdf3db2960c9e64d118faa82111c19095140ea283f6e297db1a65ecd91e21c3
|
File details
Details for the file rs_audio_stats-1.3.9-cp311-cp311-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 513.4 kB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72f9dfc5138523c0e9694cbad1966dbc29d1bc4431c6fc1508d5593cb3c772d5
|
|
| MD5 |
d733e48a559c657c3ca4906de5d92da4
|
|
| BLAKE2b-256 |
a5735a52602069e59c93428094528a4911058363caa6c10e2495c032b140608a
|
File details
Details for the file rs_audio_stats-1.3.9-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 380.1 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11047a9fce848eea0e8dc393461abb4ad50522e604ff09915da707b6ea72152f
|
|
| MD5 |
9604c792e83f824cbd1d1989bd3ea9ec
|
|
| BLAKE2b-256 |
5ac8448fce473a336d5f0d8910433f033ea30f4f6e4b2fee9ed4078e0230abfc
|
File details
Details for the file rs_audio_stats-1.3.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 570.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32e0cccde2d2378669d9e98ddc165651839864cf2b3da5d3b1a63bb816fa637c
|
|
| MD5 |
0a5fe16d6573c2d47c85534ca84316c9
|
|
| BLAKE2b-256 |
29a813ddb195caec0d64a731c1969854fbd83367b972a5ff3d0c6829492c17d6
|
File details
Details for the file rs_audio_stats-1.3.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 600.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bca5f3454162f173c0bbb0d8978b38dd96f9baca5fa816ddaed696cbcbcba8d1
|
|
| MD5 |
80ae4ff533d0cc7bbd133aefb0850d7b
|
|
| BLAKE2b-256 |
5a1783d3fd6f4731ac4ead35db8c11772d5d93f8588ac7e73e16e2154af6134c
|
File details
Details for the file rs_audio_stats-1.3.9-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 501.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e78a2b801343f0d0998e4b8eea1be70eb2221c66d300a3ffbbf237040cfd213
|
|
| MD5 |
e43ce4497c8ac4c09406a760b2900277
|
|
| BLAKE2b-256 |
0802676b799485a68b9d5ab37bb9e78f1802c01178d2771910cd9b4925296ed5
|
File details
Details for the file rs_audio_stats-1.3.9-cp310-cp310-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rs_audio_stats-1.3.9-cp310-cp310-macosx_10_12_x86_64.whl
- Upload date:
- Size: 513.2 kB
- Tags: CPython 3.10, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe70e6eaa96363b90062696b5317eff0d3cdceaa71b7fec82fefe001af59bc66
|
|
| MD5 |
f4e20ee48acb7127f44be3cb05dc5bfc
|
|
| BLAKE2b-256 |
50ecab35d35625a27f06e8673e95a2bcdb5896ada7b10ddb7ad511c9a957d1fc
|