feat(karplus): extend Free-tune range up to E5

The Free-mode Tune knob now reaches 660 Hz (E5, the top of the treble
staff), up from 400 Hz, so the resonator root can be dialled across the full
guitar range by ear. Note mode already covered this via the octave selector.

Test: Free Tune at E5 rings near 659 Hz. Full suite 795 green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 14:59:16 -08:00
parent 89a34016de
commit 097c38283e
2 changed files with 18 additions and 3 deletions
@@ -30,7 +30,8 @@ import LyrebirdUI
/// selectors in equal temperament (A4 = 440 Hz, so A3 = 220 Hz).
///
/// ## Knobs
/// - `tune`: Root frequency of the string bank in Hz (used in **Free** tuning). Range `[40, 400]`.
/// - `tune`: Root frequency of the string bank in Hz (used in **Free** tuning). Range `[40, 660]`
/// (up to E5, the top of the treble staff).
/// - `sustain`: Ring length — the string feedback. Range `[0, 1]` → feedback `[0.9, 0.999]`.
/// - `tone`: Brightness of the strings. Range `[0, 1]`: `0` = dark/woody, `1` = bright/metallic.
/// - `sensitivity`: How readily playing plucks the strings. Range `[0, 1]`: higher = lower trigger
@@ -50,7 +51,7 @@ public final class KarplusResonatorPedal: Pedal {
// MARK: - Parameters
/// Root frequency of the string bank in Hz. Range `[40, 400]`.
/// Root frequency of the string bank in Hz (Free tuning). Range `[40, 660]` — up to E5.
@UIParam public var tune: Double = 82.41
/// Ring length — the string feedback. Range `[0, 1]` → feedback `[0.9, 0.999]`.
@@ -180,7 +181,9 @@ public final class KarplusResonatorPedal: Pedal {
// MARK: - Ranges
private let tuneRange: ClosedRange<Double> = 40.0 ... 400.0
/// Free-mode root range in Hz. Upper bound reaches E5 (≈ 659 Hz, the top of the treble staff);
/// lower bound sits around a low bass E.
private let tuneRange: ClosedRange<Double> = 40.0 ... 660.0
private let unitRange: ClosedRange<Double> = 0.0 ... 1.0
// MARK: - Knobs
@@ -259,6 +259,18 @@ struct KarplusResonatorPedalTests {
"two voicings should ring differently: tail diff \(diff) vs drone tail \(droneTail)")
}
@Test func freeModeReachesTrebleStaffTop() throws {
// Free-mode Tune now reaches E5 (≈ 659 Hz, top of the treble staff). Drone voicing shares the
// root period, so the ring's fundamental sits at the set root.
let e5: Double = 659.25
let out: [Float] = try renderPluck { pedal in
pedal.mix = 1.0; pedal.sustain = 0.9; pedal.sensitivity = 0.6
pedal.tuning = 0.0; pedal.tune = e5; pedal.voicing = 0.0
}
let f: Double = fundamentalHz(out, skip: tailSkipFrames, window: tailWindowFrames, minHz: 300.0, maxHz: 900.0)
#expect(abs(f - e5) / e5 < 0.1, "Free Tune at E5 should ring near \(e5) Hz, got \(f)")
}
@Test func renderIsDeterministic() throws {
// Every node in the bank is deterministic (no RNG), so two identical renders are bit-identical.
let a: [Float] = try renderPluck { pedal in pedal.sustain = 0.8; pedal.voicing = 2.0 }