Skip to content
LithivmPublic

About

A modern spectrogram analyzer for music enthusiasts and HiFi listeners

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Spectra

A modern OpenGL-rendered spectrogram analyzer for music enthusiasts and HiFi listeners

一款面向音乐爱好者与 HiFi 发烧友的现代化频谱分析工具

screenshot


Features · 功能特性

English 中文
OpenGL Spectrogram — fragment shader with real-time colormap switching (10 palettes) OpenGL 频谱图 — 片段着色器渲染,实时切换 10 种色板
Audio Playback — play/pause with progress slider, synchronized with waveform 音频播放 — 播放/暂停,进度滑块与波形同步
Progress Slider — dedicated seek bar between spectrogram and X-axis 播放进度条 — 声谱图与时间轴之间的独立滑块,拖拽定位
Cursor Info — hover shows time, frequency, and dB at cursor position 光标信息 — 悬停实时显示当前时间、频率、dB 值
Wheel Zoom — scroll to zoom time axis, Shift+scroll for frequency axis, double-click reset 滚轮缩放 — 滚轮缩放时间轴,Shift+滚轮缩放频率轴,双击重置
Quality Analysis — per-channel clipping (bit-depth-aware), upsampling check (Welch PSD + slope + Gibbs), DR, LUFS, true peak, LRA 质量分析 — 多声道削波(位深感知)、升频检测(Welch PSD + 斜率 + Gibbs)、动态范围、响度、真峰值
Multi-resolution STFT — standard, multi-band, and phase-reassigned (iZotope RX style) 多分辨率 STFT — 标准、多频段、相位重分配三种模式
Flexible Y-axis — linear, logarithmic, mel (Slaney piecewise), and bark frequency scales 灵活 Y 轴 — 线性、对数、mel(Slaney 分段拟合)、bark 四种频率刻度
Waveform Preview — down-sampled envelope aligned with spectrogram 波形预览 — 降采样包络,与频谱上下对齐
Drag & Drop — WAV, FLAC, MP3, M4A, OGG, AAC, OPUS, APE, AIFF, WMA, TTA 拖放加载 — 支持 11 种常见音频格式
Bilingual UI — Chinese / English one-click toggle 双语界面 — 工具栏一键切换中文 / 英文
Batch Analysis — process folders, export to CSV 批量分析 — 批量处理文件夹,导出 CSV
Screenshot Export — save spectrogram view as PNG 截图导出 — 保存当前频谱视图为 PNG
Fast Startup — heavy libraries lazy-loaded in background thread 快速启动 — 重量级库后台延迟加载,启动秒开
Optimized Analysis — vectorized FFT, deduped true-peak, batched spectrum computation 优化分析 — 向量化 FFT、去重真峰值、批量频谱计算

Supported Formats · 支持格式

Format Extension
FLAC .flac
WAV .wav
MP3 .mp3
M4A / ALAC .m4a .mp4
AAC .aac
OGG Vorbis .ogg
OPUS .opus
Monkey's Audio .ape
WMA .wma
True Audio .tta
AIFF .aiff

All formats decoded via PyAV (libav). No external dependencies required.

全格式通过 PyAV (libav) 解码,无需外部依赖。

Quality Metrics · 质量指标

Metric Description
Clipping Per-channel flat-top detection (threshold 0.999) — hard/soft classification via bit-depth-aware flatness, single-sample + multi-sample events, channels_affected
Hi-freq Cutoff Welch PSD (nperseg=8192) + multi-factor scoring — noise floor P5, signal ref P90 (2–12 kHz), spectral slope (dB/oct), Gibbs ringing detection
Dynamic Range P95–P10 of segmented frame RMS (TT DR Meter standard)
LUFS (I) EBU R128 integrated loudness
LUFS (S) Short-term loudness (3 s blocks, maximum)
LRA Loudness range (P10–P95 spread)
True Peak 4× oversampling BS.1770-4
Peak / RMS Global sample peak and RMS level

Quick Start · 快速启动

From source · 从源码运行

git clone https://github.com/Lithivm/Spectra.git
cd Spectra
pip install -r requirements.txt
python main.py

Drag an audio file into the window, or click Open File (打开文件).

拖入音频文件,或点击 打开文件 按钮。Click ▶ (播放) to preview audio.

Pre-built · 打包版本

Download Spectra-v0.2.0-windows.zip from Releases, extract, and run Spectra.exe.

从 Releases 下载 Spectra-v0.2.0-windows.zip,解压后运行 Spectra.exe。

Build · 构建

pip install pyinstaller
pyinstaller spectra.spec --noconfirm

Output is in dist/Spectra/. See spectra.spec for packaging details.

输出在 dist/Spectra/,打包配置见 spectra.spec。

Colormaps · 色板

Name Description
spectra Custom palette with brightness curve (default)
inferno Perceptually uniform, warm
viridis Perceptually uniform, blue-green-yellow
plasma Perceptually uniform, purple-orange-yellow
magma Perceptually uniform, dark-purple-yellow
hot Black → red → yellow
coolwarm Cool blue → warm red (diverging)
seismic Blue → white → red (diverging)
turbo Perceptually uniform rainbow (Google)
jet Classic rainbow

spectra uses a custom colormap with a dedicated brightness curve (SPECTRA_CURVE); all other palettes are generated from hardcoded color stops (sourced from matplotlib originals) via pure-numpy linear interpolation — no matplotlib dependency. Curve parameters are defined in palette.py and require no changes to any other file to adjust.

Architecture · 架构

Spectra/
├── main.py                      # 入口薄壳(开发期直跑;装成包后走 `spectra` 命令)
├── docs/                        # 文档:specs / agents
├── src/spectra/
│   ├── __main__.py              # Entry point + crash logger
│   ├── lang.py                  # Bilingual (zh/en) toggle
│   ├── assets/                  # logo.ico · logo.png · logo_mark.png
│   ├── backend/                 # 后端:解码 + 分析
│   │   ├── core.py              # AudioAnalyzer facade class
│   │   ├── _state.py            # FFTW wisdom + STFT cache (LRU)
│   │   ├── spectrum.py          # _SpectrumMixin — STFT, reassigned, mel
│   │   ├── quality.py           # _QualityMixin — clipping, LUFS, DR
│   │   ├── loudness.py          # R128 K-weighting 原生采样率 + 真峰值(polyphase FIR)
│   │   ├── scales.py            # Slaney mel 刻度(CPU 侧唯一实现,shader mel 分支是它的镜像)
│   │   ├── load.py              # PyAV multi-format decoder
│   │   ├── metadata.py          # Tag extraction via mutagen
│   │   ├── palette.py           # Colormap registry + curve presets (zero-dependency)
│   │   └── batch.py             # CSV export for batch analysis
│   └── frontend/                # 前端:Qt + OpenGL
│       ├── main_window.py       # Main window, toolbar, playback slider, workers
│       ├── spectrogram_widget.py # QOpenGLWidget renderer + axis/colorbar + cursor zoom
│       ├── waveform_widget.py   # Waveform envelope
│       ├── metadata_panel.py    # File info + quality analysis panel
│       ├── playback_engine.py   # Audio playback via sounddevice
│       ├── batch_dialog.py      # Batch progress dialog
│       ├── progress_bar.py      # 浮在声谱图上的加载进度浮层
│       ├── anim.py              # FloatAnim 缓动助手
│       ├── icons.py             # 内联 SVG 图标(HiDPI)
│       ├── styles.py            # Color tokens for dark theme
│       └── shaders/
│           ├── spectrogram.vert # GLSL vertex shader
│           └── spectrogram.frag # GLSL fragment shader (zoom + curve uniforms)
└── tests/

Tech Stack · 技术栈

Library Purpose
PyQt6 Desktop UI + OpenGL widget
librosa STFT, spectral features
pyFFTW FFTW bindings (faster FFT)
pyloudnorm EBU R128 loudness
PyAV Audio decoding (libav)
sounddevice Audio playback (PortAudio)
mutagen Metadata extraction
scipy Signal processing
numpy Numerical arrays
numba JIT (librosa dependency)

Troubleshooting · 故障排查

If the app crashes, check %USERPROFILE%\.spectra\crash.log for details. All uncaught exceptions and worker failures are logged there.

如果应用崩溃,查看 %USERPROFILE%\.spectra\crash.log 获取详细错误信息。

License · 许可证

MIT


Built with PyQt6, OpenGL, librosa, pyFFTW, matplotlib, and sounddevice.

About

A modern spectrogram analyzer for music enthusiasts and HiFi listeners

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages