From 198eb54ce24dd23eb5f98bb53fd4427505a542f3 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Fri, 3 Jul 2026 15:37:50 -0700 Subject: [PATCH] menuband: fade-in the sample start to swallow the record-key click MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 15ms cosine fade-in on the captured buffer. The key click sits at t=0, so ramping up from silence attenuates the residual transient the front-skip/trim misses, without touching the sample body — and makes the looped boundary click-free too. Co-Authored-By: Claude Opus 4.8 --- .../Sources/MenuBand/MenuBandSampleVoice.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift b/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift index 03727d376b..5c2a56dfcb 100644 --- a/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift +++ b/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift @@ -634,6 +634,18 @@ final class MenuBandSampleVoice { peakAfter = max(peakAfter, abs(s)) sumSqAfter += s * s } + // Short cosine fade-in over the first ~15 ms. The record-key click sits + // right at the buffer start, so ramping up from silence smoothly + // swallows whatever transient survived the front-skip/trim, while the + // sample's body is untouched. Bonus: since the buffer loops, every loop + // now restarts from zero — no click at the loop boundary either. + let fadeFrames = min(frames, Int(sampleRate * 0.015)) + if fadeFrames > 1 { + for i in 0..