A Python CLI tool for analyzing peak amplitude levels across MIDI velocity levels in piano wave files. Originally written in MATLAB/Octave by Dave Starkey (dstarkey@midi9.com); this is the Python port.
Given a WAV file containing recordings of a piano note at multiple velocity levels (e.g. recorded from a MIDI sampler session), this tool slices the audio into per-note, per-velocity segments, measures peak amplitude in each, converts to dB, and outputs a multi-page PDF with waveform plots plus a summary .txt file.
Designed for 8 notes (A0–A7) × 10 or 13 velocity levels.
pip install numpy scipy matplotlib soundfilepython wave_amplitude_analyzer.py --input <wavefile> [options]# Basic usage with defaults
python wave_amplitude_analyzer.py --input WaveSource/myfile.wav
# 13 velocity levels instead of 10
python wave_amplitude_analyzer.py --input WaveSource/myfile.wav --velocities 13
# Yamaha-style files (shorter thumps, less preroll, deadspace between groups)
python wave_amplitude_analyzer.py --input WaveSource/myfile.wav --thump-size 2 --preroll 0.3 --deadspace 2| Flag | Short | Default | Description |
|---|---|---|---|
--input |
-i |
(required) | Path to input .wav file |
--velocities |
-v |
10 |
Number of velocity levels: 10 or 13 |
--thump-size |
-t |
3.0 |
Seconds allocated per note/velocity slot. Use 2.0 for Yamaha files |
--preroll |
-p |
0.9 |
Pre-roll as a fraction of thump size. Use 0.3 for Yamaha files |
--deadspace |
-d |
0.0 |
Dead space in seconds between note groups. Use 2 for Yamaha files |
--output-dir |
-o |
Results |
Output directory for PDF and TXT results |
10 levels (default):
pppp, ppp, pp, p, mp, mf, f, ff, fff, ffff
→ MIDI values: 10, 25, 40, 53, 66, 79, 92, 104, 117, 127
13 levels:
pppp-, pppp, ppp-, ppp, pp-, pp, p, mp, mf, f, ff, fff, ffff
→ MIDI values: 5, 10, 16, 25, 32, 40, 53, 66, 79, 92, 104, 117, 127
Given --input WaveSource/myfile.wav, results are written to Results/:
-
myfile.pdf— Multi-page PDF:- Page 1: Full waveform overview (decimated ×4)
- Pages 2–9: Per-note waveform (A0–A7) with red dots marking detected peaks
- Final page: Summary plot of peak dB vs. MIDI velocity for all 8 notes
-
myfile.txt— Plain text summary with sample rate, duration, and per-note peak dB values across all velocity levels
Peak amplitude is calculated using the natural log formula 10 * ln(peak), matching the original MATLAB/Octave behavior. This is not standard dBFS — it's a relative log scale consistent with the original tool.
- Mono or stereo WAV (first channel used if stereo)
- Layout: 8 consecutive note groups (A0–A7), each containing
num_velocitiesthumps recorded from softest to loudest - Total expected duration ≈
8 × (thump_size × num_velocities + deadspace)seconds
MIT License — © 2026 Dave Starkey (midi9.com)