2 Commits

Author SHA1 Message Date
josh 4e8f6e280c release: ShoeGaze 3.3.0 — noise-gate threshold + mono-output fixes on Lyrebird 2.2.0
Bump to Lyrebird 2.2.0 (both Package.resolved pins → 2.2.0 / 24ea32e) and cut
ShoeGaze 3.3.0. This release surfaces the upstream ramp-origin fix plus the two
local fixes already on main:

- Noise Gate respects its threshold after loading a rig: the gate's open level is
  derived from the threshold, which previously swept up from a default on the first
  audio block and tripped the gate on the transient (latching it open). Lyrebird
  2.2.0 delivers a pre-first-render parameter value flat, so the gate reads its real
  threshold from block one.
- Mono rigs output at unity (were ~3 dB down through a centre pan).
- Noise Gate detector Peak/RMS switch, defaulting to RMS.

NoiseGatePedal doc comment tidied (signal-chain diagram + detector parameter).
App build track: MARKETING_VERSION 3.3, CURRENT_PROJECT_VERSION 23.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-03 13:09:48 -08:00
josh a434b14f4b fix(output,gate): unity mono output + RMS noise-gate detector
Two fixes from the guitar-input analysis:

- Mono board output no longer loses 3 dB. BoardOutputMaster panned a mono
  board to stereo centre with an equal-power Pan2 (×0.707 per channel). A
  mono rig should come out at the level it went in, so the signal is now
  written to both hardware buses directly at unity.

- Noise Gate gains a Peak/RMS detector switch (defaults to RMS). The peak
  follower (|x|) rides the waveform's peaks, so the gate's threshold decision
  tracked instantaneous peaks rather than loudness; the RMS detector
  (√ symmetric-average of x²) follows perceived level, so the gate opens and
  closes where the note actually is. Implemented as a rebuildsOnChange switch
  that builds only the chosen follower. Serialization-safe: a gate saved
  before the switch (empty switchValues) loads with the RMS default.

Tests cover the detector switch, RMS default (incl. legacy load), state
round-trip, and RMS closing earlier than Peak on a sustained tail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-03 08:49:16 -08:00
7 changed files with 165 additions and 32 deletions
@@ -163,7 +163,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 22; CURRENT_PROJECT_VERSION = 23;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@@ -175,7 +175,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 15.0; MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 3.2; MARKETING_VERSION = 3.3;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@@ -193,7 +193,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 22; CURRENT_PROJECT_VERSION = 23;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist; INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
@@ -204,7 +204,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 15.0; MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 3.2; MARKETING_VERSION = 3.3;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://realizedsound.mooo.com/josh/Lyrebird", "location" : "https://realizedsound.mooo.com/josh/Lyrebird",
"state" : { "state" : {
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0", "revision" : "24ea32e47cecff8efec9720546ed068b4efef2f7",
"version" : "1.2.3" "version" : "2.2.0"
} }
}, },
{ {
+3 -3
View File
@@ -1,5 +1,5 @@
{ {
"originHash" : "f9934abeea28a70c1be54af0c3f817ff5d985104ec77c04753214e68c4acf032", "originHash" : "c8855e41a403b5b1fccd9ccb4b3ef4d75c4307590ae6a0b8e985e71c41011e09",
"pins" : [ "pins" : [
{ {
"identity" : "linenoise-swift", "identity" : "linenoise-swift",
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://realizedsound.mooo.com/josh/Lyrebird", "location" : "https://realizedsound.mooo.com/josh/Lyrebird",
"state" : { "state" : {
"revision" : "b6fdee8bfc7c44d31a0a8cfe6fbd53f352dfad54", "revision" : "24ea32e47cecff8efec9720546ed068b4efef2f7",
"version" : "2.0.0" "version" : "2.2.0"
} }
}, },
{ {
+19
View File
@@ -1,4 +1,23 @@
# Releases # Releases
## ShoeGaze 3.3.0
Noise-gate and output-level fixes, on Lyrebird 2.2.0.
### Fixed
- **Noise Gate now respects its threshold after loading a rig.** A gate restored from a saved
rig could latch open and ignore its Threshold knob — the gate's open level is derived from the
threshold, and that value swept up from a default on the first audio block, tripping the gate
on the transient. Fixed upstream in Lyrebird 2.2.0 (a live parameter set before the first
render is now delivered flat), so the gate reads its real threshold from the first block.
- **Mono rigs come out at the level they went in.** A mono board was written through a centre
pan that dropped both channels ~3 dB; it now copies the mono signal to both outputs at unity.
### Changed
- **Noise Gate detector: Peak / RMS, defaulting to RMS.** RMS follows perceived loudness, so the
gate's threshold decision tracks how loud the note actually is instead of riding the waveform
peaks. A gate saved before this switch existed loads on RMS. (Peak remains available.)
- Updated to **Lyrebird 2.2.0**.
## ShoeGaze 3.1.1 ## ShoeGaze 3.1.1
A small fix for the Mutant envelope filter's control panel. A small fix for the Mutant envelope filter's control panel.
@@ -82,9 +82,6 @@ final class BoardOutputMaster: SynthesizerBase {
// MARK: - Constants // MARK: - Constants
/// Pan position for the board in the stereo field. Centre = 0.0. Used only for a mono board.
private let stereoPan: Double = 0.0
/// Lag time constant in seconds for the bypass crossfades — smooths engaged ↔ bypassed /// Lag time constant in seconds for the bypass crossfades — smooths engaged ↔ bypassed
/// transitions to prevent clicks. Matches the per-pedal bypass lag. /// transitions to prevent clicks. Matches the per-pedal bypass lag.
private let bypassLagTime: Double = 0.02 private let bypassLagTime: Double = 0.02
@@ -137,8 +134,12 @@ final class BoardOutputMaster: SynthesizerBase {
output(bus: 0, source: gainedLeft) output(bus: 0, source: gainedLeft)
output(bus: 1, source: gainedRight) output(bus: 1, source: gainedRight)
} else { } else {
// Mono board: Pan2 spreads the mono output to stereo hardware buses 0 + 1. // Mono board: write the mono signal to both hardware buses at unity (0 dB). Using an
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan)) // equal-power `Pan2` to centre would drop each channel by 3 dB (×0.707) — power-correct
// for a true pan, but a mono guitar rig should come out at the same level it went in, so
// the signal is copied to left and right directly instead.
output(bus: 0, source: gainedLeft)
output(bus: 1, source: gainedLeft)
} }
} }
@@ -11,20 +11,19 @@ import LyrebirdUI
/// ///
/// Signal chain (inside `effect(_:)`): /// Signal chain (inside `effect(_:)`):
/// ``` /// ```
/// dry ─┬─────────────────────────────────────────────────────────┐ /// detector(dry) → Schmidt(lo: thr, hi: thr×ratio) → LinLin(0…1 → floor…1) → LagUpDown(open/close)
/// └→ AmplitudeFollower → Schmidt(lo: thr, hi: thr×ratio) │ /// Peak: AmplitudeFollower(|x|)
/// → LinLin(0…1 → floor…1) │ /// RMS: √Lag(x²) out = dry × smoothed-gain
/// → LagUpDown(fast open/slow close) × ─┴→ mono out
/// ``` /// ```
/// ///
/// An `AmplitudeFollower` tracks the dry signal level. A Schmitt trigger turns that /// The **detector** tracks the dry signal level — either peak (`|x|`) or RMS (√mean-square). A
/// envelope into an open/closed gate with hysteresis (opens above `threshold × openRatio`, /// Schmitt trigger turns that envelope into an open/closed gate with hysteresis (opens above
/// closes below `threshold`) so the gate does not chatter around the threshold. The 0/1 /// `threshold × openRatio`, closes below `threshold`) so the gate does not chatter around the
/// gate is mapped to a gain in `[floor, 1]` and smoothed **asymmetrically** — opening fast so a /// threshold. The 0/1 gate is mapped to a gain in `[floor, 1]` and smoothed **asymmetrically** —
/// note's attack isn't softened, closing slowly so the gate fades shut instead of snapping (a fast /// opening fast so a note's attack isn't softened, closing slowly so the gate fades shut instead of
/// close popped audibly when heavy downstream gain amplified the step). When the gate is closed the /// snapping (a fast close popped audibly when heavy downstream gain amplified the step). When the
/// signal is attenuated to `floor` rather than hard-muted, so `floor` sets how much of the quiet /// gate is closed the signal is attenuated to `floor` rather than hard-muted, so `floor` sets how
/// signal/noise tail bleeds through. /// much of the quiet signal/noise tail bleeds through.
/// ///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class. /// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
/// ///
@@ -39,6 +38,8 @@ import LyrebirdUI
/// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`. /// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`.
/// - attack: Gate open time in seconds (advanced pop-over). Range `[0.001, 0.05]`. Defaults to `0.005`. /// - attack: Gate open time in seconds (advanced pop-over). Range `[0.001, 0.05]`. Defaults to `0.005`.
/// - release: Gate close time in seconds (advanced pop-over). Range `[0.01, 0.5]`. Defaults to `0.08`. /// - release: Gate close time in seconds (advanced pop-over). Range `[0.01, 0.5]`. Defaults to `0.08`.
/// - detector: Level-detection mode (switch). `0` = Peak (`|x|`), `1` = RMS (√mean-square).
/// Defaults to RMS (`1`).
public final class NoiseGatePedal: Pedal { public final class NoiseGatePedal: Pedal {
/// One-line description shown in the picker and info panel. /// One-line description shown in the picker and info panel.
@@ -63,17 +64,33 @@ public final class NoiseGatePedal: Pedal {
/// out chatter at the threshold). Range `[0.01, 0.5]`. Surfaced in the advanced pop-over. /// out chatter at the threshold). Range `[0.01, 0.5]`. Surfaced in the advanced pop-over.
@UIParam public var release: Double = 0.08 @UIParam public var release: Double = 0.08
/// Detector mode: `0` = **Peak** (tracks `|x|`), `1` = **RMS** (tracks √mean-square). RMS follows
/// perceived loudness, so the threshold decision — and the level at which the gate closes — lines
/// up with how loud the note actually is, instead of riding the waveform's peaks. Defaults to RMS.
@UIParam public var detector: Double = 1.0
// MARK: - Constants // MARK: - Constants
/// Default wet/dry blend — fully wet; the gate sits in-line. /// Default wet/dry blend — fully wet; the gate sits in-line.
private static let defaultMix: Double = 1.0 private static let defaultMix: Double = 1.0
/// `detector` value selecting the peak follower.
private let detectorPeakValue: Double = 0.0
/// `detector` value selecting the RMS follower.
private let detectorRMSValue: Double = 1.0
/// Envelope-follower attack time, in seconds — fast so the gate opens promptly on a note. /// Envelope-follower attack time, in seconds — fast so the gate opens promptly on a note.
private let detectAttack: Double = 0.002 private let detectAttack: Double = 0.002
/// Envelope-follower release time, in seconds — slower so the gate holds through decay. /// Envelope-follower release time, in seconds — slower so the gate holds through decay.
private let detectRelease: Double = 0.05 private let detectRelease: Double = 0.05
/// RMS integration window (one-pole averaging time, in seconds) for the RMS detector. Long enough
/// to average out the waveform's per-cycle ripple so the envelope reflects mean-square level, not
/// instantaneous peaks.
private let rmsWindow: Double = 0.02
/// Open-threshold multiplier. The gate opens above `threshold × openRatio` and closes /// Open-threshold multiplier. The gate opens above `threshold × openRatio` and closes
/// below `threshold`, giving hysteresis that prevents chatter near the threshold. /// below `threshold`, giving hysteresis that prevents chatter near the threshold.
private let openRatio: Double = 2.0 private let openRatio: Double = 2.0
@@ -122,6 +139,23 @@ public final class NoiseGatePedal: Pedal {
] ]
} }
/// Detector-mode switch (Peak / RMS). Appended as the gate's only switch, so a gate saved before
/// it existed (empty `switchValues`) loads with the RMS default — no migration.
public override var effectSwitches: [PedalSwitch] {
[
PedalSwitch(
label: "Detector",
node: $detector,
options: [
PedalSwitch.Option(title: "Peak", value: detectorPeakValue),
PedalSwitch.Option(title: "RMS", value: detectorRMSValue),
],
// Switching detector changes which follower is instantiated, so rebuild the board.
rebuildsOnChange: true
),
]
}
// MARK: - Init // MARK: - Init
/// Creates a noise-gate pedal. /// Creates a noise-gate pedal.
@@ -150,12 +184,26 @@ public final class NoiseGatePedal: Pedal {
/// - Parameter dry: Dry mono input signal. /// - Parameter dry: Dry mono input signal.
/// - Returns: Gated mono output. /// - Returns: Gated mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput { public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Track the dry signal's amplitude envelope. // Build the chosen detector only. `detector` is a `rebuildsOnChange` switch, so it is read
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio( // here as a plain value at build time (the board rebuilds when it is toggled) — no live
// node-select in the graph.
let envelope: any ValidGeneratorInput
if detector >= detectorRMSValue {
// RMS detector: √(symmetric one-pole average of x²). The averaging window must be
// symmetric — a fast attack would track the *squared peaks* and collapse back to peak
// detection — so a plain `Lag` over `rmsWindow` recovers the mean square, giving a
// loudness-tracking envelope roughly 3 dB below the peak for a steady tone.
let squared: any ValidGeneratorInput = dry * dry
let meanSquare: Lag.Audio = Lag.Audio(input: squared, time: rmsWindow)
envelope = Sqrt.Audio(meanSquare)
} else {
// Peak detector: a one-pole follower of |x| (fast attack, slower release).
envelope = AmplitudeFollower.Audio(
in: dry, in: dry,
attackTime: detectAttack, attackTime: detectAttack,
releaseTime: detectRelease releaseTime: detectRelease
) )
}
// Hysteretic open/closed gate: opens above threshold×openRatio, closes below threshold. // Hysteretic open/closed gate: opens above threshold×openRatio, closes below threshold.
let gate: Schmidt.Audio = Schmidt.Audio( let gate: Schmidt.Audio = Schmidt.Audio(
@@ -170,4 +170,69 @@ struct NoiseGatePedalTests {
#expect(pedal.threshold == 0.03 && pedal.floor == 0.4, "legacy Threshold/Floor mis-mapped") #expect(pedal.threshold == 0.03 && pedal.floor == 0.4, "legacy Threshold/Floor mis-mapped")
#expect(pedal.attack == 0.005 && pedal.release == 0.08, "legacy gate should default Attack/Release") #expect(pedal.attack == 0.005 && pedal.release == 0.08, "legacy gate should default Attack/Release")
} }
@Test func exposesDetectorSwitch() throws {
let switches: [PedalSwitch] = NoiseGatePedal().effectSwitches
#expect(switches.map { $0.label } == ["Detector"])
#expect(switches.first?.options.map { $0.title } == ["Peak", "RMS"])
}
@Test func defaultsToRMSAndLegacyGateGetsRMS() throws {
#expect(NoiseGatePedal().detector == 1.0, "new gate should default to RMS")
// A gate saved before the detector switch (empty switchValues) loads with the RMS default.
let legacy: PedalState = PedalState(
id: UUID(), type: "Noise Gate",
knobValues: [0.03, 0.4, 1.0, 1.0], switchValues: [], advancedValues: [], bypass: 0.0)
let pedal: NoiseGatePedal = NoiseGatePedal()
pedal.applyState(legacy)
#expect(pedal.detector == 1.0, "legacy gate should default to the RMS detector")
}
@Test func detectorRoundTripsThroughState() throws {
let pedal: NoiseGatePedal = NoiseGatePedal()
pedal.detector = 0.0 // Peak
let restored: NoiseGatePedal = NoiseGatePedal()
restored.applyState(pedal.captureState())
#expect(restored.detector == 0.0)
}
@Test func rmsDetectorClosesEarlierThanPeak() throws {
// On a note held just above threshold, the RMS envelope (≈ 3 dB below the peak envelope for a
// steady tone) drops under the close threshold sooner than the peak envelope does — so the
// RMS gate shuts earlier and passes less of the sustained tail than the Peak gate. The source
// steps to a constant 0.03 (peak env ≈ 0.03, RMS env ≈ 0.021); with threshold 0.025 the Peak
// gate stays open on the tail while the RMS gate closes.
func tailEnergy(detector: Double) throws -> Double {
let sr: Double = 48000.0
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.6, sampleRate: sr)
defer { try? FileManager.default.removeItem(at: url) }
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
defer {
engine.busAllocator.releaseAudioBus(srcBus)
engine.busAllocator.releaseAudioBus(dstBus)
}
let source: DecaySineSource = DecaySineSource(bus: srcBus.index)
let gate: NoiseGatePedal = NoiseGatePedal(inputBus: srcBus.index, outputBus: dstBus.index)
gate.sampleRate = sr
gate.threshold = 0.025
gate.floor = 0.0
gate.detector = detector
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
try engine.add(source)
try engine.add(gate, position: NodePosition.after(source))
try engine.add(master, position: NodePosition.after(gate))
try engine.start()
let inter: [Float] = readStereoCAF(url: url, sampleRate: sr)
let mono: [Double] = stride(from: 0, to: inter.count, by: 2).map { Double(inter[$0]) }
let start: Int = Int(0.15 * sr) // the sustained, below-peak-threshold tail
var energy: Double = 0.0
for i: Int in start..<mono.count { energy += mono[i] * mono[i] }
return energy
}
let peakTail: Double = try tailEnergy(detector: 0.0)
let rmsTail: Double = try tailEnergy(detector: 1.0)
#expect(peakTail > rmsTail * 2.0,
"RMS should close earlier than Peak on the sustained tail (peak=\(peakTail) rms=\(rmsTail))")
}
} }