From 690a37ba4de46173952d475eae484bbe8679b208 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Fri, 3 Jul 2026 13:30:17 -0700 Subject: [PATCH] menuband: less-eager sample trim (keep more attack) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Front record-key click-skip 35ms → 22ms and trim pre-roll 12ms → 26ms, so the sample's attack isn't clipped when the onset starts soon after the key click. Co-Authored-By: Claude Opus 4.8 --- slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift b/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift index 7c22e3a450..9f300d6079 100644 --- a/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift +++ b/slab/menuband/Sources/MenuBand/MenuBandSampleVoice.swift @@ -50,7 +50,9 @@ final class MenuBandSampleVoice { /// buffer can hold. private let initialScratchFrames: Int private let trimThreshold: Float = 0.012 - private let trimPrerollFrames = Int(44_100 * 0.012) + // Keep a longer pre-roll before the detected onset so the sample's attack + // isn't clipped (the trim was a touch eager — it started right on the onset). + private let trimPrerollFrames = Int(44_100 * 0.026) /// The currently-stored recording. nil until a successful capture. /// Reads from the audio thread (player schedules) are safe because @@ -96,7 +98,7 @@ final class MenuBandSampleVoice { /// without eating into actual performance. `trimmedStartFrame` /// runs AFTER this and additionally rejects any leading /// transient burst that survives the fixed window. - private let recordKeyClickSkipFrames: Int = Int(44_100 * 0.035) + private let recordKeyClickSkipFrames: Int = Int(44_100 * 0.022) /// Decremented on each ingestInput block until zero. Set fresh /// at every `startRecording` call. private var framesRemainingToSkip: Int = 0 -- 2.51.2