6 Commits

Author SHA1 Message Date
josh 957a99d802 docs: round out 1.2.0 release notes with late refinements + fixes
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 16:05:12 -07:00
josh e839447aa8 Stack the routing row under the pedal picker
Move the ROUTING cards (Stereo Split / Parallel Split / Merge to Mono) from
the right of the horizontal pedal strip to their own row beneath the pedal
cards, using the space under the picker.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 16:01:07 -07:00
josh a21121e120 Remove granulator latency: window+pan the live input (no delay buffer)
The granulators read grains from behind the write head, so each grain
replayed the last grainSize of audio — an audible delay. Rework
StereoGranulator to the straight-through approach (matching Lyrebird's
InputGrain at position 0): grains apply their Hann window and random pan to
the LIVE input sample with no look-back buffer, so there is zero added
latency. Output is normalised by overlap so density doesn't change level.
Drops the circular buffer entirely.

GranulatorPedal / AutoGranulatorPedal are unchanged (same generator API).
Generator tests (seeded determinism, zero-spread centering, full-spread
L/R separation) still hold. Suite 271.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 15:49:50 -07:00
josh bc6e6286df Surface pedal/board edit failures as a UI alert
Adding a second stereo (widener) pedal — e.g. two Granulators in a row —
threw ShoeGazeError.stereoWidthExceeded, which was only printed to the
console. Route the addPedal / routing / addBoard catch blocks to an alert
with player-facing wording (stereo-width / merge cases mapped to plain text;
others fall back to the error's LocalizedError description). Alert lives on
its own presentation anchor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 15:30:31 -07:00
josh bc7157b7ee Reflect input-channel count in the input picker before Start
Engine config edits (In/Out/Rate) now apply to the stopped engine
immediately rather than only at Start, so the input-source picker — which
lists 0..<engine.numInputChannels — updates as soon as the In stepper
changes, letting the user choose the input before starting. No-op while
running (controls are disabled). Reuses the existing onConfigApplied
refresh path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 15:26:14 -07:00
josh 7d3bafe200 Release 1.2.0
Bump MARKETING_VERSION / CFBundleShortVersionString to 1.2.0 (both apps)
and add docs/release-notes-1.2.0.md.

Highlights: ten new pedals (Distortion, Flanger, Vibrato, Rotary,
Harmonizer, Reverse Delay, Shimmer Reverb, Bitcrusher, Granulator, Auto
Granulator), an iCloud-synced rig library, and a reworked builder layout
with a colour-coded, type-filterable pedal picker.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 15:20:11 -07:00
10 changed files with 201 additions and 79 deletions
@@ -176,7 +176,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -206,7 +206,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
+1 -1
View File
@@ -13,7 +13,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
+1 -1
View File
@@ -13,7 +13,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
@@ -10,30 +10,20 @@ import Foundation // `cos`/`sin` for the init-time Hann table and per-grain pa
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
private let stereoGranulatorZeroBlock: [Double] = makeSampleBuffer()
/// Stereo input granulator: records the mono input into a circular buffer and replays it as a
/// cloud of overlapping Hann-windowed grains, each randomly panned across the stereo field by
/// `spread`.
/// Stereo input granulator (straight-through): windows and pans the **live** input directly,
/// without a delay/look-back buffer, so there is no latency.
///
/// Each grain is a unity-speed windowed copy of the most recent `grainSize` of audio (so the cloud
/// thickens and smears the input without changing pitch). Grains are spawned every
/// `grainSize / overlap` samples from a fixed voice pool; each grain's pan is a fresh random value
/// in `[-1, 1] × spread` turned into equal-power L/R gains. `spread = 0` collapses every grain to
/// centre (mono); `spread = 1` scatters grains across the full field.
/// A pool of overlapping grain voices each apply a Hann envelope to the incoming sample and pan it
/// to a fresh random position in `[-1, 1] × spread`; the windowed, panned copies sum to the stereo
/// output. Because every active grain reads the current input sample (not buffered history), the
/// effect adds stereo width and a shimmering amplitude texture with **no time delay**. `spread = 0`
/// collapses every grain to centre (mono); `spread = 1` scatters grains across the full field.
/// Output is normalised by `overlap` so density doesn't change the level.
///
/// `grainSize`, `overlap`, and `spread` are read at control rate (once per block). Output is two
/// channels (`[0]` = left, `[1]` = right) — use the ``left`` / ``right`` accessors.
///
/// - Important: All buffers and the grain voice pool are pre-allocated at `init` for `maxGrainSize`
/// seconds — the RT path never allocates or resizes.
///
/// - Parameters:
/// - input: Audio-rate mono signal to granulate.
/// - maxGrainSize: Largest grain length in seconds; sizes the pre-allocated buffer.
/// - grainSize: Grain length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
/// - overlap: Number of overlapping grains (spawn density). Control rate; clamped to `[1, 24]`.
/// - spread: Stereo spread `[0, 1]` — scales each grain's random pan. Control rate.
/// - sampleRate: Sample rate used to size the buffer and convert seconds → frames.
/// - seed: Optional PRNG seed for deterministic grain panning (tests). Defaults to time-based.
/// - Important: The grain voice pool is pre-allocated at `init` — the RT path never allocates.
public final class StereoGranulator: GeneratorBase, AudioGenerator {
// MARK: - Inputs
@@ -44,23 +34,18 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
let _overlap: any ValidGeneratorInput
let _spread: any ValidGeneratorInput
// MARK: - Buffers + state
private var _buffer: [Double]
private let _mask: Int
private var _writeHead: Int = 0
private let _maxGrainFrames: Int
private let _minGrainFrames: Int
// MARK: - State
/// Precomputed unit Hann window, indexed by `phase · hannSize / grainLen`.
private var _hann: [Double]
private let _hannSize: Int = 2048
private let _maxGrainFrames: Int
private let _minGrainFrames: Int
// Grain voice pool (fixed size; a grain that can't find a free voice is skipped).
private static let maxVoices: Int = 24
private var _vActive: [Bool]
private var _vReadHead: [Int]
private var _vPhase: [Int]
private var _vLen: [Int]
private var _vGainL: [Double]
@@ -85,11 +70,12 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
///
/// - Parameters:
/// - input: Audio-rate mono signal to granulate.
/// - maxGrainSize: Largest grain length in seconds; sizes the pre-allocated buffer.
/// - grainSize: Grain length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
/// - overlap: Number of overlapping grains (spawn density). Control rate; clamped to `[1, 24]`.
/// - maxGrainSize: Largest grain length in seconds; bounds the grain-length clamp.
/// - grainSize: Grain (window) length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
/// - overlap: Number of overlapping grains (density); also the level normaliser. Control rate;
/// clamped to `[1, 24]`.
/// - spread: Stereo spread `[0, 1]` — scales each grain's random pan. Control rate.
/// - sampleRate: Sample rate used to size the buffer and convert seconds → frames.
/// - sampleRate: Sample rate used to convert grain seconds → frames.
/// - seed: Optional PRNG seed for deterministic grain panning (tests). Defaults to a constant.
public init(
input: any ValidGeneratorInput,
@@ -107,21 +93,10 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
_overlap = overlap._resolvedInput()
_spread = spread._resolvedInput()
let maxFrames: Int = max(1, Int((maxGrainSize * sampleRate).rounded()))
_maxGrainFrames = maxFrames
_maxGrainFrames = max(1, Int((maxGrainSize * sampleRate).rounded()))
_minGrainFrames = max(1, Int((minGrainSeconds * sampleRate).rounded()))
// A grain reads the `grainLen` samples behind the write head while the head writes
// `grainLen` ahead during the grain's life — disjoint spans needing ≥ 2·maxGrainFrames.
// Round up to a power of two for branchless `& _mask` wrapping.
let needed: Int = 2 * maxFrames + 2
var size: Int = 1
while size < needed { size <<= 1 }
_buffer = [Double](repeating: 0.0, count: size)
_mask = size - 1
_vActive = [Bool](repeating: false, count: StereoGranulator.maxVoices)
_vReadHead = [Int](repeating: 0, count: StereoGranulator.maxVoices)
_vPhase = [Int](repeating: 0, count: StereoGranulator.maxVoices)
_vLen = [Int](repeating: 1, count: StereoGranulator.maxVoices)
_vGainL = [Double](repeating: 0.0, count: StereoGranulator.maxVoices)
@@ -166,6 +141,8 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
let spread: Double = rawSpread.isFinite ? min(max(rawSpread, 0.0), 1.0) : 0.0
let spawnPeriod: Int = max(1, grainLen / overlap)
// Normalise so denser overlap doesn't raise the level (≈ sum of overlapping Hann windows).
let norm: Double = 1.0 / Double(overlap)
let inputSamples: [Double] = _inputIsGenerator
? (_input.calculatedSamples(graph: graph, count: count).first ?? stereoGranulatorZeroBlock)
@@ -173,7 +150,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
let inputCount: Int = inputSamples.count
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
var writeHead: Int = _writeHead
var spawnCountdown: Int = _spawnCountdown
var rng: UInt64 = _rng
@@ -181,7 +157,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
let x: Double = _inputIsGenerator
? (i < inputCount ? inputSamples[i] : 0.0)
: inputScalar
_buffer[writeHead & _mask] = x
var left: Double = 0.0
var right: Double = 0.0
@@ -189,10 +164,10 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
let phase: Int = _vPhase[v]
let len: Int = _vLen[v]
let windowIndex: Int = phase * _hannSize / len
let windowed: Double = _buffer[_vReadHead[v] & _mask] * _hann[windowIndex]
// Straight-through: window + pan the LIVE sample (no delay buffer).
let windowed: Double = x * _hann[windowIndex]
left += windowed * _vGainL[v]
right += windowed * _vGainR[v]
_vReadHead[v] = _vReadHead[v] + 1
let nextPhase: Int = phase + 1
if nextPhase >= len {
_vActive[v] = false
@@ -204,15 +179,13 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
spawnCountdown -= 1
if spawnCountdown <= 0 {
spawnCountdown = spawnPeriod
spawnGrain(grainLen: grainLen, spread: spread, writeHead: writeHead, rng: &rng)
spawnGrain(grainLen: grainLen, spread: spread, rng: &rng)
}
writeHead = writeHead + 1
_result[0][i] = left
_result[1][i] = right
_result[0][i] = left * norm
_result[1][i] = right * norm
}
_writeHead = writeHead
_spawnCountdown = spawnCountdown
_rng = rng
return _result
@@ -222,7 +195,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
private func spawnGrain(
grainLen: Int,
spread: Double,
writeHead: Int,
rng: inout UInt64
) {
var voice: Int = -1
@@ -235,8 +207,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
_vActive[voice] = true
_vPhase[voice] = 0
_vLen[voice] = grainLen
// Read the grainLen samples just before the write head.
_vReadHead[voice] = writeHead - grainLen
let pan: Double = xorshift64Next(&rng) * spread // shared RT-safe PRNG, [-1, 1) × spread
let angle: Double = (pan + 1.0) * panAngleScale
_vGainL[voice] = cos(angle)
@@ -123,6 +123,32 @@ public struct EngineConfigView: View {
pendingInputs = shoeGaze.engine.numInputChannels
pendingOutputs = shoeGaze.engine.numOutputChannels
}
// Apply config edits to the (stopped) engine immediately so dependent UI — notably the
// input-source picker, which lists `0..<engine.numInputChannels` — reflects the new channel
// counts before Start. While running, the controls are disabled, so these never fire then.
.onChange(of: pendingInputs) { applyConfigWhileStopped() }
.onChange(of: pendingOutputs) { applyConfigWhileStopped() }
.onChange(of: pendingSampleRate) { applyConfigWhileStopped() }
}
/// Reconfigures the stopped engine with the pending values and notifies the host so views that
/// read non-observable engine state refresh. No-op while the engine is running.
private func applyConfigWhileStopped() {
guard !shoeGaze.engine.isRunning else { return }
do {
if let applyConfig: (Double, Int, Int) throws -> Void = applyConfig {
try applyConfig(pendingSampleRate, pendingInputs, pendingOutputs)
} else {
try shoeGaze.reconfigureEngine(
sampleRate: pendingSampleRate,
inputChannels: pendingInputs,
outputChannels: pendingOutputs
)
}
onConfigApplied()
} catch {
print("[EngineConfigView] live reconfigure failed: \(error)")
}
}
private func label(_ text: String) -> some View {
@@ -155,9 +155,10 @@ public struct PedalPaletteView: View {
}
}
/// Fixed-width-card row for a horizontal scroller: leading filter + PEDALS group, a divider,
/// then the ROUTING group.
/// Horizontal scroller: a PEDALS row (leading filter + colour-coded cards) with the ROUTING
/// row stacked beneath it.
private var horizontalBody: some View {
VStack(alignment: .leading, spacing: PedalPaletteView.sectionSpacing) {
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
sectionTitle("PEDALS")
@@ -166,13 +167,15 @@ public struct PedalPaletteView: View {
ForEach(visiblePedalNames, id: \.self) { name in
pedalRow(name)
}
Divider().overlay(Color.white.opacity(PedalPaletteView.cardBorderOpacity))
}
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
sectionTitle("ROUTING")
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
routingCard(title: option.title, caption: option.caption, action: option.action)
}
}
}
}
// MARK: - Subviews
@@ -118,6 +118,16 @@ public struct ShoeGazeBuilderView: View {
@State private var pendingSwitchEntry: RigEntry?
@State private var showSwitchSaveDialog: Bool = false
/// A failed edit (add pedal / routing / board) to surface as an alert. `nil` = no alert.
@State private var actionError: ActionError?
/// A user-facing failure message for the action-error alert.
private struct ActionError: Identifiable {
let id: UUID = UUID()
let title: String
let message: String
}
/// Archive export state. Cross-platform: backs the sidebar's Export Archive and the
/// "Save & Clear" flow is separate (it saves to the library, not a file).
@State private var showExporter: Bool = false
@@ -193,6 +203,7 @@ public struct ShoeGazeBuilderView: View {
.background(boardsSheetAnchor)
.background(rigExportAnchor)
.background(rigImportAnchor)
.background(actionErrorAnchor)
.rigNamePrompt($namePrompt)
.confirmationDialog(
"Erase all rigs?",
@@ -374,6 +385,43 @@ public struct ShoeGazeBuilderView: View {
}
}
/// Hosts the action-failure alert on its own node (one presentation per node).
private var actionErrorAnchor: some View {
Color.clear
.alert(
actionError?.title ?? "",
isPresented: Binding(
get: { actionError != nil },
set: { presented in if !presented { actionError = nil } }
),
presenting: actionError
) { _ in
Button("OK", role: .cancel) { }
} message: { error in
Text(error.message)
}
}
/// Surfaces a failed edit as an alert (and logs it). Maps the common stereo-width / merge errors
/// to player-facing wording (no API names); otherwise uses the error's `LocalizedError` text.
private func reportError(_ title: String, _ error: Error) {
actionError = ActionError(title: title, message: friendlyMessage(for: error))
}
private func friendlyMessage(for error: Error) -> String {
switch error as? ShoeGazeError {
case .stereoWidthExceeded, .cannotSplitStereoChain:
return "This board is already in stereo. Add a “Merge to Mono” before another stereo "
+ "(widening) pedal such as Chorus, Rotary, or a Granulator."
case .cannotMergeMonoChain:
return "This board is already mono — there’s no stereo signal to merge."
case .cannotUnzipMonoChain:
return "This board is mono — there’s no stereo signal to split into left/right lanes."
default:
return (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
}
}
#if !os(macOS)
/// Hosts the recording-folder importer on its own node.
private var recordingFolderImportAnchor: some View {
@@ -472,6 +520,7 @@ public struct ShoeGazeBuilderView: View {
}
} catch {
print("[ShoeGazeBuilderView] routing \(action) failed: \(error)")
reportError("Couldn’t add routing", error)
}
}
@@ -516,6 +565,7 @@ public struct ShoeGazeBuilderView: View {
autosave()
} catch {
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
reportError("Couldn’t add \(type)", error)
}
}
@@ -530,6 +580,7 @@ public struct ShoeGazeBuilderView: View {
} catch {
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
print("[ShoeGazeBuilderView] addBoard failed: \(error)")
reportError("Couldn’t add board", error)
}
}
@@ -52,9 +52,6 @@ struct AutoGranulatorPedalTests {
}
}
// Small min/max grains so audible output (which trails the write head by one grain) fills the
// reader's 4096-frame window.
@Test func buildsAndProducesNonSilentOutput() throws {
let samples: [Float] = try render { pedal in pedal.minGrain = 0.01; pedal.maxGrain = 0.03 }
#expect(!samples.isEmpty)
@@ -52,9 +52,6 @@ struct GranulatorPedalTests {
}
}
// Small grains so audible output (which trails the write head by one grain) fills the reader's
// 4096-frame window rather than starting after a long grain's worth of silence.
@Test func buildsAndProducesNonSilentOutput() throws {
let samples: [Float] = try render { pedal in pedal.grain = 0.02 }
#expect(!samples.isEmpty)
+78
View File
@@ -0,0 +1,78 @@
# ShoeGaze 1.2.0
Ten new pedals, an iCloud-synced rig library, and a reworked builder layout.
## New pedals
Ten additions bring the built-in catalog to 32:
**Gain**
- **Distortion** — mid-gain saturation between Overdrive and Fuzz (Drive / Tone).
**Modulation**
- **Flanger** — sweeping comb-filter jet with feedback (Rate / Depth / Feedback).
- **Vibrato** — pure pitch wobble, fully wet (Rate / Depth).
- **Rotary** — Leslie rotary-speaker: Doppler pitch wobble + volume throb, two-speed
(Chorale / Tremolo) with an acceleration ramp (Depth / Accel + Speed switch).
**Pitch**
- **Harmonizer** — two pitch-shifted harmony voices at fixed musical intervals, picked with a new
stepped knob (octave / 5th / 4th / major & minor 3rd & 6th, above and below) with per-voice and
direct levels.
**Delay / Reverb**
- **Reverse Delay** — backward-tape segments with feedback trails (Time / Feedback).
- **Shimmer Reverb** — regenerative ambient reverb whose tail climbs an octave as it sustains
(Size / Decay / Shimmer / Damp).
**Texture**
- **Bitcrusher** — sample-rate decimation + bit-depth reduction + tone (Crush / Bits / Tone).
- **Granulator** — stereo grain cloud; grains scattered across the stereo field by Spread
(Grain / Overlap / Spread).
- **Auto Granulator** — granulator whose grain size tracks your dynamics, with a Response switch to
flip the loud↔short / loud↔long relationship (Min Grain / Max Grain / Overlap / Spread + Response).
## Rig library (iCloud)
- Rigs are now a managed **library** in the left sidebar instead of one hand-saved file. New, Save,
Save As, Duplicate, Rename, Delete, and Erase All — each rig holds multiple boards.
- **iCloud sync** across your devices and both apps (macOS + iPad) via a shared container, with a
local fallback when iCloud is unavailable. The library loads on launch and shows a loading state.
- Selecting a rig prompts to save unsaved changes first (macOS + iOS).
- **Archive** import/export bundles the whole library as one hand-editable JSON file (replaces the
old single-rig save/load); legacy single-rig files still import.
- macOS **File menu**: New Rig (⌘N), Save Rig (⌘S), Export / Import Archive (⌘E / ⌘I).
- Saves and loads run off the main thread, so the UI never stalls on disk or iCloud.
## Builder UI
- Reworked top layout: scope + CPU meters beside a stacked board-mixer / horizontal pedal-picker,
giving the board canvas the full width below.
- **Pedal picker** cards are now **colour-coded by type**, with a **filter-by-type** menu
(Gain / Dynamics / EQ & Filter / Modulation / Pitch / Delay / Reverb / Texture; defaults to All).
- The builder is pinned to a dark color scheme, fixing black-on-dark system controls (nav title,
steppers, Record button) on iOS in light mode.
- The input-source picker reflects the **In** channel count as soon as you change it (the stopped
engine reconfigures immediately), so you can choose the input before Start.
- Failed edits now surface as an **alert** instead of a console log — e.g. adding a second stereo
(widening) pedal explains that the board is already stereo and to add a Merge to Mono first.
- The routing cards sit in their own row beneath the pedal picker.
## Fixes
- The granulators are now **latency-free** — grains window and pan the live input directly
(straight-through), instead of replaying buffered history.
- Shimmer Reverb no longer accumulates a DC offset at high shimmer (DC-blocked feedback path).
## Under the hood
- New RT-safe generators: `ReverseDelay`, `SampleRateDecimate`, `BitReduce`, `ShimmerReverb`,
`StereoGranulator`; a reusable `PedalSelectorKnob` control with preset round-trip.
- All new generators sanitise control inputs (finite + clamped) and pre-allocate buffers.
- 271 tests; RT-safety reviewed.
## Setup notes
- **iCloud:** enable the `iCloud.net.realizedsound.ShoeGazeData` container on both builder App IDs
(iCloud Documents) and sign with the same team for cross-device sync.
- Shimmer Reverb and the granulators reward a tuning pass to taste.