fix(perc/install): kick mastering + closed hat lift + install fix + reverse loop
Five fixes bundled together based on USB log analysis and live testing
feedback:
1. **KICK MASTERING** for laptop speakers. The previous recipe put most
of the energy in 50-80 Hz which laptop speakers physically can't
reproduce. User reported "no audible frequencies on laptop". Rewrote:
- removed 4 kHz noise click (sounded like a digital pop)
- softened attack to 2.5 kHz noise (blends vs clicks)
- 180 Hz pitch snap (audible thump on laptops)
- MAIN BODY at 150 Hz @ vol 2.0 (was 80 Hz @ 1.6 — pushes the speaker)
- 100 Hz mid-low fill @ vol 1.4
- 80 Hz triangle "beef" (harmonics at 160/240 Hz land in laptop range)
- 50 Hz sub kept for headphones/subwoofers (inaudible on laptops but
adds body on real speakers)
Result: kick now has real PUNCH on laptop speakers while still keeping
the 808-style sub extension for headphones.
2. **CLOSED HAT LIFT CLICK**. User wanted a subtle mechanical "tick" when
the key releases — the sound of the stick leaving the hat. Added a
new addReleaseBurst() helper that registers an onRelease callback
without needing an actual sustain voice. On key-up, fires a 4ms 9kHz
noise transient + 3ms 6kHz square pip. Subtle, dry, mechanical.
3. **INSTALL FIX — BUG 1: mkfs rc detection**. My earlier debug
instrumentation used `mkfs ... > err 2>&1; cat err` which made
system() always return cat's exit code (0), silently masking every
mkfs failure. Install then proceeded onto an unformatted partition
and the copy step failed with ENOSPC on every file. Fixed with
subshell pattern: `(mkfs ... > err 2>&1; rc=$?; cat err >> dlog; exit $rc)`
4. **INSTALL FIX — BUG 2: mkfs EBUSY root cause**. mkfs.vfat couldn't
get O_EXCL on /dev/nvme0n1p1 because the kernel's block device cache
still referenced the old Fedora ESP's filesystem pages even after
force_unmount + sfdisk + BLKRRPART fallback. New mitigations:
a. `dd` zeros the first 64 KB of the disk BEFORE sfdisk, killing
the old FAT boot sector + GPT primary header so the kernel
sees a clean slate
b. `echo 3 > /proc/sys/vm/drop_caches` before mkfs to force the
kernel page cache to release lingering references
c. Settle time bumped from 500ms to 3s before first mkfs
d. Retry loop extended from 2 to 3 attempts with drop_caches and
2s settle between each
With the rc detection fix, we'll now actually SEE if mkfs still fails
after these mitigations, and the retry loop will give more chances
to land a successful format.
5. **REVERSE PLAYBACK FULL LOOP** (space bar). User wanted: "when the
reverse flips forward and reaches the present, loop from the press
point". The old implementation played the reversed buffer ONCE then
stopped. New behavior:
- Capture the last N ms of audio as a reversed buffer
- Concatenate the forward copy of the same buffer
- Load the 2×-length combined buffer with loop:true
Result: holding space plays REVERSE → FORWARD → REVERSE → FORWARD
indefinitely, creating a ping-pong loop of the captured section.
Release space → stops. Loop length = 2 × captured duration.
The install fix is the biggest functional improvement — we can finally
install ac-native to HD side-by-side with Fedora without the mkfs EBUSY
wall. The kick mastering means the drums are actually usable on laptop
speakers. The reverse loop is pure instrument magic.