Compare commits
209 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ef09a771a | |||
| 3f05cfa416 | |||
| 4cae1e6fd0 | |||
| 24ac361c48 | |||
| 52c676605f | |||
| 10a6e122bf | |||
| 9dfadb129d | |||
| 1f5b70edc7 | |||
| a8bd0242a3 | |||
| 4c09825c2e | |||
| b1e59d2c03 | |||
| 0873bbd82e | |||
| 843ae5b5f6 | |||
| 0a8a8e549f | |||
| 3e3f86b737 | |||
| 097c38283e | |||
| 89a34016de | |||
| d1f823e54c | |||
| 75de04160b | |||
| 74227400ad | |||
| 243be726ea | |||
| 20b2034fed | |||
| 3edd64e782 | |||
| 53b506adeb | |||
| 4e8f6e280c | |||
| a434b14f4b | |||
| 0ddf350f1f | |||
| f8926ecfb8 | |||
| 9873dd258b | |||
| fc6ddb8d9a | |||
| 812a240e55 | |||
| 93ca9076d2 | |||
| 4a9bf0fb30 | |||
| 850b86209a | |||
| 2aea609f34 | |||
| 44e6c35550 | |||
| 5decdd8693 | |||
| 132515b4cd | |||
| 392ae1525a | |||
| ad6ed41674 | |||
| fba32ff0aa | |||
| 2c970aa344 | |||
| 7dccf596f4 | |||
| 75b99a547b | |||
| 965633de34 | |||
| 779c55493d | |||
| bb418ca2e8 | |||
| 4eb1cbdd61 | |||
| 2fd7eaee57 | |||
| 654e80e9c8 | |||
| 292261a088 | |||
| a1ce308082 | |||
| 685bf5833e | |||
| 5a3cbeb372 | |||
| 11ce3f47d2 | |||
| da68864f36 | |||
| ebc660898d | |||
| f9ddd6b160 | |||
| da2c3328ee | |||
| 9b23f99a58 | |||
| d7eb0690ff | |||
| 35ae16040a | |||
| f67a5370ff | |||
| 96ab2a0586 | |||
| 99649c2d89 | |||
| 7f1856e8e5 | |||
| a2fcd59e1b | |||
| 594c501039 | |||
| e8b858f1aa | |||
| 9daffbbdf3 | |||
| 9c0122f199 | |||
| 781577b062 | |||
| 1de14fd879 | |||
| 6cf698dbac | |||
| 0f6d69819d | |||
| 3cdb8d9ddb | |||
| b4a04f6dc8 | |||
| f7787c4ba3 | |||
| 8a8cac3823 | |||
| d32caf6262 | |||
| ac61b47d17 | |||
| 88ad976b8e | |||
| 95839a9e35 | |||
| 573a91f377 | |||
| 31fa1b9cd3 | |||
| 9c0f89bae6 | |||
| 651706126c | |||
| cda596b9d5 | |||
| a7534a29db | |||
| e88db04686 | |||
| da4d5e23ea | |||
| 8cd77ad984 | |||
| 818478ce1b | |||
| 415e99dd62 | |||
| 71d9b44809 | |||
| 4de8379cb8 | |||
| 690030a4c5 | |||
| 8a08264fb4 | |||
| e5deb8f94a | |||
| 9abc613fc3 | |||
| 48dce06f5a | |||
| b9a63eeaf5 | |||
| 9588d77137 | |||
| 5d8e655dab | |||
| 17a0845225 | |||
| 29b1747533 | |||
| 102715ded1 | |||
| 27fb6e6898 | |||
| a9e91ef08c | |||
| c9795f7305 | |||
| 6718914ee0 | |||
| 544a07d569 | |||
| fb50538e84 | |||
| e1ed4e348c | |||
| 3fe6b8a50a | |||
| 59370ee5dd | |||
| 8a266a33dc | |||
| ec4e7dc5a4 | |||
| 733e979c1b | |||
| 1b247cf766 | |||
| 23d607b9fc | |||
| 40fa590196 | |||
| fe31eb6d7d | |||
| 77df1675cb | |||
| 4a5d4009f6 | |||
| 791fbd1b2c | |||
| 323988af7b | |||
| ed3283f645 | |||
| 8983e8829e | |||
| e697789bd7 | |||
| 09fa4e8d4b | |||
| 37777826d1 | |||
| a1a7683bc9 | |||
| 3d67c7b450 | |||
| 551b650d45 | |||
| 7720fbec7b | |||
| 3228614071 | |||
| e207728a12 | |||
| e36074e9d3 | |||
| b29c8848ef | |||
| be0e3d118b | |||
| 5542ee5b5a | |||
| b0294612f8 | |||
| cc3a986cde | |||
| 5987ec7b78 | |||
| f61961b90b | |||
| 7e39842eb2 | |||
| 2772abdc56 | |||
| a33d5488c9 | |||
| 2c2ce06797 | |||
| 8b72957502 | |||
| e051521c04 | |||
| 4b0cf65a2b | |||
| 0bfc25ace6 | |||
| 426a288002 | |||
| 12e83bd172 | |||
| bf1e09ede3 | |||
| cd3aeb771b | |||
| e75b50b157 | |||
| 6a3c4fdca9 | |||
| 22ae022143 | |||
| 722c8d9069 | |||
| 1c9979af52 | |||
| 36202a5e95 | |||
| 19feb03fe8 | |||
| f97ba90ea6 | |||
| 67744ec89d | |||
| ba80573213 | |||
| efa193ea37 | |||
| 45b18b5ea8 | |||
| 5b343a2cce | |||
| d07247e40e | |||
| bdfbe04713 | |||
| 5090a9255f | |||
| 4e58c9bd9b | |||
| 2ce6dda9da | |||
| b6f1d78066 | |||
| 296ca1b24e | |||
| 3ef39a7a0d | |||
| 5dafc00d98 | |||
| fb3e2d2653 | |||
| ae067ac6d7 | |||
| 6f651b6e17 | |||
| 67d4434220 | |||
| b99a526df6 | |||
| d728bfa72a | |||
| fee7892101 | |||
| 83b8fff74b | |||
| 3007b76798 | |||
| 465e3e6dfd | |||
| 947dfe427a | |||
| 097253b410 | |||
| 9ccdada4f1 | |||
| 75edf44b64 | |||
| d4664b3c1f | |||
| bab4fdd087 | |||
| 9cb8788cc0 | |||
| 401682d266 | |||
| 4fef5aed7b | |||
| dee1c29744 | |||
| 48ac573489 | |||
| e25b75a880 | |||
| 4d8464282e | |||
| a7bbda4166 | |||
| 1ba622a611 | |||
| ae8f370fa8 | |||
| 1893576718 | |||
| ec6c97c065 | |||
| 0b0befe02f |
@@ -20,3 +20,7 @@ DerivedData/
|
||||
# Note: Package.resolved is intentionally tracked to pin the Lyrebird dependency.
|
||||
icon-source.png
|
||||
review.diff
|
||||
|
||||
# Local working plan (not shared)
|
||||
docs/plans/amp-expansion-plan.md
|
||||
docs/plans/pedal-expansion-plan.md
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to ShoeGaze are recorded here. The format follows
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
||||
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.1.1] — 2026-08-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Mutant switch captions no longer wrap.** The envelope filter's three segmented switches
|
||||
(Direction / Mode / Range — seven segments in all) were crammed into a single-width pedal,
|
||||
wrapping the "Down" caption to "Do wn". Mutant is now double-width, like the Cabinet and amp
|
||||
pedals, so the switch captions have room.
|
||||
|
||||
## [3.1.0] — 2026-08-13
|
||||
|
||||
Starter rigs and a deeper envelope filter. ShoeGaze now ships a library of ready-to-play
|
||||
rigs grouped by style, two new pedals, and a much more expressive Mutant envelope filter —
|
||||
plus a batch of rig-switching and reverb fixes.
|
||||
|
||||
### Added
|
||||
|
||||
- **18 built-in starter rigs**, seeded into the library on first launch and grouped by
|
||||
style — **Shoegaze Walls**, **Dreampop**, **Classic**, **Ambient**, and **Experimental**.
|
||||
A **Mine / Starters** toggle at the top of the rig sidebar switches between your own rigs
|
||||
and the shipped ones (grouped under category headers); the sidebar opens on whichever
|
||||
group holds the current rig. A **Restore Starter Rigs** action (rig-library menu, or the
|
||||
Starters empty state) reinstalls the shipped rigs at any time.
|
||||
- **Two-board starter rig** — a Garcia-style clean/effects split across two boards, switched
|
||||
with the board Solo / Blend control, showing off multi-board rigs.
|
||||
- **Vibe pedal** — a photocell "vibe": four staggered all-pass stages swept by one LFO, with
|
||||
**Chorus** and **Vibrato** modes and Speed / Intensity controls.
|
||||
- **Sustain Fuzz pedal** — a mid-scooped, high-sustain fuzz (two cascaded soft-clip stages),
|
||||
distinct from the brighter single-stage Fuzz. Sustain / Tone / Scoop controls.
|
||||
- **Mutant (envelope filter) controls** — a **Range** switch (Lo / Hi) that shifts the whole
|
||||
sweep band, matching the original Mu-Tron III, plus **Sweep**, **Attack**, and **Release**
|
||||
in the advanced pop-over. Sweep sets how far your picking drives the cutoff; Attack /
|
||||
Release shape how quickly the filter follows.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Switching rigs keeps your current input.** Loading a rig from the library no longer snaps
|
||||
the input back to the test loop (or the input a rig was saved with) — your live guitar (or
|
||||
whatever input you have selected) carries across the switch. Opening or restoring a rig
|
||||
file still applies its saved input.
|
||||
- **Shimmer Reverb backed off.** The regenerating loop gain is roughly `decay + shimmer`, so
|
||||
the old defaults (0.8 + 0.5) self-oscillated into a screech with little or no input.
|
||||
Defaults are now decay 0.5 / shimmer 0.25 / damp 0.5, and the starter rigs that use it were
|
||||
re-tuned to stay well below self-oscillation.
|
||||
- **Mutant sweep defaults tamed** — resting cutoff 80 → 120 Hz and sweep span 40× → 20×, so
|
||||
the filter is neither muted at rest nor extreme when it opens.
|
||||
- **Starter rigs refresh on update.** Shipped rigs install (and refresh to their current
|
||||
form) by catalog version, so a corrected starter reaches libraries that were seeded
|
||||
earlier — without touching your own rigs.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **No more spurious "Save changes?" prompt when switching rigs.** The unsaved-changes check
|
||||
compared live session settings (input source, engine channel counts) that legitimately
|
||||
differ from a rig's saved values; it now compares rig content only.
|
||||
- **Starter rigs can't be overwritten by accident.** A built-in starter rig is managed content
|
||||
(refreshed to the shipped version on updates), so saving over a loaded starter offers **Save
|
||||
as New Rig** or **Cancel** — your changes are kept as your own rig rather than replacing the
|
||||
shipped one.
|
||||
- **Multi-board signal-router rigs now save and load.** Routed A/B rigs were previously lost
|
||||
on save; their branch chains and blend now persist.
|
||||
|
||||
## [3.0.0] — 2026-08-04
|
||||
|
||||
The big one: ShoeGaze becomes an amp-modeling rig. This release adds a full lineup of
|
||||
tube-amp voices — each with its own tone stack, onboard effects, and control surface —
|
||||
plus a deep speaker-cabinet and microphone section. Everything is original DSP built in
|
||||
code from the Lyrebird engine; there are no third-party captures or IR packs.
|
||||
|
||||
### Added
|
||||
|
||||
- **26 amp-model pedals**, grouped in their own **Amp Model** palette category:
|
||||
- **Fullerton** blackface combos — Fullerton Reverb, Deluxe, Ivy League, Drive — with
|
||||
spring reverb, tremolo, and a Bright switch.
|
||||
- **California** and **Jazz Clean** clean machines.
|
||||
- **British** stack and combo voices — British, Plexi, JTM, Bluesbreaker, Master, Dual —
|
||||
from early crunch to hot-rodded master-volume lead.
|
||||
- **Chime** top-boost family — Chime, Chime 15, Chime Normal, Chime Baby, Chime Top
|
||||
Boost — with the classic Cut control.
|
||||
- **Boutique and high-gain** — Boutique Lead, Boutique OD, Cali Hi-Gain (with an onboard
|
||||
5-band graphic EQ), and Modern High-Gain (Sag + Tight).
|
||||
- **Character amps** — Command, Citrus, Sixties Combo, Magna Vibrato (true pitch
|
||||
vibrato), and Anaheim (a solid-state-preamp / tube-power-amp hybrid with a built-in
|
||||
limiter).
|
||||
|
||||
Each amp carries its own tone-stack voicing, a selectable speaker cabinet, and a real
|
||||
**master volume** that drives the power-amp stage — not just an output trim.
|
||||
- **Analog-style output limiting.** Every amp ends in a soft `tanh` saturation into a hard
|
||||
±1 ceiling, so a driven amp compresses like the real thing instead of digitally clipping.
|
||||
- **Power-amp feel controls**, tucked behind an advanced pop-over (the sliders button at the
|
||||
top-right of the amp card): **Sag** (power-supply droop and bloom), **Bias**, and **Bias X**
|
||||
(bias balance).
|
||||
- **A full speaker-cabinet and microphone section** on the Cabinet pedal, now in its own
|
||||
**Cabinet** palette category next to the amps:
|
||||
- **Cabinet voices** — eight synthesized speaker voicings.
|
||||
- **Microphone modeling** — No Mic / Dynamic / Ribbon / Condenser, folded into the cab
|
||||
response.
|
||||
- **Mic placement** — Position (on-axis ↔ cone edge) and Proximity (distance / bass lift).
|
||||
- **Dual-mic blend** — add a second mic with its own blend and spacing (comb) control,
|
||||
the classic two-mic technique.
|
||||
- A transparent look-ahead limiter on the cabinet output.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Gain and Drive now read 1–11** — yes, they go to eleven — with a musical taper: fine
|
||||
control at the bottom of the dial, full saturation at the top, instead of a raw internal
|
||||
number.
|
||||
- **The cabinet is now a separate pedal you place in the chain.** Amps keep a built-in cab,
|
||||
plus a **None (direct)** option so you can run a dedicated Cabinet block (and, later, your
|
||||
own impulse response) after the amp.
|
||||
- **Palette:** the Amp Model and Cabinet categories sit together, and the Cabinet card is
|
||||
double-width to fit its cab / mic / second-mic selectors.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Noise Gate no longer pops as a note decays.** The gate now opens fast and closes gently
|
||||
(a slow, tunable fade) instead of snapping shut when a sustained note falls through the
|
||||
threshold — previously that abrupt step, amplified by downstream gain (e.g. a fuzz), was
|
||||
audible as a pop / sudden tone change. New **Attack** and **Release** timing knobs (in the
|
||||
gate's advanced pop-over) dial the close from tight to a gradual swell.
|
||||
|
||||
### Notes
|
||||
|
||||
- All amp, cabinet, and microphone models are original DSP generated in code — not captures
|
||||
of any specific hardware, speaker, microphone, or IR pack. Tube tone stacks follow the
|
||||
published Yeh & Smith analysis of the classic passive tone-stack circuit.
|
||||
|
||||
## [2.1.3] — 2026-07-13
|
||||
|
||||
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output —
|
||||
even with "Mute while tuning" on — until a steady note was detected.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Tuner no longer leaks into the audio output.** The tuner's pitch-detection stage
|
||||
was mistakenly written to an audio output bus instead of its internal analysis bus,
|
||||
so the tracked frequency was summed onto an output channel — bypassing the rig mute
|
||||
and crackling while the pitch was still unstable (it stopped once a note locked). The
|
||||
tuner now writes only to its analysis bus; engaging it leaves the output untouched.
|
||||
|
||||
## [2.1.1] — 2026-07-12
|
||||
|
||||
A quieter, more predictable startup. The input feeding the pedals now has its own
|
||||
mute — separate from the rig-output mute — that arms every time you start the engine,
|
||||
so nothing squeals the instant it spins up. New rigs open listening to In 0 instead of
|
||||
the test-loop phrase, and your input choice and I/O channel counts now travel with the
|
||||
rig (and iCloud) instead of a separate local setting.
|
||||
|
||||
### Added
|
||||
|
||||
- **Input mute.** A hard kill-switch on the incoming guitar / mic signal, distinct from
|
||||
the rig-output mute. It arms automatically every time you press Start (so a fresh
|
||||
engine is silent until you're ready), sits next to the Start/Stop transport with a
|
||||
pulsing red glow while active, and is MIDI-mappable (footswitch or key), like Rig Mute.
|
||||
|
||||
### Changed
|
||||
|
||||
- **New rigs open on In 0** (live input) instead of the built-in test-loop phrase.
|
||||
- **Input & I/O persist with the rig.** The input selection and the engine's input /
|
||||
output channel counts are stored in the rig (and sync via iCloud), and are reapplied
|
||||
on launch — so a multi-channel setup and a chosen input channel survive a restart
|
||||
instead of reverting to the defaults. Replaces the previous local-only input setting.
|
||||
- The docked (macOS) transport shows the Bypass / Mute / Input toggles as icons so the
|
||||
row no longer crowds the sample-rate and channel controls.
|
||||
|
||||
### Fixed
|
||||
|
||||
- A muted input is now **exactly** silent from the first sample — no brief start-up
|
||||
transient when the engine begins rendering.
|
||||
- iOS: the app declares in-place document support, clearing a launch-time console warning.
|
||||
|
||||
### Compatibility
|
||||
|
||||
Additive: rigs saved before this release load unchanged (input defaults to In 0, or the
|
||||
test loop when no live input is available), and 2.1.1 rigs still open in older builds —
|
||||
the input-mute state isn't persisted and the extra I/O fields are ignored there.
|
||||
|
||||
## [2.1.0] — 2026-07-10
|
||||
|
||||
Tempo comes to the pedals. Delay times and modulation rates can lock to a note
|
||||
division of the live tempo — a quarter-note delay, a dotted-eighth, an eighth-triplet
|
||||
LFO — shown with real music-notation glyphs and following the tempo as it changes.
|
||||
Delays reach further, the BPM is directly editable, and every mappable control shows
|
||||
its MIDI / key binding right on the pedal.
|
||||
|
||||
### Added
|
||||
|
||||
- **Tempo-synced pedal parameters.** Lock a delay time or a modulation rate to a note
|
||||
division — whole down to sixteenth, including dotted and triplet values — and it is
|
||||
derived from the shared tempo, following tap tempo, the stepper, the BPM field, and
|
||||
MIDI. Delay time on Delay, Feedback Delay, Ping-Pong, Reverse Delay, and each of
|
||||
Multi-Tap's three taps; LFO rate on Tremolo, Vibrato, Chorus, Flanger, Phaser, and
|
||||
Modulation. A MIDI CC bound to a synced parameter is ignored while it stays synced
|
||||
(the tempo drives the value) and resumes control once the parameter is set to Free.
|
||||
- **Note-value glyphs.** The division picker uses drawn music-notation glyphs —
|
||||
noteheads, stems, flags, an augmentation dot for dotted values, and a bracketed "3"
|
||||
over triplets — instead of text labels.
|
||||
- **Editable BPM.** The tempo readout is now a text field: type a tempo directly
|
||||
(integer only, clamped to 30–300 BPM). The stepper and tap tempo still work, and a
|
||||
synced pedal follows a typed change immediately.
|
||||
- **In-context control mapping.** Each pedal draws a small badge on every mappable
|
||||
control showing its binding source — Program Change footswitch (PC), Control Change
|
||||
expression (CC), or letter Key (KEY) — with a legend above the board. Completes the
|
||||
computer-keyboard control mapping.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Longer delays.** Maximum delay time raised to 5 seconds across the delay pedals
|
||||
(previously 1–2 s), so tempo-synced values at slow tempos (whole and half notes) fit.
|
||||
- Note divisions that would exceed a parameter's range at the current tempo are shown
|
||||
disabled in the picker, and an active sync that has to clamp shows a warning marker.
|
||||
|
||||
### Compatibility
|
||||
|
||||
Additive: rigs saved before this release load unchanged (every parameter defaults to
|
||||
"free"), and 2.1 rigs still open in older builds — the tempo-sync state is simply
|
||||
ignored there.
|
||||
|
||||
## [2.0.0] — 2026-07-05
|
||||
|
||||
Major release. Performance-focused: a visual metronome, a real rig mute with
|
||||
keyboard control, and rigs that remember their tempo, input, and I/O — plus a
|
||||
saveable set-list order for hands-free switching between rigs live. The version
|
||||
jumps to 2.0.0 to align ShoeGaze's numbering with the wider project family.
|
||||
|
||||
### Added
|
||||
|
||||
- **Visual metronome tempo indicator.** A horizontal playhead sweeps wall-to-wall
|
||||
once per beat with pendulum easing (it slows into each beat so you can anticipate
|
||||
it), fades toward center, and flashes a glow on the downbeat. Replaces the single
|
||||
flashing LED.
|
||||
- **Rig Mute (⌘Z).** A hard gate that silences the entire rig output — distinct from
|
||||
Bypass Rig, which passes your dry signal through. Reachable from the header, the
|
||||
per-board volume row, the macOS Board menu, and MIDI.
|
||||
- **Keyboard shortcuts** (macOS native menus + iOS/iPadOS hardware keyboards):
|
||||
- `⌘1`–`⌘9` — switch to / solo boards 1–9.
|
||||
- `⌘⇧1`–`⌘⇧9` and `⌘⇧0` — load set-list rigs 1–10 in library order.
|
||||
- `⌘Z` — toggle rig mute.
|
||||
|
||||
All are listed in the in-app Help.
|
||||
- **macOS menus.** Board ▸ Mute Rig and Board ▸ Bypass Rig (with live state), and a
|
||||
Rigs ▸ Set List submenu whose ten slots map to `⌘⇧1`–`⌘⇧0` and track the current
|
||||
library order.
|
||||
- **Set-list ordering.** Reorder rigs in the picker by dragging a row or via each
|
||||
rig's Move Up / Move Down menu. The order is saved and travels with an exported
|
||||
archive; the top ten map to the `⌘⇧` shortcuts.
|
||||
- **Per-rig persistence.** A saved rig now also stores its tempo (BPM + enabled
|
||||
state) and input selection. Engine input/output channel counts are saved too, and
|
||||
applied on demand via `applyChannelLayout(from:)` rather than forced on every load.
|
||||
|
||||
### Changed
|
||||
|
||||
- The header "Mute rig" toggle — which actually only set the tuner-mutes-rig
|
||||
preference — is now a real rig-mute button. The tuner preference is relabeled
|
||||
**"Mute while tuning"**.
|
||||
- The rig library now honors a manual set-list order instead of sorting by name/date.
|
||||
New rigs append to the end; renaming a rig keeps its position.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Importing a rig archive into a non-empty library no longer collides set-list
|
||||
positions with existing rigs — imported rigs append in archive order.
|
||||
|
||||
### Removed
|
||||
|
||||
- The **ShoeGazeDemo** (macOS) and **ShoeGazeiOSDemo** (iOS) minimal-player apps and
|
||||
their Xcode projects. Only the full **ShoeGazeBuilder** (macOS) and
|
||||
**ShoeGazeBuilderiOS** (iPad) apps remain.
|
||||
|
||||
### Compatibility
|
||||
|
||||
- Despite the major-version bump, rig persistence is backward-compatible: the new
|
||||
tempo / input / I/O / set-list fields are additive and optional. Rigs saved by
|
||||
earlier versions load unchanged (missing fields are ignored), and rigs saved by
|
||||
2.0.0 still open in older builds (the new keys are ignored there). The 2.0.0 bump
|
||||
reflects the scope of new features and version alignment, not a format break.
|
||||
|
||||
## [1.5.0] — 2026-07-04
|
||||
|
||||
- Looper pedal, iPad/iOS layout rework, Lyrebird 1.2.3.
|
||||
|
||||
## [1.4.0] — 2026-07-01
|
||||
|
||||
- Maintenance and refinements.
|
||||
|
||||
## [1.3.0] — 2026-06-28
|
||||
|
||||
- Rig / board sharing via the `.shoegaze` document type.
|
||||
|
||||
## [1.2.0] — 2026-06-28
|
||||
|
||||
- Ten new pedals, iCloud rig library, builder UI rework.
|
||||
|
||||
## [1.1.1] — 2026-06-26
|
||||
|
||||
- Info-button placement and region-lane drag-drop fix.
|
||||
|
||||
## [1.1.0] — 2026-06-26
|
||||
|
||||
- Refinements over the initial release.
|
||||
|
||||
## [1.0.0] — 2026-06-24
|
||||
|
||||
- Initial ShoeGaze release.
|
||||
@@ -100,7 +100,7 @@
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1600;
|
||||
LastUpgradeCheck = 2620;
|
||||
LastUpgradeCheck = 2700;
|
||||
TargetAttributes = {
|
||||
C3B100000000000000000014 = {
|
||||
CreatedOnToolsVersion = 16.0;
|
||||
@@ -163,10 +163,9 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 23;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
@@ -176,7 +175,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 1.2.0;
|
||||
MARKETING_VERSION = 3.3;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -194,9 +193,8 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 23;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
@@ -206,7 +204,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 1.2.0;
|
||||
MARKETING_VERSION = 3.3;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -218,6 +216,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -249,6 +248,7 @@
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -280,6 +280,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -311,6 +312,7 @@
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -366,7 +368,8 @@
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
kind = versionRange;
|
||||
maximumVersion = 3.0.0;
|
||||
minimumVersion = 1.2.0;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||
"version" : "1.2.0"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
LastUpgradeVersion = "2700"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -20,7 +20,7 @@ import LyrebirdShoeGazeUI
|
||||
/// The engine is **not** started automatically; the user clicks Start in the builder's toolbar.
|
||||
/// On termination the engine is stopped to release Core Audio resources cleanly.
|
||||
@MainActor
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
|
||||
// MARK: - Engine configuration constants
|
||||
|
||||
@@ -55,12 +55,48 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
private let shoeGaze: ShoeGaze
|
||||
private let window: LyrebirdWindow
|
||||
|
||||
/// Multi-level undo / redo for structural rig edits. The same instance backs both the Edit-menu
|
||||
/// items here and `ShoeGazeBuilderView`'s own edits, so ⌘Z works from the menu and the canvas.
|
||||
private let undo: UndoCoordinator
|
||||
|
||||
/// Foot-controller MIDI input. The macOS engine is never rebuilt, so this is created once and
|
||||
/// started at launch.
|
||||
private let midi: MIDIController
|
||||
|
||||
/// The rig library; constructed in `init`, resolved + loaded asynchronously after launch.
|
||||
private let library: RigLibraryStore
|
||||
|
||||
/// Record toggle item, retained so `validateMenuItem(_:)` can flip its title + enabled state.
|
||||
private var recordMenuItem: NSMenuItem?
|
||||
|
||||
/// Rig-mute toggle item, retained so `validateMenuItem(_:)` can flip its title + checkmark to
|
||||
/// match the current mute state (which may also change from the UI, MIDI, or the tuner).
|
||||
private var muteMenuItem: NSMenuItem?
|
||||
|
||||
/// Rig-bypass toggle item, retained so `validateMenuItem(_:)` can flip its title + checkmark to
|
||||
/// match the current bypass state (which may also change from the UI or MIDI).
|
||||
private var bypassMenuItem: NSMenuItem?
|
||||
|
||||
/// Undo / Redo items, retained so `validateMenuItem(_:)` can enable them and refresh their
|
||||
/// titles to the next action (e.g. "Undo Add Reverb").
|
||||
private var undoMenuItem: NSMenuItem?
|
||||
private var redoMenuItem: NSMenuItem?
|
||||
|
||||
/// The Rigs ▸ Set List submenu, retained so its item titles can be refreshed to the current
|
||||
/// library order each time it opens (via `menuNeedsUpdate(_:)`).
|
||||
private var setListMenu: NSMenu?
|
||||
|
||||
/// The ten fixed ⌘⇧1…⌘⇧0 set-list items (tags 0…9). Their key equivalents fire whether or not
|
||||
/// the menu is open; `validateMenuItem(_:)` disables slots with no rig, and `menuNeedsUpdate`
|
||||
/// refreshes their titles to the rig names.
|
||||
private var setListMenuItems: [NSMenuItem] = []
|
||||
|
||||
/// Number of set-list slots exposed as ⌘⇧1…⌘⇧0.
|
||||
private static let setListSlotCount: Int = 10
|
||||
|
||||
/// The Help window, created lazily on first open and reused thereafter.
|
||||
private var helpWindow: LyrebirdWindow?
|
||||
|
||||
/// Default file name offered by the archive Export panel.
|
||||
private static let defaultArchiveFileName: String = "ShoeGaze Library"
|
||||
|
||||
@@ -68,6 +104,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
override init() {
|
||||
let coreDriver: CoreAudioDriver = CoreAudioDriver()
|
||||
// The engine is built with the default layout; the autosaved rig's saved I/O layout (if any)
|
||||
// is applied by `RigStore.restore` below, so a multi-channel setup survives relaunch.
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: AppDelegate.blockSize,
|
||||
sampleRate: AppDelegate.sampleRate,
|
||||
@@ -80,6 +118,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
self.coreDriver = coreDriver
|
||||
self.engine = engine
|
||||
self.shoeGaze = shoeGaze
|
||||
self.undo = UndoCoordinator(shoeGaze: shoeGaze)
|
||||
self.midi = MIDIController(engine: engine, shoeGaze: shoeGaze)
|
||||
self.window = LyrebirdWindow(
|
||||
title: "ShoeGaze Builder — Lyrebird Pedalboard",
|
||||
width: AppDelegate.windowWidth,
|
||||
@@ -99,6 +139,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
/// Seeds one board with a single pedal so the builder opens with an audible starting point.
|
||||
private static func seedInitialBoard(into shoeGaze: ShoeGaze) {
|
||||
// Fresh launch (no autosaved rig): default to live In 0 rather than the test-loop arpeggio,
|
||||
// so the app comes up listening to the instrument. A restored rig keeps its own saved input.
|
||||
if shoeGaze.engine.numInputChannels > 0 {
|
||||
shoeGaze.inputSource = .liveInput(channel: 0)
|
||||
}
|
||||
var created: PedalBoard?
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
@@ -114,14 +159,23 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
installMainMenu()
|
||||
midi.start()
|
||||
midi.onMapChanged = { [weak self] in
|
||||
guard let self: AppDelegate = self else { return }
|
||||
RigStore.save(self.shoeGaze)
|
||||
}
|
||||
let session: ShoeGaze = shoeGaze
|
||||
let driver: CoreAudioDriver = coreDriver
|
||||
let rigLibrary: RigLibraryStore = library
|
||||
let midiController: MIDIController = midi
|
||||
let undoCoordinator: UndoCoordinator = undo
|
||||
window.open {
|
||||
ShoeGazeBuilderView(
|
||||
shoeGaze: session,
|
||||
library: rigLibrary,
|
||||
hardwareSampleRate: { driver.deviceSampleRate }
|
||||
hardwareSampleRate: { driver.deviceSampleRate },
|
||||
midi: midiController,
|
||||
undo: undoCoordinator
|
||||
)
|
||||
}
|
||||
anchorWindowLeft()
|
||||
@@ -260,6 +314,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
addItem(to: fileMenu, title: "Export Archive…", action: #selector(exportArchiveAction(_:)), key: "e")
|
||||
addItem(to: fileMenu, title: "Import Archive…", action: #selector(importArchiveAction(_:)), key: "i")
|
||||
|
||||
// Edit menu — multi-level undo / redo of structural rig edits (add / remove / move pedals,
|
||||
// boards, routing). ⌘Z / ⇧⌘Z; titles + enabled state refresh in `validateMenuItem(_:)`.
|
||||
let editMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(editMenuItem)
|
||||
let editMenu: NSMenu = NSMenu(title: "Edit")
|
||||
editMenuItem.submenu = editMenu
|
||||
self.undoMenuItem = addItem(
|
||||
to: editMenu,
|
||||
title: "Undo",
|
||||
action: #selector(undoAction(_:)),
|
||||
key: "z"
|
||||
)
|
||||
self.redoMenuItem = addItem(
|
||||
to: editMenu,
|
||||
title: "Redo",
|
||||
action: #selector(redoAction(_:)),
|
||||
key: "z"
|
||||
)
|
||||
self.redoMenuItem?.keyEquivalentModifierMask = [.command, .shift]
|
||||
|
||||
// Board menu — add board + transport.
|
||||
let boardMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(boardMenuItem)
|
||||
@@ -268,6 +342,51 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// Engine start/stop lives in the in-window EngineConfigView (with sample-rate/channel
|
||||
// config and the mismatch alert), so the Board menu only adds boards.
|
||||
addItem(to: boardMenu, title: "Add Board", action: #selector(addBoardAction(_:)), key: "b")
|
||||
boardMenu.addItem(NSMenuItem.separator())
|
||||
// ⌘M toggles rig mute (a hard silence of all output; distinct from Bypass Rig's dry
|
||||
// passthrough). ⌘Z / ⇧⌘Z are Undo / Redo (Edit menu); the in-window view binds ⌘M on iOS.
|
||||
self.muteMenuItem = addItem(
|
||||
to: boardMenu,
|
||||
title: "Mute Rig",
|
||||
action: #selector(toggleMuteAction(_:)),
|
||||
key: "m"
|
||||
)
|
||||
// Bypass Rig routes every board to its dry input (pedals skipped) — distinct from Mute's
|
||||
// hard silence. No key equivalent: ⌘B is Add Board, and Bypass has a prominent on-screen button.
|
||||
self.bypassMenuItem = addItem(
|
||||
to: boardMenu,
|
||||
title: "Bypass Rig",
|
||||
action: #selector(toggleBypassAction(_:)),
|
||||
key: ""
|
||||
)
|
||||
|
||||
// Rigs menu — a Set List of the top ten library rigs, each on ⌘⇧1…⌘⇧0. The items are
|
||||
// fixed; their titles refresh to the current library order on open, and their key
|
||||
// equivalents fire whether or not the menu is showing.
|
||||
let rigsMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(rigsMenuItem)
|
||||
let rigsMenu: NSMenu = NSMenu(title: "Rigs")
|
||||
rigsMenuItem.submenu = rigsMenu
|
||||
let setListItem: NSMenuItem = NSMenuItem(title: "Set List", action: nil, keyEquivalent: "")
|
||||
rigsMenu.addItem(setListItem)
|
||||
let setListSubmenu: NSMenu = NSMenu(title: "Set List")
|
||||
setListSubmenu.delegate = self
|
||||
setListItem.submenu = setListSubmenu
|
||||
for slot: Int in 0 ..< AppDelegate.setListSlotCount {
|
||||
// Slots 0…8 → ⌘⇧1…⌘⇧9; slot 9 → ⌘⇧0 (matches the physical number row).
|
||||
let key: String = slot < 9 ? "\(slot + 1)" : "0"
|
||||
let item: NSMenuItem = NSMenuItem(
|
||||
title: "\(slot + 1). —",
|
||||
action: #selector(loadRigSlotAction(_:)),
|
||||
keyEquivalent: key
|
||||
)
|
||||
item.keyEquivalentModifierMask = [.command, .shift]
|
||||
item.target = self
|
||||
item.tag = slot
|
||||
setListSubmenu.addItem(item)
|
||||
setListMenuItems.append(item)
|
||||
}
|
||||
self.setListMenu = setListSubmenu
|
||||
|
||||
// Record menu — choose an output folder, then toggle recording.
|
||||
let recordMenuItem: NSMenuItem = NSMenuItem()
|
||||
@@ -288,6 +407,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
key: "R" // ⇧⌘R
|
||||
)
|
||||
|
||||
// Help menu — opens the in-app guide.
|
||||
let helpMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(helpMenuItem)
|
||||
let helpMenu: NSMenu = NSMenu(title: "Help")
|
||||
helpMenuItem.submenu = helpMenu
|
||||
addItem(to: helpMenu, title: "ShoeGaze Help", action: #selector(showHelpAction(_:)), key: "?")
|
||||
|
||||
NSApplication.shared.mainMenu = mainMenu
|
||||
}
|
||||
|
||||
@@ -307,6 +433,40 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
// MARK: - Menu actions
|
||||
|
||||
/// Reverts the most recent structural rig edit — unless a text field is being edited, in which
|
||||
/// case its own field editor handles ⌘Z (so typing a rig name keeps normal text undo).
|
||||
@objc private func undoAction(_ sender: Any?) {
|
||||
if let editor: NSText = NSApp.keyWindow?.firstResponder as? NSText,
|
||||
let manager: UndoManager = editor.undoManager {
|
||||
manager.undo()
|
||||
return
|
||||
}
|
||||
undo.undo()
|
||||
}
|
||||
|
||||
/// Re-applies the most recently undone structural rig edit, deferring to a text field's own redo
|
||||
/// while one is being edited (mirrors ``undoAction(_:)``).
|
||||
@objc private func redoAction(_ sender: Any?) {
|
||||
if let editor: NSText = NSApp.keyWindow?.firstResponder as? NSText,
|
||||
let manager: UndoManager = editor.undoManager {
|
||||
manager.redo()
|
||||
return
|
||||
}
|
||||
undo.redo()
|
||||
}
|
||||
|
||||
/// Opens (or re-opens) the Help window hosting the shared ``HelpView``.
|
||||
@objc private func showHelpAction(_ sender: Any?) {
|
||||
let helpWidth: CGFloat = 560
|
||||
let helpHeight: CGFloat = 720
|
||||
if helpWindow == nil {
|
||||
helpWindow = LyrebirdWindow(title: "ShoeGaze Help", width: helpWidth, height: helpHeight)
|
||||
}
|
||||
helpWindow?.open {
|
||||
HelpView()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func newRigAction(_ sender: Any?) {
|
||||
// Forward to the builder view, which owns the current-rig state and naming prompt.
|
||||
NotificationCenter.default.post(name: .shoeGazeNewRig, object: nil)
|
||||
@@ -348,12 +508,34 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func toggleMuteAction(_ sender: Any?) {
|
||||
shoeGaze.toggleRigMuted()
|
||||
// Reflect the new state immediately, not only on the next menu-open validation.
|
||||
muteMenuItem?.title = shoeGaze.rigMuted ? "Unmute Rig" : "Mute Rig"
|
||||
muteMenuItem?.state = shoeGaze.rigMuted ? .on : .off
|
||||
}
|
||||
|
||||
@objc private func toggleBypassAction(_ sender: Any?) {
|
||||
shoeGaze.toggleRigBypassed()
|
||||
bypassMenuItem?.title = shoeGaze.rigBypassed ? "Re-engage Rig" : "Bypass Rig"
|
||||
bypassMenuItem?.state = shoeGaze.rigBypassed ? .on : .off
|
||||
}
|
||||
|
||||
/// Loads the set-list rig at the sender's slot tag. Forwards to the in-window builder (which
|
||||
/// owns the current-rig state, the unsaved-changes prompt, and engine lifecycle) via notification.
|
||||
@objc private func loadRigSlotAction(_ sender: NSMenuItem) {
|
||||
NotificationCenter.default.post(name: .shoeGazeLoadRigSlot, object: sender.tag)
|
||||
}
|
||||
|
||||
@objc private func addBoardAction(_ sender: Any?) {
|
||||
var created: PedalBoard?
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
created = board
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
// Record as an undo checkpoint, matching the in-window Add Board.
|
||||
try undo.perform("Add Board") {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
created = board
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
}
|
||||
} catch {
|
||||
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||
print("[ShoeGazeBuilder] addBoard failed: \(error)")
|
||||
@@ -387,12 +569,62 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
recordMenuItem?.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording"
|
||||
}
|
||||
|
||||
// MARK: - NSMenuDelegate
|
||||
|
||||
/// Refreshes the Set List item titles to the current library order each time the submenu opens.
|
||||
/// Key equivalents fire independently of this (see `setListMenuItems`); this is display only.
|
||||
func menuNeedsUpdate(_ menu: NSMenu) {
|
||||
guard menu === setListMenu else { return }
|
||||
let entries: [RigEntry] = library.entries
|
||||
for item: NSMenuItem in setListMenuItems {
|
||||
let slot: Int = item.tag
|
||||
if slot < entries.count {
|
||||
item.title = "\(slot + 1). \(entries[slot].name)"
|
||||
} else {
|
||||
item.title = "\(slot + 1). —"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
if menuItem == recordMenuItem {
|
||||
menuItem.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording"
|
||||
// Can always stop; can only start once a folder has been chosen.
|
||||
return shoeGaze.isRecording || shoeGaze.recordingFolder != nil
|
||||
}
|
||||
if menuItem == muteMenuItem {
|
||||
// Mute may have changed from the UI, MIDI, or the tuner — resync title + checkmark.
|
||||
menuItem.title = shoeGaze.rigMuted ? "Unmute Rig" : "Mute Rig"
|
||||
menuItem.state = shoeGaze.rigMuted ? .on : .off
|
||||
return true
|
||||
}
|
||||
if menuItem == bypassMenuItem {
|
||||
// Bypass may have changed from the UI or MIDI — resync title + checkmark.
|
||||
menuItem.title = shoeGaze.rigBypassed ? "Re-engage Rig" : "Bypass Rig"
|
||||
menuItem.state = shoeGaze.rigBypassed ? .on : .off
|
||||
return true
|
||||
}
|
||||
if menuItem == undoMenuItem {
|
||||
// Name the next action so the menu reads "Undo Add Reverb"; disable when there's none.
|
||||
if let label: String = undo.undoActionLabel {
|
||||
menuItem.title = "Undo \(label)"
|
||||
} else {
|
||||
menuItem.title = "Undo"
|
||||
}
|
||||
return undo.canUndo
|
||||
}
|
||||
if menuItem == redoMenuItem {
|
||||
if let label: String = undo.redoActionLabel {
|
||||
menuItem.title = "Redo \(label)"
|
||||
} else {
|
||||
menuItem.title = "Redo"
|
||||
}
|
||||
return undo.canRedo
|
||||
}
|
||||
if setListMenuItems.contains(menuItem) {
|
||||
// A slot is live only when the library actually holds a rig at that position.
|
||||
return menuItem.tag < library.entries.count
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 643 KiB |
@@ -2,6 +2,21 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>ShoeGaze Document</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Owner</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>net.realizedsound.shoegaze</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -13,9 +28,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.3.0</string>
|
||||
<string>${MARKETING_VERSION}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.music</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
@@ -40,32 +55,17 @@
|
||||
<string>Any</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>ShoeGaze Document</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Owner</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>net.realizedsound.shoegaze</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>net.realizedsound.shoegaze</string>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>ShoeGaze Document</string>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.json</string>
|
||||
</array>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>ShoeGaze Document</string>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>net.realizedsound.shoegaze</string>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
C3C10000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001C /* LyrebirdUI */; };
|
||||
C3C10000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001E /* Lyrebird */; };
|
||||
C3C100000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000030 /* Assets.xcassets */; };
|
||||
C3C1000000000000000000B1 /* SplashView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C1000000000000000000B0 /* SplashView.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -22,6 +23,7 @@
|
||||
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSApp.swift; sourceTree = "<group>"; };
|
||||
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSAppModel.swift; sourceTree = "<group>"; };
|
||||
C3C100000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
C3C1000000000000000000B0 /* SplashView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashView.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -60,6 +62,7 @@
|
||||
children = (
|
||||
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */,
|
||||
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */,
|
||||
C3C1000000000000000000B0 /* SplashView.swift */,
|
||||
C3C100000000000000000030 /* Assets.xcassets */,
|
||||
C3C100000000000000000006 /* Info.plist */,
|
||||
);
|
||||
@@ -100,7 +103,7 @@
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1600;
|
||||
LastUpgradeCheck = 2620;
|
||||
LastUpgradeCheck = 2700;
|
||||
TargetAttributes = {
|
||||
C3C100000000000000000011 = {
|
||||
CreatedOnToolsVersion = 16.0;
|
||||
@@ -147,6 +150,7 @@
|
||||
files = (
|
||||
C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */,
|
||||
C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */,
|
||||
C3C1000000000000000000B1 /* SplashView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -157,10 +161,12 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 10;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
@@ -169,11 +175,13 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = 2;
|
||||
@@ -184,9 +192,11 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
CURRENT_PROJECT_VERSION = 10;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
@@ -195,11 +205,13 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = 2;
|
||||
@@ -210,6 +222,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -240,6 +253,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -272,6 +286,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -302,6 +317,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -358,8 +374,9 @@
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 1.2.0;
|
||||
kind = versionRange;
|
||||
maximumVersion = 3.0.0;
|
||||
minimumVersion = 1.7.2;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||
"version" : "1.2.0"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
LastUpgradeVersion = "2700"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -31,7 +31,7 @@
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
|
||||
|
Before Width: | Height: | Size: 402 KiB After Width: | Height: | Size: 643 KiB |
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : { "red" : "0.080", "green" : "0.070", "blue" : "0.060", "alpha" : "1.000" }
|
||||
}
|
||||
}
|
||||
],
|
||||
"info" : { "author" : "xcode", "version" : 1 }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"images" : [
|
||||
{ "idiom" : "universal", "filename" : "splashlogo.png", "scale" : "1x" },
|
||||
{ "idiom" : "universal", "filename" : "splashlogo@2x.png", "scale" : "2x" },
|
||||
{ "idiom" : "universal", "filename" : "splashlogo@3x.png", "scale" : "3x" }
|
||||
],
|
||||
"info" : { "author" : "xcode", "version" : 1 }
|
||||
}
|
||||
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 208 KiB |
|
After Width: | Height: | Size: 420 KiB |
@@ -2,57 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.3.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>UILaunchScreen</key>
|
||||
<dict/>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>NSUbiquitousContainers</key>
|
||||
<dict>
|
||||
<key>iCloud.net.realizedsound.ShoeGazeData</key>
|
||||
<dict>
|
||||
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
|
||||
<true/>
|
||||
<key>NSUbiquitousContainerName</key>
|
||||
<string>ShoeGaze</string>
|
||||
<key>NSUbiquitousContainerSupportedFolderLevels</key>
|
||||
<string>Any</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
@@ -68,17 +17,74 @@
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${MARKETING_VERSION}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||
<key>NSUbiquitousContainers</key>
|
||||
<dict>
|
||||
<key>iCloud.net.realizedsound.ShoeGazeData</key>
|
||||
<dict>
|
||||
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
|
||||
<true/>
|
||||
<key>NSUbiquitousContainerName</key>
|
||||
<string>ShoeGaze</string>
|
||||
<key>NSUbiquitousContainerSupportedFolderLevels</key>
|
||||
<string>Any</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>UILaunchScreen</key>
|
||||
<dict>
|
||||
<key>UIColorName</key>
|
||||
<string>LaunchBackground</string>
|
||||
</dict>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>net.realizedsound.shoegaze</string>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>ShoeGaze Document</string>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.json</string>
|
||||
</array>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>ShoeGaze Document</string>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>net.realizedsound.shoegaze</string>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
|
||||
@@ -13,29 +13,38 @@ import LyrebirdShoeGazeUI
|
||||
/// lifetime of the app. The audio engine is **not** started automatically — the user presses
|
||||
/// Start in ``ShoeGazeBuilderView``. The engine is stopped when the view disappears.
|
||||
///
|
||||
/// ``ShoeGazeBuilderView`` manages its own scroll regions (palette + builder), so it is hosted
|
||||
/// directly rather than wrapped in an outer `ScrollView`.
|
||||
/// ``ShoeGazeBuilderView`` draws its own header/title and manages its own scroll regions (palette
|
||||
/// + board canvas), so it is hosted directly — no `NavigationStack`, title, or outer `ScrollView`.
|
||||
/// A fill frame keeps it pinned to the full window so portrait isn't vertically centered.
|
||||
@main
|
||||
struct ShoeGazeBuilderiOSApp: App {
|
||||
|
||||
@State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel()
|
||||
@State private var showSplash: Bool = true
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
ShoeGazeBuilderView(
|
||||
shoeGaze: model.shoeGaze,
|
||||
library: model.library,
|
||||
hardwareSampleRate: { model.hardwareSampleRate },
|
||||
onEnableLiveInput: { model.enableLiveInput() }
|
||||
onEnableLiveInput: { model.enableLiveInput() },
|
||||
midi: model.midi,
|
||||
undo: model.undo
|
||||
)
|
||||
.navigationTitle("ShoeGaze Builder")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
.task { await model.startLibrary() }
|
||||
.onDisappear { model.stop() }
|
||||
.onOpenURL { url in model.importDocument(at: url) }
|
||||
|
||||
if showSplash {
|
||||
SplashView(isActive: $showSplash)
|
||||
.transition(.opacity)
|
||||
.zIndex(1)
|
||||
}
|
||||
}
|
||||
.onDisappear { model.stop() }
|
||||
.onOpenURL { url in model.importDocument(at: url) }
|
||||
}
|
||||
.onChange(of: scenePhase) { _, phase in
|
||||
// Persist the rig whenever the app leaves the foreground.
|
||||
|
||||
@@ -34,21 +34,23 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
private static let numAudioBuses: Int = 256
|
||||
private static let seedPedalType: PedalType = .overdrive
|
||||
|
||||
/// UserDefaults key persisting the input selection. Must match the key written by the
|
||||
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
||||
private static let inputSelectionDefaultsKey: String = "ShoeGaze.inputSelection"
|
||||
/// Persisted value meaning "live input, channel 0".
|
||||
private static let liveInputChannelZeroTag: Int = 0
|
||||
|
||||
// MARK: - Owned objects
|
||||
|
||||
/// The active ShoeGaze builder session. Swapped out when live input is enabled (the engine
|
||||
/// is rebuilt with an input channel); the `@Observable` change re-binds the hosting view.
|
||||
private(set) var shoeGaze: ShoeGaze
|
||||
|
||||
/// Multi-level undo / redo for structural rig edits, bound to the current `shoeGaze`. Recreated
|
||||
/// when `shoeGaze` is swapped by the live-input rebuild (history resets across that rebuild).
|
||||
private(set) var undo: UndoCoordinator
|
||||
|
||||
private var engine: SynthesisEngine
|
||||
private var iosDriver: iOSAudioDriver
|
||||
|
||||
/// Foot-controller MIDI input. Owned here so it outlives the live-input engine rebuild; the
|
||||
/// underlying Core MIDI client is engine-bound, so it is recreated against each new engine.
|
||||
private(set) var midi: MIDIController
|
||||
|
||||
/// The shared rig library (iCloud-or-local). Independent of the engine, so it survives the
|
||||
/// live-input engine rebuild.
|
||||
private(set) var library: RigLibraryStore
|
||||
@@ -72,6 +74,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
self.engine = built.engine
|
||||
self.iosDriver = built.driver
|
||||
self.shoeGaze = shoeGaze
|
||||
self.undo = UndoCoordinator(shoeGaze: shoeGaze)
|
||||
|
||||
// Restore the autosaved working rig if there is one; otherwise seed a default board. Operate
|
||||
// on the local `shoeGaze`, not `self.shoeGaze`: self may not be touched until every stored
|
||||
@@ -83,6 +86,11 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
// Construct the library instantly; it resolves iCloud + loads asynchronously via
|
||||
// startLibrary() from the app's .task.
|
||||
self.library = RigLibraryBootstrap.makeStore()
|
||||
|
||||
// Connect MIDI foot-controller input and begin listening for devices.
|
||||
self.midi = MIDIController(engine: built.engine, shoeGaze: shoeGaze)
|
||||
self.midi.start()
|
||||
self.midi.onMapChanged = { [weak self] in self?.save() }
|
||||
}
|
||||
|
||||
/// Persists the current rig. Call when the app moves to the background.
|
||||
@@ -135,6 +143,8 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
) -> (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) {
|
||||
let sampleRate: Double = AVAudioSession.sharedInstance().sampleRate
|
||||
let driver: iOSAudioDriver = iOSAudioDriver()
|
||||
// The engine is built with the default layout; the autosaved rig's saved I/O (if any) is
|
||||
// applied by `RigStore.restore`, so an output change survives relaunch.
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: ShoeGazeBuilderiOSAppModel.blockSize,
|
||||
sampleRate: sampleRate,
|
||||
@@ -192,6 +202,8 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
self.engine = rebuilt.engine
|
||||
self.iosDriver = rebuilt.driver
|
||||
self.shoeGaze = rebuilt.shoeGaze
|
||||
// Bind undo to the new session; history resets across the engine rebuild.
|
||||
self.undo = UndoCoordinator(shoeGaze: rebuilt.shoeGaze)
|
||||
|
||||
do {
|
||||
// Teardown already happened, so a restore failure can only recover by seeding.
|
||||
@@ -201,19 +213,24 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
ShoeGazeBuilderiOSAppModel.seedFallbackBoard(into: shoeGaze)
|
||||
}
|
||||
|
||||
// The Core MIDI client is bound to the old engine — recreate it against the new one and
|
||||
// point it at the rebuilt rig, preserving the "MIDI outlives the rebuild" contract.
|
||||
midi.stop()
|
||||
midi = MIDIController(engine: rebuilt.engine, shoeGaze: shoeGaze)
|
||||
midi.start()
|
||||
midi.onMapChanged = { [weak self] in self?.save() }
|
||||
|
||||
selectLiveInputAndPersist()
|
||||
|
||||
if wasRunning { try? engine.start() }
|
||||
}
|
||||
|
||||
/// Selects live input on channel 0 and persists the choice for restore-on-relaunch.
|
||||
/// Selects live input on channel 0 and autosaves so the rig (the source of truth for the input
|
||||
/// selection) records it for restore-on-relaunch.
|
||||
private func selectLiveInputAndPersist() {
|
||||
do {
|
||||
try shoeGaze.setInputSource(.liveInput(channel: 0))
|
||||
UserDefaults.standard.set(
|
||||
ShoeGazeBuilderiOSAppModel.liveInputChannelZeroTag,
|
||||
forKey: ShoeGazeBuilderiOSAppModel.inputSelectionDefaultsKey
|
||||
)
|
||||
save()
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderiOS] selecting live input failed: \(error)")
|
||||
}
|
||||
@@ -221,6 +238,11 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
|
||||
/// Seeds a single default board so the rig is never empty after a failed restore.
|
||||
private static func seedFallbackBoard(into shoeGaze: ShoeGaze) {
|
||||
// Fresh launch (no autosaved rig): default to live In 0 rather than the test-loop arpeggio.
|
||||
// A restored rig keeps its own saved input selection.
|
||||
if shoeGaze.engine.numInputChannels > 0 {
|
||||
shoeGaze.inputSource = .liveInput(channel: 0)
|
||||
}
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Board 1"
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// SplashView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// Animated launch splash shown over the app on cold start.
|
||||
///
|
||||
/// The native launch screen (`UILaunchScreen` → `LaunchBackground`) paints an instant dark
|
||||
/// backdrop with no visible jump; this view then fades and scales the ShoeGaze pedal logo in,
|
||||
/// holds briefly, and fades the whole overlay away to reveal ``ShoeGazeBuilderView``. Colors match
|
||||
/// the app background so the hand-off is seamless. Respects Reduce Motion by skipping the scale.
|
||||
struct SplashView: View {
|
||||
|
||||
/// Background matching the builder's app background (`0.08, 0.07, 0.06`).
|
||||
private static let backgroundColor: Color = Color(red: 0.08, green: 0.07, blue: 0.06)
|
||||
|
||||
private static let logoSize: CGFloat = 200
|
||||
private static let logoCornerRadius: CGFloat = 44
|
||||
private static let logoStartScale: CGFloat = 0.86
|
||||
private static let wordmarkKerning: CGFloat = 4
|
||||
|
||||
private static let logoFadeInDuration: Double = 0.55
|
||||
private static let wordmarkFadeInDelay: Double = 0.30
|
||||
private static let wordmarkFadeInDuration: Double = 0.45
|
||||
private static let holdDuration: Double = 0.85
|
||||
private static let fadeOutDuration: Double = 0.45
|
||||
|
||||
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
||||
|
||||
/// Set false to fade the overlay out; parent removes it when the fade completes.
|
||||
@Binding var isActive: Bool
|
||||
|
||||
@State private var logoOpacity: Double = 0
|
||||
@State private var logoScale: CGFloat = SplashView.logoStartScale
|
||||
@State private var wordmarkOpacity: Double = 0
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
SplashView.backgroundColor
|
||||
.ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 22) {
|
||||
Image("SplashLogo")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: SplashView.logoSize, height: SplashView.logoSize)
|
||||
.clipShape(RoundedRectangle(cornerRadius: SplashView.logoCornerRadius,
|
||||
style: .continuous))
|
||||
.opacity(logoOpacity)
|
||||
.scaleEffect(logoScale)
|
||||
|
||||
Text("ShoeGaze")
|
||||
.font(.system(size: 34, weight: .semibold, design: .rounded))
|
||||
.kerning(SplashView.wordmarkKerning)
|
||||
.foregroundStyle(.white)
|
||||
.opacity(wordmarkOpacity)
|
||||
}
|
||||
}
|
||||
.onAppear { runSequence() }
|
||||
}
|
||||
|
||||
private func runSequence() {
|
||||
withAnimation(.easeOut(duration: SplashView.logoFadeInDuration)) {
|
||||
logoOpacity = 1
|
||||
if !reduceMotion { logoScale = 1 }
|
||||
}
|
||||
withAnimation(.easeOut(duration: SplashView.wordmarkFadeInDuration)
|
||||
.delay(SplashView.wordmarkFadeInDelay)) {
|
||||
wordmarkOpacity = 1
|
||||
}
|
||||
|
||||
let holdUntil: Double = SplashView.logoFadeInDuration + SplashView.holdDuration
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + holdUntil) {
|
||||
withAnimation(.easeIn(duration: SplashView.fadeOutDuration)) {
|
||||
isActive = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,397 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 60;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
C3B000000000000000000020 /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001E /* LyrebirdShoeGaze */; };
|
||||
C3B000000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001F /* LyrebirdShoeGazeUI */; };
|
||||
C3B000000000000000000022 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000023 /* Lyrebird */; };
|
||||
C3B000000000000000000024 /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000025 /* LyrebirdUI */; };
|
||||
C3B000000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000030 /* Assets.xcassets */; };
|
||||
C3B0000000000000000000C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000007 /* main.swift */; };
|
||||
C3B0000000000000000000D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000008 /* AppDelegate.swift */; };
|
||||
C3B0000000000000000000E /* DemoRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000009 /* DemoRootView.swift */; };
|
||||
C3B0000000000000000000F /* ShoeGazeDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B00000000000000000000A /* ShoeGazeDemoController.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
C3B000000000000000000004 /* ShoeGazeDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C3B000000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
C3B000000000000000000007 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||
C3B000000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
C3B000000000000000000009 /* DemoRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoRootView.swift; sourceTree = "<group>"; };
|
||||
C3B00000000000000000000A /* ShoeGazeDemoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeDemoController.swift; sourceTree = "<group>"; };
|
||||
C3B000000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
C3B000000000000000000012 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C3B000000000000000000020 /* LyrebirdShoeGaze in Frameworks */,
|
||||
C3B000000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */,
|
||||
C3B000000000000000000022 /* Lyrebird in Frameworks */,
|
||||
C3B000000000000000000024 /* LyrebirdUI in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
C3B000000000000000000002 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3B000000000000000000005 /* ShoeGazeDemo */,
|
||||
C3B000000000000000000003 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C3B000000000000000000003 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3B000000000000000000004 /* ShoeGazeDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C3B000000000000000000005 /* ShoeGazeDemo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3B000000000000000000007 /* main.swift */,
|
||||
C3B000000000000000000008 /* AppDelegate.swift */,
|
||||
C3B000000000000000000009 /* DemoRootView.swift */,
|
||||
C3B00000000000000000000A /* ShoeGazeDemoController.swift */,
|
||||
C3B000000000000000000030 /* Assets.xcassets */,
|
||||
C3B000000000000000000006 /* Info.plist */,
|
||||
);
|
||||
path = ShoeGazeDemo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
C3B000000000000000000014 /* ShoeGazeDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C3B000000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeDemo" */;
|
||||
buildPhases = (
|
||||
C3B000000000000000000011 /* Sources */,
|
||||
C3B000000000000000000012 /* Frameworks */,
|
||||
C3B000000000000000000013 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = ShoeGazeDemo;
|
||||
packageProductDependencies = (
|
||||
C3B00000000000000000001E /* LyrebirdShoeGaze */,
|
||||
C3B00000000000000000001F /* LyrebirdShoeGazeUI */,
|
||||
C3B000000000000000000023 /* Lyrebird */,
|
||||
C3B000000000000000000025 /* LyrebirdUI */,
|
||||
);
|
||||
productName = ShoeGazeDemo;
|
||||
productReference = C3B000000000000000000004 /* ShoeGazeDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
C3B000000000000000000001 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1600;
|
||||
LastUpgradeCheck = 2620;
|
||||
TargetAttributes = {
|
||||
C3B000000000000000000014 = {
|
||||
CreatedOnToolsVersion = 16.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = C3B000000000000000000018 /* Build configuration list for PBXProject "ShoeGazeDemo" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = C3B000000000000000000002;
|
||||
packageReferences = (
|
||||
C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */,
|
||||
C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */,
|
||||
);
|
||||
productRefGroup = C3B000000000000000000003 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
C3B000000000000000000014 /* ShoeGazeDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
C3B000000000000000000013 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C3B000000000000000000031 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
C3B000000000000000000011 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C3B0000000000000000000C /* main.swift in Sources */,
|
||||
C3B0000000000000000000D /* AppDelegate.swift in Sources */,
|
||||
C3B0000000000000000000E /* DemoRootView.swift in Sources */,
|
||||
C3B0000000000000000000F /* ShoeGazeDemoController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C3B000000000000000000016 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeDemo/ShoeGazeDemo.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = ShoeGazeDemo/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C3B000000000000000000017 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeDemo/ShoeGazeDemo.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = ShoeGazeDemo/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C3B000000000000000000019 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C3B00000000000000000001A /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
C3B000000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C3B000000000000000000016 /* Debug */,
|
||||
C3B000000000000000000017 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C3B000000000000000000018 /* Build configuration list for PBXProject "ShoeGazeDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C3B000000000000000000019 /* Debug */,
|
||||
C3B00000000000000000001A /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCLocalSwiftPackageReference section */
|
||||
C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */ = {
|
||||
isa = XCLocalSwiftPackageReference;
|
||||
relativePath = ..;
|
||||
};
|
||||
/* End XCLocalSwiftPackageReference section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 1.2.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
C3B00000000000000000001E /* LyrebirdShoeGaze */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */;
|
||||
productName = LyrebirdShoeGaze;
|
||||
};
|
||||
C3B00000000000000000001F /* LyrebirdShoeGazeUI */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */;
|
||||
productName = LyrebirdShoeGazeUI;
|
||||
};
|
||||
C3B000000000000000000023 /* Lyrebird */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||
productName = Lyrebird;
|
||||
};
|
||||
C3B000000000000000000025 /* LyrebirdUI */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||
productName = LyrebirdUI;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = C3B000000000000000000001 /* Project object */;
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C3B000000000000000000014"
|
||||
BuildableName = "ShoeGazeDemo.app"
|
||||
BlueprintName = "ShoeGazeDemo"
|
||||
ReferencedContainer = "container:ShoeGazeDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C3B000000000000000000014"
|
||||
BuildableName = "ShoeGazeDemo.app"
|
||||
BlueprintName = "ShoeGazeDemo"
|
||||
ReferencedContainer = "container:ShoeGazeDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C3B000000000000000000014"
|
||||
BuildableName = "ShoeGazeDemo.app"
|
||||
BlueprintName = "ShoeGazeDemo"
|
||||
ReferencedContainer = "container:ShoeGazeDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,153 +0,0 @@
|
||||
// AppDelegate.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
import LyrebirdShoeGazeUI
|
||||
|
||||
/// Application delegate for the ShoeGaze demo.
|
||||
///
|
||||
/// Creates a `SynthesisEngine`, a `ShoeGazeDemoController` (which builds the default
|
||||
/// `.boards` showcase automatically), and opens a `LyrebirdWindow` hosting `DemoRootView`.
|
||||
///
|
||||
/// The engine is **not** started automatically. The user clicks Start in `DemoRootView`'s
|
||||
/// toolbar (or presses Stop to halt audio). On application termination, `stop()` is called
|
||||
/// to release Core Audio resources cleanly.
|
||||
@MainActor
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
// MARK: - Engine configuration constants
|
||||
|
||||
private static let blockSize: Int = 512
|
||||
private static let sampleRate: Double = 48_000.0
|
||||
private static let outputChannels: Int = 2
|
||||
// Built-in mics are mono; default to one input channel so live input works out of the box
|
||||
// (CoreAudio can't satisfy more input channels than the device provides). Raise in the UI.
|
||||
private static let inputChannels: Int = 1
|
||||
private static let numAudioBuses: Int = 256
|
||||
|
||||
// MARK: - Window geometry constants
|
||||
|
||||
private static let windowWidth: CGFloat = 1_100
|
||||
private static let windowHeight: CGFloat = 640
|
||||
|
||||
// MARK: - Owned objects
|
||||
|
||||
private let coreDriver: CoreAudioDriver
|
||||
private let controller: ShoeGazeDemoController
|
||||
private let window: LyrebirdWindow
|
||||
|
||||
/// The Mute menu item, retained so `validateMenuItem(_:)` can update its checkmark.
|
||||
private var muteMenuItem: NSMenuItem?
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
override init() {
|
||||
let coreDriver: CoreAudioDriver = CoreAudioDriver()
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: AppDelegate.blockSize,
|
||||
sampleRate: AppDelegate.sampleRate,
|
||||
numOutputChannels: AppDelegate.outputChannels,
|
||||
numInputChannels: AppDelegate.inputChannels,
|
||||
numAudioBuses: AppDelegate.numAudioBuses,
|
||||
driver: coreDriver
|
||||
)
|
||||
|
||||
self.coreDriver = coreDriver
|
||||
self.controller = ShoeGazeDemoController(engine: engine)
|
||||
self.window = LyrebirdWindow(
|
||||
title: "ShoeGaze — Lyrebird Guitar Pedalboard",
|
||||
width: AppDelegate.windowWidth,
|
||||
height: AppDelegate.windowHeight
|
||||
)
|
||||
super.init()
|
||||
}
|
||||
|
||||
// MARK: - NSApplicationDelegate
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
installMainMenu()
|
||||
let demoController: ShoeGazeDemoController = controller
|
||||
let driver: CoreAudioDriver = coreDriver
|
||||
window.open {
|
||||
DemoRootView(controller: demoController, hardwareSampleRate: { driver.deviceSampleRate })
|
||||
}
|
||||
}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
controller.stop()
|
||||
}
|
||||
|
||||
// MARK: - Main menu
|
||||
|
||||
/// Builds the app's menu bar: an application menu (About / Hide / Quit ⌘Q) and an
|
||||
/// Audio menu (Mute ⌘M). Standard items route through the responder chain to
|
||||
/// `NSApplication`; Mute targets this delegate.
|
||||
private func installMainMenu() {
|
||||
let appName: String = ProcessInfo.processInfo.processName
|
||||
let mainMenu: NSMenu = NSMenu()
|
||||
|
||||
// Application menu.
|
||||
let appMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(appMenuItem)
|
||||
let appMenu: NSMenu = NSMenu()
|
||||
appMenuItem.submenu = appMenu
|
||||
appMenu.addItem(
|
||||
withTitle: "About \(appName)",
|
||||
action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)),
|
||||
keyEquivalent: ""
|
||||
)
|
||||
appMenu.addItem(NSMenuItem.separator())
|
||||
appMenu.addItem(
|
||||
withTitle: "Hide \(appName)",
|
||||
action: #selector(NSApplication.hide(_:)),
|
||||
keyEquivalent: "h"
|
||||
)
|
||||
appMenu.addItem(NSMenuItem.separator())
|
||||
appMenu.addItem(
|
||||
withTitle: "Quit \(appName)",
|
||||
action: #selector(NSApplication.terminate(_:)),
|
||||
keyEquivalent: "q"
|
||||
)
|
||||
|
||||
// Audio menu.
|
||||
let audioMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(audioMenuItem)
|
||||
let audioMenu: NSMenu = NSMenu(title: "Audio")
|
||||
audioMenuItem.submenu = audioMenu
|
||||
let mute: NSMenuItem = NSMenuItem(
|
||||
title: "Mute",
|
||||
action: #selector(toggleMute(_:)),
|
||||
keyEquivalent: "m"
|
||||
)
|
||||
mute.target = self
|
||||
audioMenu.addItem(mute)
|
||||
muteMenuItem = mute
|
||||
|
||||
NSApplication.shared.mainMenu = mainMenu
|
||||
}
|
||||
|
||||
/// Toggles audio output (mute). Bound to the Audio ▸ Mute menu item (⌘M).
|
||||
@objc private func toggleMute(_ sender: Any?) {
|
||||
controller.toggleMute()
|
||||
}
|
||||
|
||||
/// Shows a checkmark on the Mute item while audio is silenced (engine not running).
|
||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
if menuItem == muteMenuItem {
|
||||
menuItem.state = controller.isRunning ? .off : .on
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{"size":"16x16","idiom":"mac","filename":"icon_16x16.png","scale":"1x"},
|
||||
{"size":"16x16","idiom":"mac","filename":"icon_16x16@2x.png","scale":"2x"},
|
||||
{"size":"32x32","idiom":"mac","filename":"icon_32x32.png","scale":"1x"},
|
||||
{"size":"32x32","idiom":"mac","filename":"icon_32x32@2x.png","scale":"2x"},
|
||||
{"size":"128x128","idiom":"mac","filename":"icon_128x128.png","scale":"1x"},
|
||||
{"size":"128x128","idiom":"mac","filename":"icon_128x128@2x.png","scale":"2x"},
|
||||
{"size":"256x256","idiom":"mac","filename":"icon_256x256.png","scale":"1x"},
|
||||
{"size":"256x256","idiom":"mac","filename":"icon_256x256@2x.png","scale":"2x"},
|
||||
{"size":"512x512","idiom":"mac","filename":"icon_512x512.png","scale":"1x"},
|
||||
{"size":"512x512","idiom":"mac","filename":"icon_512x512@2x.png","scale":"2x"}
|
||||
],
|
||||
"info" : {"author":"xcode","version":1}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 782 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 345 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 345 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -1 +0,0 @@
|
||||
{ "info" : {"author":"xcode","version":1} }
|
||||
@@ -1,303 +0,0 @@
|
||||
// DemoRootView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
import SwiftUI
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
import LyrebirdShoeGazeUI
|
||||
|
||||
/// Root view for the ShoeGaze demo window.
|
||||
///
|
||||
/// Presents a top toolbar with a mode picker, an input-source toggle, and a Start/Stop
|
||||
/// transport button, followed by a content area that switches between four showcase
|
||||
/// modes as the user selects them.
|
||||
///
|
||||
/// Because `ShoeGazeDemoController` is `@Observable`, SwiftUI re-renders this view and
|
||||
/// all its children whenever `controller.mode`, `controller.shoeGaze.boards`,
|
||||
/// `controller.router`, `controller.parallelSection`, or `controller.isRunning` change —
|
||||
/// including after a ``ShoeGazeDemoController/rebuild()`` that replaces `shoeGaze`.
|
||||
///
|
||||
/// ## Mode showcases
|
||||
///
|
||||
/// - `.boards` → `ShoeGazeView` — two boards, eight pedals, master gain per board.
|
||||
/// - `.editor` → `BoardEditorView` — board + FlowLayout pedal area + version snapshots.
|
||||
/// - `.parallel` → `ParallelSectionView` — splitter, two branch rows, merger (via board).
|
||||
/// - `.router` → `ChainRouterView` — dual-board chain router with splitter + master.
|
||||
/// - `.stereo` → `StereoSplitSectionView` — stereo split with the four route modes.
|
||||
struct DemoRootView: View {
|
||||
|
||||
// MARK: - Layout constants
|
||||
|
||||
private static let toolbarSpacing: CGFloat = 10
|
||||
private static let toolbarPadding: CGFloat = 12
|
||||
private static let contentPadding: CGFloat = 16
|
||||
private static let windowMinWidth: CGFloat = 1_100
|
||||
private static let windowMinHeight: CGFloat = 640
|
||||
/// Dark stage-floor background (warm almost-black).
|
||||
private static let backgroundRed: Double = 0.08
|
||||
private static let backgroundGreen: Double = 0.07
|
||||
private static let backgroundBlue: Double = 0.06
|
||||
private static let dividerOpacity: Double = 0.15
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private let controller: ShoeGazeDemoController
|
||||
private let hardwareSampleRate: () -> Double?
|
||||
|
||||
/// Bumped on each transport press so the buttons re-read `controller.isRunning`
|
||||
/// (which derives from the non-observable engine).
|
||||
@State private var transportTick: Bool = false
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates the root demo view bound to the given controller.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - controller: The `ShoeGazeDemoController` that owns the engine, active `ShoeGaze`
|
||||
/// session, and current mode. All toolbar actions dispatch through this.
|
||||
/// - hardwareSampleRate: Returns the actual hardware sample rate (or `nil`), for the engine-
|
||||
/// config mismatch warning. Defaults to `nil`.
|
||||
init(
|
||||
controller: ShoeGazeDemoController,
|
||||
hardwareSampleRate: @escaping () -> Double? = { nil }
|
||||
) {
|
||||
self.controller = controller
|
||||
self.hardwareSampleRate = hardwareSampleRate
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
toolbar
|
||||
Divider()
|
||||
.overlay(Color.white.opacity(DemoRootView.dividerOpacity))
|
||||
contentArea
|
||||
.padding(DemoRootView.contentPadding)
|
||||
Divider()
|
||||
.overlay(Color.white.opacity(DemoRootView.dividerOpacity))
|
||||
ShoeGazeScopeView(shoeGaze: controller.shoeGaze)
|
||||
.padding(DemoRootView.contentPadding)
|
||||
}
|
||||
.frame(
|
||||
minWidth: DemoRootView.windowMinWidth,
|
||||
minHeight: DemoRootView.windowMinHeight
|
||||
)
|
||||
.background(
|
||||
Color(
|
||||
red: DemoRootView.backgroundRed,
|
||||
green: DemoRootView.backgroundGreen,
|
||||
blue: DemoRootView.backgroundBlue
|
||||
)
|
||||
)
|
||||
.alert(
|
||||
"Microphone Access Needed",
|
||||
isPresented: Binding(
|
||||
get: { controller.microphoneAccessDenied },
|
||||
set: { controller.microphoneAccessDenied = $0 }
|
||||
)
|
||||
) {
|
||||
Button("OK", role: .cancel) { }
|
||||
} message: {
|
||||
Text("Live input needs microphone access. Enable it in System Settings › Privacy & "
|
||||
+ "Security › Microphone, then select the input again.")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Toolbar
|
||||
|
||||
/// Top toolbar: mode picker, input-source picker, transport, and CPU meter.
|
||||
private var toolbar: some View {
|
||||
HStack(spacing: DemoRootView.toolbarSpacing) {
|
||||
modePicker
|
||||
Spacer()
|
||||
inputSourcePicker
|
||||
// In Boards mode the pedalboard view (`ShoeGazeView`) supplies its own
|
||||
// Start/Stop, so the board starts only when its own button is pressed. The
|
||||
// other modes have no in-content transport, so show it here for them.
|
||||
if controller.mode != .boards {
|
||||
transportButtons
|
||||
}
|
||||
}
|
||||
.padding(DemoRootView.toolbarPadding)
|
||||
}
|
||||
|
||||
/// Segmented picker for `DemoMode`.
|
||||
///
|
||||
/// The selection binding's setter delegates to `controller.select(_:)` rather than
|
||||
/// writing a `@State` directly, so the controller handles the mode switch and rebuild.
|
||||
private var modePicker: some View {
|
||||
let modeBinding: Binding<DemoMode> = Binding(
|
||||
get: { controller.mode },
|
||||
set: { controller.select($0) }
|
||||
)
|
||||
return Picker("Mode", selection: modeBinding) {
|
||||
ForEach(DemoMode.allCases) { demoMode in
|
||||
Text(demoMode.title).tag(demoMode)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.frame(maxWidth: 380)
|
||||
.foregroundStyle(Color.white)
|
||||
}
|
||||
|
||||
/// A `Binding<Int>` mapping the input Picker tag to `InputSource`.
|
||||
///
|
||||
/// Tag `-1` = `.testLoop`; tags `0 ..< numInputChannels` = `.liveInput(channel:)`.
|
||||
/// Setting the binding calls `controller.setInputSource(_:)`.
|
||||
private var inputSourceBinding: Binding<Int> {
|
||||
Binding(
|
||||
get: {
|
||||
switch controller.inputSource {
|
||||
case .testLoop:
|
||||
return -1
|
||||
case .liveInput(let channel):
|
||||
return channel
|
||||
}
|
||||
},
|
||||
set: { newValue in
|
||||
if newValue == -1 {
|
||||
controller.setInputSource(.testLoop)
|
||||
} else {
|
||||
controller.setInputSource(.liveInput(channel: newValue))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/// Picker listing "Test Loop" and one option per available hardware input channel.
|
||||
///
|
||||
/// When `engine.numInputChannels == 0` only "Test Loop" is shown; the live options
|
||||
/// are omitted so the picker never offers channels that do not exist.
|
||||
private var inputSourcePicker: some View {
|
||||
HStack(spacing: DemoRootView.toolbarSpacing) {
|
||||
Text("Input:")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(Color.white.opacity(0.65))
|
||||
Picker("Input", selection: inputSourceBinding) {
|
||||
Text("Test Loop").tag(-1)
|
||||
ForEach(Array(0..<max(0, controller.engine.numInputChannels)), id: \.self) { channel in
|
||||
Text("In \(channel)").tag(channel)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.menu)
|
||||
.foregroundStyle(Color.white)
|
||||
}
|
||||
}
|
||||
|
||||
/// Engine configuration + transport (sample rate, ins/outs, Start/Stop, mismatch alert).
|
||||
private var transportButtons: some View {
|
||||
EngineConfigView(
|
||||
shoeGaze: controller.shoeGaze,
|
||||
hardwareSampleRate: hardwareSampleRate,
|
||||
applyConfig: { rate, inputs, outputs in
|
||||
try controller.reconfigure(
|
||||
sampleRate: rate,
|
||||
inputChannels: inputs,
|
||||
outputChannels: outputs
|
||||
)
|
||||
},
|
||||
onConfigApplied: { transportTick.toggle() }
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Content area
|
||||
|
||||
/// The main content area switches view based on the active mode.
|
||||
@ViewBuilder
|
||||
private var contentArea: some View {
|
||||
switch controller.mode {
|
||||
case .boards:
|
||||
ShoeGazeView(shoeGaze: controller.shoeGaze, hardwareSampleRate: hardwareSampleRate)
|
||||
|
||||
case .editor:
|
||||
editorContent
|
||||
|
||||
case .parallel:
|
||||
parallelContent
|
||||
|
||||
case .router:
|
||||
routerContent
|
||||
|
||||
case .stereo:
|
||||
stereoContent
|
||||
}
|
||||
}
|
||||
|
||||
/// `.editor` content: `BoardEditorView` bound to the first board in the session.
|
||||
///
|
||||
/// Shows a placeholder when the board list is unexpectedly empty (e.g. if
|
||||
/// `buildEditor()` failed silently).
|
||||
@ViewBuilder
|
||||
private var editorContent: some View {
|
||||
if controller.shoeGaze.boards.isEmpty {
|
||||
Text("No editor board available.")
|
||||
.foregroundStyle(Color.white.opacity(0.55))
|
||||
} else {
|
||||
BoardEditorView(
|
||||
shoeGaze: controller.shoeGaze,
|
||||
boardIndex: 0,
|
||||
versionStore: controller.versionStore
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// `.parallel` content: the full board view (shows pre/post-split pedals) stacked
|
||||
/// above `ParallelSectionView` which exposes the splitter mode picker and branch rows.
|
||||
@ViewBuilder
|
||||
private var parallelContent: some View {
|
||||
if let section: ParallelSection = controller.parallelSection,
|
||||
!controller.shoeGaze.boards.isEmpty {
|
||||
let board: PedalBoard = controller.shoeGaze.boards[0]
|
||||
ScrollView(.vertical, showsIndicators: true) {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
PedalBoardView(board: board)
|
||||
ParallelSectionView(section: section)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("Parallel section unavailable.")
|
||||
.foregroundStyle(Color.white.opacity(0.55))
|
||||
}
|
||||
}
|
||||
|
||||
/// `.stereo` content: the full board view (shows the pre-split pedal) stacked above a
|
||||
/// width badge and `StereoSplitSectionView` (route picker + L/R branch rows).
|
||||
@ViewBuilder
|
||||
private var stereoContent: some View {
|
||||
if let section: StereoSplitSection = controller.stereoSection,
|
||||
let board: PedalBoard = controller.shoeGaze.boards.first {
|
||||
ScrollView(.vertical, showsIndicators: true) {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
HStack(spacing: 10) {
|
||||
PedalBoardView(board: board)
|
||||
StereoWidthBadge(width: board.width)
|
||||
}
|
||||
StereoSplitSectionView(section: section)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("Stereo split unavailable.")
|
||||
.foregroundStyle(Color.white.opacity(0.55))
|
||||
}
|
||||
}
|
||||
|
||||
/// `.router` content: `ChainRouterView` bound to the live `ChainRouter`.
|
||||
@ViewBuilder
|
||||
private var routerContent: some View {
|
||||
if let chainRouter: ChainRouter = controller.router {
|
||||
ScrollView(.vertical, showsIndicators: true) {
|
||||
ChainRouterView(router: chainRouter)
|
||||
}
|
||||
} else {
|
||||
Text("Chain router unavailable.")
|
||||
.foregroundStyle(Color.white.opacity(0.55))
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.music</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>ShoeGazeDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,371 +0,0 @@
|
||||
// ShoeGazeDemoController.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
import Observation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
// MARK: - DemoMode
|
||||
|
||||
/// The active showcase mode displayed in the demo window.
|
||||
///
|
||||
/// Each case corresponds to one full-window showcase of a distinct ShoeGaze feature.
|
||||
/// Switching modes tears down the current audio graph and rebuilds it fresh.
|
||||
enum DemoMode: String, CaseIterable, Identifiable {
|
||||
|
||||
/// Two full boards, each with four pedals (Board 1: Overdrive → Delay → Reverb → Modulation;
|
||||
/// Board 2: Fuzz → Tremolo → Phaser → Compressor).
|
||||
case boards = "Boards"
|
||||
|
||||
/// A single board inside `BoardEditorView` with preset version snapshots pre-populated.
|
||||
case editor = "Editor"
|
||||
|
||||
/// A single board with a ``ParallelSection`` (Overdrive → split → Delay|Fuzz → merge → Reverb).
|
||||
case parallel = "Parallel"
|
||||
|
||||
/// A ``ChainRouter`` that splits one input across two independent boards (A: Overdrive + Delay;
|
||||
/// B: Fuzz + Reverb) and recombines them through a shared master stage.
|
||||
case router = "Router"
|
||||
|
||||
/// A board with a ``StereoSplitSection`` (Overdrive → splitStereo(Delay | PingPong) →
|
||||
/// collectStereo) showcasing the four ``StereoRoute`` modes and stereo output.
|
||||
case stereo = "Stereo"
|
||||
|
||||
var id: String { rawValue }
|
||||
|
||||
/// Short human-readable title used in the mode picker.
|
||||
var title: String {
|
||||
switch self {
|
||||
case .boards: return "Boards"
|
||||
case .editor: return "Editor"
|
||||
case .parallel: return "Parallel"
|
||||
case .router: return "Router"
|
||||
case .stereo: return "Stereo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ShoeGazeDemoController
|
||||
|
||||
/// Main-actor observable controller that owns the engine and active ShoeGaze session.
|
||||
///
|
||||
/// A single `ShoeGaze` instance plus optional `router` / `parallelSection` hold the
|
||||
/// current showcase. Switching modes via ``select(_:)`` or changing the input source via
|
||||
/// ``setInputSource(_:)`` calls ``rebuild()`` which:
|
||||
///
|
||||
/// 1. Stops the engine if it is running.
|
||||
/// 2. Calls `shoeGaze.teardown()` to remove all nodes and release all buses.
|
||||
/// 3. Replaces `shoeGaze` with a fresh instance.
|
||||
/// 4. Builds the new mode-specific graph.
|
||||
/// 5. Restarts the engine if it was running before the rebuild.
|
||||
///
|
||||
/// This guarantees the engine never holds stale references across mode switches.
|
||||
@MainActor
|
||||
@Observable
|
||||
final class ShoeGazeDemoController {
|
||||
|
||||
// MARK: - Public state
|
||||
|
||||
/// The synthesis engine. Callers must not call `engine.start()` or `engine.stop()`
|
||||
/// directly — use ``start()`` and ``stop()`` so `isRunning` stays consistent.
|
||||
let engine: SynthesisEngine
|
||||
|
||||
/// The active ShoeGaze session. Replaced on every ``rebuild()`` call.
|
||||
private(set) var shoeGaze: ShoeGaze
|
||||
|
||||
/// Non-nil only in `.router` mode, after ``buildRouter()`` succeeds.
|
||||
private(set) var router: ChainRouter?
|
||||
|
||||
/// Non-nil only in `.parallel` mode, after ``buildParallel()`` succeeds.
|
||||
private(set) var parallelSection: ParallelSection?
|
||||
|
||||
/// Non-nil only in `.stereo` mode, after ``buildStereo()`` succeeds.
|
||||
private(set) var stereoSection: StereoSplitSection?
|
||||
|
||||
/// Stores named board snapshots for the `.editor` showcase.
|
||||
let versionStore: BoardVersionStore = BoardVersionStore()
|
||||
|
||||
/// Currently selected showcase mode.
|
||||
private(set) var mode: DemoMode = .boards
|
||||
|
||||
/// Current input source policy.
|
||||
private(set) var inputSource: InputSource = .testLoop
|
||||
|
||||
/// `true` while the engine is running. Derived from the engine (the single source
|
||||
/// of truth) so it stays correct regardless of which control starts/stops it.
|
||||
var isRunning: Bool { engine.isRunning }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a controller, builds the default `.boards` showcase, and does NOT start the engine.
|
||||
///
|
||||
/// - Parameter engine: A pre-configured `SynthesisEngine` owned by the caller. The
|
||||
/// engine must not be running when this initialiser is called.
|
||||
init(engine: SynthesisEngine) {
|
||||
self.engine = engine
|
||||
self.shoeGaze = ShoeGaze(engine: engine, inputSource: .testLoop)
|
||||
buildBoards()
|
||||
}
|
||||
|
||||
// MARK: - Mode selection
|
||||
|
||||
/// Switches to the given mode if different from the current one, triggering a full rebuild.
|
||||
///
|
||||
/// - Parameter newMode: The showcase to activate.
|
||||
func select(_ newMode: DemoMode) {
|
||||
guard newMode != mode else { return }
|
||||
mode = newMode
|
||||
rebuild()
|
||||
}
|
||||
|
||||
// MARK: - Input source
|
||||
|
||||
/// Changes the input source policy and triggers a full rebuild.
|
||||
///
|
||||
/// Live input requires microphone authorisation first — without it macOS feeds the AUHAL input
|
||||
/// silent zeros. The request is asynchronous, so `.liveInput` is applied only once the grant
|
||||
/// resolves; a denial falls back to the test loop.
|
||||
///
|
||||
/// - Parameter source: `.testLoop` for the built-in test signal or `.liveInput(channel:)`
|
||||
/// for hardware microphone/instrument input on the given channel.
|
||||
func setInputSource(_ source: InputSource) {
|
||||
guard case .liveInput = source else {
|
||||
applyInputSource(source)
|
||||
return
|
||||
}
|
||||
MicrophonePermission.request { [weak self] granted in
|
||||
if !granted { self?.microphoneAccessDenied = true }
|
||||
self?.applyInputSource(granted ? source : .testLoop)
|
||||
}
|
||||
}
|
||||
|
||||
/// Set when live input is requested but microphone access is denied/restricted. The UI observes
|
||||
/// this and presents an alert, then clears it.
|
||||
var microphoneAccessDenied: Bool = false
|
||||
|
||||
/// Applies an input-source change and triggers a full rebuild.
|
||||
private func applyInputSource(_ source: InputSource) {
|
||||
inputSource = source
|
||||
rebuild()
|
||||
}
|
||||
|
||||
// MARK: - Transport
|
||||
|
||||
/// Starts the engine. Updates ``isRunning`` on success; prints on failure.
|
||||
func start() {
|
||||
do {
|
||||
try engine.start()
|
||||
} catch {
|
||||
print("[ShoeGazeDemoController] engine.start() failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// Stops the engine and updates ``isRunning``.
|
||||
func stop() {
|
||||
engine.stop()
|
||||
}
|
||||
|
||||
/// Toggles audio output on/off (mute). Muting silences output by stopping the engine;
|
||||
/// unmuting restarts it. `isRunning == false` is the "muted" (silent) state.
|
||||
func toggleMute() {
|
||||
if isRunning {
|
||||
stop()
|
||||
} else {
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Engine reconfiguration
|
||||
|
||||
/// Applies new engine settings (while stopped) and rebuilds the current mode so the showcase
|
||||
/// is reconstructed at the new sample rate / channel counts. Used by the engine-config UI.
|
||||
///
|
||||
/// Tears the session down BEFORE reconfiguring — changing channel counts re-partitions the bus
|
||||
/// allocator, which would invalidate rig buses still allocated under the old layout.
|
||||
///
|
||||
/// - Throws: `SynthesisEngineConfigError` if the engine is running or a value is invalid.
|
||||
func reconfigure(sampleRate: Double, inputChannels: Int, outputChannels: Int) throws {
|
||||
let wasRunning: Bool = isRunning
|
||||
if wasRunning { stop() }
|
||||
|
||||
tearDownSession()
|
||||
try engine.setSampleRate(sampleRate)
|
||||
try engine.setNumOutputChannels(outputChannels)
|
||||
try engine.setNumInputChannels(inputChannels)
|
||||
// A live-input source past the new channel count would make rebuild fail; fall back.
|
||||
if case .liveInput(let channel) = inputSource, channel >= inputChannels {
|
||||
inputSource = .testLoop
|
||||
}
|
||||
buildSession()
|
||||
// `buildSession()` creates a fresh `ShoeGaze`, whose `init` installs the scope tap for the
|
||||
// new channel layout — no explicit `installScopeTap()` needed here.
|
||||
|
||||
if wasRunning { start() }
|
||||
}
|
||||
|
||||
// MARK: - Rebuild
|
||||
|
||||
/// Tears down the current session and rebuilds the active mode.
|
||||
///
|
||||
/// The engine is stopped before teardown and restarted afterward if it was running,
|
||||
/// satisfying the remove-before-release invariant documented on `ShoeGaze.teardown()`.
|
||||
private func rebuild() {
|
||||
let wasRunning: Bool = isRunning
|
||||
if wasRunning { stop() }
|
||||
tearDownSession()
|
||||
buildSession()
|
||||
if wasRunning { start() }
|
||||
}
|
||||
|
||||
/// Removes the current session's nodes and clears split/router references.
|
||||
private func tearDownSession() {
|
||||
shoeGaze.teardown()
|
||||
router = nil
|
||||
parallelSection = nil
|
||||
stereoSection = nil
|
||||
}
|
||||
|
||||
/// Creates a fresh session and builds the active mode's graph.
|
||||
private func buildSession() {
|
||||
shoeGaze = ShoeGaze(engine: engine, inputSource: inputSource)
|
||||
switch mode {
|
||||
case .boards: buildBoards()
|
||||
case .editor: buildEditor()
|
||||
case .parallel: buildParallel()
|
||||
case .router: buildRouter()
|
||||
case .stereo: buildStereo()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Mode builders
|
||||
|
||||
/// `.boards` — three full boards covering all twelve pedal types.
|
||||
///
|
||||
/// Board 1: Overdrive → Delay → Reverb → Modulation
|
||||
/// Board 2: Fuzz → Tremolo → Phaser → Compressor
|
||||
/// Board 3: Mutant → Auto-Wah → Feedback Delay → Multi-Tap Delay
|
||||
private func buildBoards() {
|
||||
do {
|
||||
let board1: PedalBoard = try shoeGaze.addBoard()
|
||||
board1.label = "Board 1"
|
||||
try board1.add(OverdrivePedal())
|
||||
try board1.add(DelayPedal())
|
||||
try board1.add(ReverbPedal())
|
||||
try board1.add(ModulationPedal())
|
||||
try shoeGaze.finalizeBoard(board1)
|
||||
|
||||
let board2: PedalBoard = try shoeGaze.addBoard()
|
||||
board2.label = "Board 2"
|
||||
try board2.add(FuzzPedal())
|
||||
try board2.add(TremoloPedal())
|
||||
try board2.add(PhaserPedal())
|
||||
try board2.add(CompressorPedal())
|
||||
try shoeGaze.finalizeBoard(board2)
|
||||
|
||||
let board3: PedalBoard = try shoeGaze.addBoard()
|
||||
board3.label = "Board 3"
|
||||
try board3.add(MutantPedal())
|
||||
try board3.add(AutoWahPedal())
|
||||
try board3.add(FeedbackDelayPedal())
|
||||
try board3.add(MultiTapDelayPedal())
|
||||
try shoeGaze.finalizeBoard(board3)
|
||||
} catch {
|
||||
print("[ShoeGazeDemoController] buildBoards failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// `.editor` — one board inside `BoardEditorView` with two pre-captured versions.
|
||||
///
|
||||
/// The pre-populated version entries ("Crunch" and "Clean Shimmer") ensure the
|
||||
/// Versions menu is not empty when the showcase first appears.
|
||||
private func buildEditor() {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Editor Board"
|
||||
try board.add(OverdrivePedal())
|
||||
try board.add(FuzzPedal())
|
||||
try board.add(DelayPedal())
|
||||
try board.add(ReverbPedal())
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
|
||||
// Pre-populate two named snapshots so the Versions menu is immediately useful.
|
||||
versionStore.capture(board, name: "Crunch")
|
||||
versionStore.capture(board, name: "Clean Shimmer")
|
||||
} catch {
|
||||
print("[ShoeGazeDemoController] buildEditor failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// `.parallel` — Overdrive → split(Delay | Fuzz) → merge → Reverb.
|
||||
///
|
||||
/// Stores the `ParallelSection` in `parallelSection` so `DemoRootView` can display
|
||||
/// `ParallelSectionView`.
|
||||
private func buildParallel() {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Parallel Board"
|
||||
try board.add(OverdrivePedal())
|
||||
|
||||
let section: ParallelSection = try board.split()
|
||||
try section.branchA.add(DelayPedal())
|
||||
try section.branchB.add(FuzzPedal())
|
||||
try board.merge(section)
|
||||
|
||||
try board.add(ReverbPedal())
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
|
||||
parallelSection = section
|
||||
} catch {
|
||||
print("[ShoeGazeDemoController] buildParallel failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// `.router` — ChainRouter with two independent chains: A (Overdrive + Delay),
|
||||
/// B (Fuzz + Reverb), merged through a shared master stage.
|
||||
///
|
||||
/// Stores the `ChainRouter` in `router` so `DemoRootView` can display
|
||||
/// `ChainRouterView`.
|
||||
private func buildRouter() {
|
||||
do {
|
||||
let r: ChainRouter = try shoeGaze.makeChainRouter()
|
||||
try r.addToA(OverdrivePedal())
|
||||
try r.addToA(DelayPedal())
|
||||
try r.addToB(FuzzPedal())
|
||||
try r.addToB(ReverbPedal())
|
||||
try r.finalize()
|
||||
router = r
|
||||
} catch {
|
||||
print("[ShoeGazeDemoController] buildRouter failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// `.stereo` — Overdrive → splitStereo(left: Delay | right: Ping-Pong) → collectStereo.
|
||||
///
|
||||
/// Demonstrates the stereo split mechanism: a mono signal fanned into two independently
|
||||
/// authored chains that become the left and right output channels, with the four
|
||||
/// ``StereoRoute`` modes (stereo / left / right / bypass) selectable live. Stores the
|
||||
/// `StereoSplitSection` so `DemoRootView` can display `StereoSplitSectionView`.
|
||||
private func buildStereo() {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Stereo Board"
|
||||
try board.add(OverdrivePedal())
|
||||
|
||||
let section: StereoSplitSection = try board.splitStereo()
|
||||
try section.left.add(DelayPedal())
|
||||
try section.right.add(PingPongDelayPedal())
|
||||
try board.collectStereo(section)
|
||||
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
stereoSection = section
|
||||
} catch {
|
||||
print("[ShoeGazeDemoController] buildStereo failed: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
// main.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
|
||||
// Program entry runs on the main thread; assert main-actor isolation for the
|
||||
// AppKit bootstrap rather than hopping asynchronously. `AppDelegate.init` builds
|
||||
// `@MainActor` synthesizers and UI.
|
||||
MainActor.assumeIsolated {
|
||||
let app: NSApplication = NSApplication.shared
|
||||
let delegate: AppDelegate = AppDelegate()
|
||||
app.setActivationPolicy(.regular)
|
||||
app.delegate = delegate
|
||||
app.activate(ignoringOtherApps: true)
|
||||
app.run()
|
||||
}
|
||||
#else
|
||||
// The ShoeGaze demo is a macOS AppKit application and has no iOS entry point.
|
||||
print("ShoeGazeDemo runs on macOS only.")
|
||||
#endif
|
||||
@@ -1,387 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 60;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
C3C000000000000000000009 /* ShoeGazeiOSDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */; };
|
||||
C3C00000000000000000000A /* ShoeGazeiOSDemoAppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */; };
|
||||
C3C00000000000000000000B /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001A /* LyrebirdShoeGaze */; };
|
||||
C3C00000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001B /* LyrebirdShoeGazeUI */; };
|
||||
C3C00000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001C /* LyrebirdUI */; };
|
||||
C3C00000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001E /* Lyrebird */; };
|
||||
C3C000000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000030 /* Assets.xcassets */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
C3C000000000000000000004 /* ShoeGazeiOSDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeiOSDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C3C000000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoApp.swift; sourceTree = "<group>"; };
|
||||
C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoAppModel.swift; sourceTree = "<group>"; };
|
||||
C3C000000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
C3C00000000000000000000F /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C3C00000000000000000000B /* LyrebirdShoeGaze in Frameworks */,
|
||||
C3C00000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */,
|
||||
C3C00000000000000000000D /* LyrebirdUI in Frameworks */,
|
||||
C3C00000000000000000001D /* Lyrebird in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
C3C000000000000000000002 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3C000000000000000000005 /* ShoeGazeiOSDemo */,
|
||||
C3C000000000000000000003 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C3C000000000000000000003 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3C000000000000000000004 /* ShoeGazeiOSDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C3C000000000000000000005 /* ShoeGazeiOSDemo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */,
|
||||
C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */,
|
||||
C3C000000000000000000030 /* Assets.xcassets */,
|
||||
C3C000000000000000000006 /* Info.plist */,
|
||||
);
|
||||
path = ShoeGazeiOSDemo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
C3C000000000000000000011 /* ShoeGazeiOSDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C3C000000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeiOSDemo" */;
|
||||
buildPhases = (
|
||||
C3C00000000000000000000E /* Sources */,
|
||||
C3C00000000000000000000F /* Frameworks */,
|
||||
C3C000000000000000000010 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = ShoeGazeiOSDemo;
|
||||
packageProductDependencies = (
|
||||
C3C00000000000000000001A /* LyrebirdShoeGaze */,
|
||||
C3C00000000000000000001B /* LyrebirdShoeGazeUI */,
|
||||
C3C00000000000000000001C /* LyrebirdUI */,
|
||||
C3C00000000000000000001E /* Lyrebird */,
|
||||
);
|
||||
productName = ShoeGazeiOSDemo;
|
||||
productReference = C3C000000000000000000004 /* ShoeGazeiOSDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
C3C000000000000000000001 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1600;
|
||||
LastUpgradeCheck = 2620;
|
||||
TargetAttributes = {
|
||||
C3C000000000000000000011 = {
|
||||
CreatedOnToolsVersion = 16.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = C3C000000000000000000015 /* Build configuration list for PBXProject "ShoeGazeiOSDemo" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = C3C000000000000000000002;
|
||||
packageReferences = (
|
||||
C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */,
|
||||
C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */,
|
||||
);
|
||||
productRefGroup = C3C000000000000000000003 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
C3C000000000000000000011 /* ShoeGazeiOSDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
C3C000000000000000000010 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C3C000000000000000000031 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
C3C00000000000000000000E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C3C000000000000000000009 /* ShoeGazeiOSDemoApp.swift in Sources */,
|
||||
C3C00000000000000000000A /* ShoeGazeiOSDemoAppModel.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C3C000000000000000000013 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeiOSDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = 2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C3C000000000000000000014 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeiOSDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = 2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C3C000000000000000000016 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C3C000000000000000000017 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
C3C000000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeiOSDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C3C000000000000000000013 /* Debug */,
|
||||
C3C000000000000000000014 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C3C000000000000000000015 /* Build configuration list for PBXProject "ShoeGazeiOSDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C3C000000000000000000016 /* Debug */,
|
||||
C3C000000000000000000017 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCLocalSwiftPackageReference section */
|
||||
C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */ = {
|
||||
isa = XCLocalSwiftPackageReference;
|
||||
relativePath = ..;
|
||||
};
|
||||
/* End XCLocalSwiftPackageReference section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 1.2.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
C3C00000000000000000001A /* LyrebirdShoeGaze */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */;
|
||||
productName = LyrebirdShoeGaze;
|
||||
};
|
||||
C3C00000000000000000001B /* LyrebirdShoeGazeUI */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */;
|
||||
productName = LyrebirdShoeGazeUI;
|
||||
};
|
||||
C3C00000000000000000001C /* LyrebirdUI */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||
productName = LyrebirdUI;
|
||||
};
|
||||
C3C00000000000000000001E /* Lyrebird */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||
productName = Lyrebird;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = C3C000000000000000000001 /* Project object */;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/andybest/linenoise-swift",
|
||||
"state" : {
|
||||
"revision" : "afc897c02b030af7333105c4fedcd843a8339238",
|
||||
"version" : "0.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "lyrebird",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||
"version" : "1.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "nimble",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Quick/Nimble.git",
|
||||
"state" : {
|
||||
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
|
||||
"version" : "7.3.4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C3C000000000000000000011"
|
||||
BuildableName = "ShoeGazeiOSDemo.app"
|
||||
BlueprintName = "ShoeGazeiOSDemo"
|
||||
ReferencedContainer = "container:ShoeGazeiOSDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C3C000000000000000000011"
|
||||
BuildableName = "ShoeGazeiOSDemo.app"
|
||||
BlueprintName = "ShoeGazeiOSDemo"
|
||||
ReferencedContainer = "container:ShoeGazeiOSDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C3C000000000000000000011"
|
||||
BuildableName = "ShoeGazeiOSDemo.app"
|
||||
BlueprintName = "ShoeGazeiOSDemo"
|
||||
ReferencedContainer = "container:ShoeGazeiOSDemo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{"filename":"icon_1024.png","idiom":"universal","platform":"ios","size":"1024x1024"}
|
||||
],
|
||||
"info" : {"author":"xcode","version":1}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 402 KiB |
@@ -1 +0,0 @@
|
||||
{ "info" : {"author":"xcode","version":1} }
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>ShoeGazeiOSDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>UILaunchScreen</key>
|
||||
<dict/>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,33 +0,0 @@
|
||||
// ShoeGazeiOSDemoApp.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import LyrebirdShoeGazeUI
|
||||
|
||||
/// iOS entry point for the ShoeGaze in-repo demo.
|
||||
///
|
||||
/// Holds the `ShoeGazeiOSDemoAppModel` as `@State` so it is created once and
|
||||
/// owned for the lifetime of the app. The audio engine is **not** started
|
||||
/// automatically — the user presses Start in the pedalboard (`ShoeGazeView`) to
|
||||
/// begin audio. The engine is stopped when the view disappears.
|
||||
@main
|
||||
struct ShoeGazeiOSDemoApp: App {
|
||||
|
||||
@State private var model: ShoeGazeiOSDemoAppModel = ShoeGazeiOSDemoAppModel()
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
ShoeGazeView(shoeGaze: model.shoeGaze, hardwareSampleRate: { model.hardwareSampleRate })
|
||||
.padding(.horizontal, 12)
|
||||
}
|
||||
.navigationTitle("ShoeGaze")
|
||||
}
|
||||
.onDisappear { model.stop() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
// ShoeGazeiOSDemoAppModel.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import AVFoundation
|
||||
import Observation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
/// Observable model that owns the `SynthesisEngine` and `ShoeGaze` session for
|
||||
/// the ShoeGaze iOS demo.
|
||||
///
|
||||
/// The engine is not started automatically — the pedalboard's Start button
|
||||
/// (`ShoeGazeView`) drives `engine.start()`. `stop()` is called from `.onDisappear`
|
||||
/// to release audio resources when the view goes away.
|
||||
///
|
||||
/// `AVAudioSession` is activated at init so the hardware sample rate is known
|
||||
/// before the engine is constructed — iOS devices typically lock to 48 000 Hz
|
||||
/// regardless of the preferred rate, and querying the session after activation
|
||||
/// avoids pitch and timing errors.
|
||||
///
|
||||
/// The default board (Overdrive → Delay → Reverb → Modulation) uses `.testLoop`
|
||||
/// as the input source, so no microphone permission is required to run the demo.
|
||||
/// Switch to `.liveInput(channel: 0)` and set `numInputChannels: 1` in the
|
||||
/// engine init to route hardware microphone or instrument input through the board.
|
||||
@Observable
|
||||
@MainActor
|
||||
final class ShoeGazeiOSDemoAppModel {
|
||||
|
||||
// MARK: - Engine configuration constants
|
||||
|
||||
private static let blockSize: Int = 512
|
||||
private static let outputChannels: Int = 2
|
||||
private static let numAudioBuses: Int = 256
|
||||
|
||||
// MARK: - Owned objects
|
||||
|
||||
/// The active ShoeGaze pedalboard session.
|
||||
private(set) var shoeGaze: ShoeGaze
|
||||
|
||||
private let engine: SynthesisEngine
|
||||
private let iosDriver: iOSAudioDriver
|
||||
|
||||
/// The sample rate the audio session actually committed to (for the config mismatch warning).
|
||||
var hardwareSampleRate: Double? { iosDriver.sessionSampleRate }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
init() {
|
||||
// Activate the session before querying `sampleRate` so the hardware rate
|
||||
// is reported correctly (iOS locks to 48 000 Hz on most devices).
|
||||
let session: AVAudioSession = AVAudioSession.sharedInstance()
|
||||
try? session.setCategory(.playAndRecord,
|
||||
mode: .default,
|
||||
options: [.defaultToSpeaker, .allowBluetoothHFP])
|
||||
try? session.setActive(true)
|
||||
let sampleRate: Double = session.sampleRate
|
||||
|
||||
let driver: iOSAudioDriver = iOSAudioDriver()
|
||||
let eng: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: ShoeGazeiOSDemoAppModel.blockSize,
|
||||
sampleRate: sampleRate,
|
||||
numOutputChannels: ShoeGazeiOSDemoAppModel.outputChannels,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: ShoeGazeiOSDemoAppModel.numAudioBuses,
|
||||
driver: driver
|
||||
)
|
||||
self.iosDriver = driver
|
||||
self.engine = eng
|
||||
self.shoeGaze = ShoeGaze(engine: eng)
|
||||
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Demo Board"
|
||||
try board.add(OverdrivePedal())
|
||||
try board.add(DelayPedal())
|
||||
try board.add(ReverbPedal())
|
||||
try board.add(ModulationPedal())
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
} catch {
|
||||
print("[ShoeGazeiOSDemo] board build failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Transport
|
||||
|
||||
/// Starts the audio engine. Not called automatically — the pedalboard's Start
|
||||
/// button drives `engine.start()`; this is here for callers that want to start it.
|
||||
func start() {
|
||||
do {
|
||||
try engine.start()
|
||||
} catch {
|
||||
print("[ShoeGazeiOSDemo] engine.start() failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// Stops the audio engine. Call from `.onDisappear`.
|
||||
func stop() {
|
||||
engine.stop()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"originHash" : "b8327204b102b429067129b94b6ba77dcfa78570af3b9d11cae4d7eb252e388c",
|
||||
"originHash" : "6094cf70541e0593db7264ad9c75576ce239a5a5885ca4b783b5444793b6fee5",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||
"version" : "1.2.0"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
// double-registration. The dynamic-product dance used by `LiveCompile/` is only
|
||||
// required for runtime dylib hot-swap, which ShoeGaze does not do.
|
||||
//
|
||||
// The demo app lives at Demo/ShoeGazeDemo.xcodeproj — open ShoeGaze.xcworkspace
|
||||
// in Xcode and run the ShoeGazeDemo scheme to build it.
|
||||
// The apps live at Demo/ShoeGazeBuilder.xcodeproj (macOS) and
|
||||
// Demo/ShoeGazeBuilderiOS.xcodeproj (iPad) — open ShoeGaze.xcworkspace in Xcode
|
||||
// and run the matching scheme to build them.
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
@@ -23,14 +24,16 @@ let package = Package(
|
||||
.library(name: "LyrebirdShoeGazeUI", targets: ["LyrebirdShoeGazeUI"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.2.0"),
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "2.3.0"),
|
||||
],
|
||||
targets: [
|
||||
// The core target depends on LyrebirdUI as well as the synthesis core:
|
||||
// pedals expose their knobs as `@UIParam`, whose projected `UIParamNode`
|
||||
// (the type `ParameterKnob` binds to) lives in LyrebirdUI. Importing
|
||||
// LyrebirdUI here does not pull SwiftUI into ShoeGaze's own sources —
|
||||
// it only makes the `@UIParam` wrapper and `UIParamNode` visible.
|
||||
// Both targets depend on the core `Lyrebird` product AND `LyrebirdUI`.
|
||||
// Pedals expose their knobs as `@UIParam`, whose projected `UIParamNode`
|
||||
// lives in the core `LyrebirdSynth` module (the `Lyrebird` product) as of
|
||||
// Lyrebird 2.0 — `LyrebirdUI` no longer re-exports it — so any file using
|
||||
// `@UIParam` / `UIParamNode` needs `import LyrebirdSynth`, which requires
|
||||
// the `Lyrebird` product as a direct dependency. Importing these does not
|
||||
// pull SwiftUI into ShoeGaze's own core sources.
|
||||
.target(
|
||||
name: "LyrebirdShoeGaze",
|
||||
dependencies: [
|
||||
@@ -43,6 +46,7 @@ let package = Package(
|
||||
name: "LyrebirdShoeGazeUI",
|
||||
dependencies: [
|
||||
"LyrebirdShoeGaze",
|
||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
||||
.product(name: "LyrebirdUI", package: "Lyrebird"),
|
||||
],
|
||||
path: "Sources/LyrebirdShoeGazeUI"
|
||||
@@ -51,6 +55,7 @@ let package = Package(
|
||||
name: "LyrebirdShoeGazeTests",
|
||||
dependencies: [
|
||||
"LyrebirdShoeGaze",
|
||||
"LyrebirdShoeGazeUI",
|
||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
||||
.product(name: "LyrebirdUI", package: "Lyrebird"),
|
||||
],
|
||||
|
||||
@@ -11,19 +11,31 @@ signal (no hardware needed) or on live guitar through an audio input.
|
||||
|
||||
## Features
|
||||
|
||||
- **32 modeled pedals** across gain, dynamics, EQ/filter, modulation, pitch, delay, reverb, and
|
||||
texture — see the catalog below.
|
||||
- **67 modeled pedals** — effects across gain, dynamics, EQ/filter, modulation, pitch, delay,
|
||||
reverb, and texture, plus **26 tube-amp models** with their own tone stacks and a deep
|
||||
speaker-cabinet / microphone section. All original DSP built on the Lyrebird engine — no
|
||||
third-party captures or IR packs. See the catalog below.
|
||||
- **Starter rigs** — a library of ready-to-play rigs ships with the app, grouped by style
|
||||
(Shoegaze Walls, Dreampop, Classic, Ambient, Experimental) and reachable from a **Mine /
|
||||
Starters** toggle in the rig sidebar.
|
||||
- **Multi-board rigs** — build several boards and a board-mixer bar to **Solo** one (amp-channel
|
||||
style) or **Blend** any subset, each with its own level and a click-free crossfade.
|
||||
style) or **Blend** any subset, each with its own level and a click-free crossfade, plus a
|
||||
rig-wide **output volume and mute** on top.
|
||||
- **MIDI foot-controller support** — map footswitches (Program Change) to bypass/mute/solo
|
||||
toggles, and expression pedals (Control Change) to any knob, board level, or the rig-wide
|
||||
volume, with per-binding invert for crossfades. MIDI Learn, one binding per rig.
|
||||
- **Signal-flow editor** — drag pedals in from the palette; reorder, split into parallel or
|
||||
stereo lanes, and merge back to mono.
|
||||
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar; synced across
|
||||
your devices and both apps via iCloud.
|
||||
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar (your own rigs
|
||||
and the shipped starters on separate tabs); synced across your devices and both apps via iCloud.
|
||||
Switching rigs keeps your current input, and saving over a starter rig asks first.
|
||||
- **Sharing** — send a rig or a saved board to anyone as a `.shoegaze` file via the system share
|
||||
sheet (AirDrop, Mail, Messages, Files); export/import the whole library the same way.
|
||||
- **Recording** — capture your output to timestamped files.
|
||||
- **Test signal or live input** — a built-in arpeggiated test loop (shared across all boards so
|
||||
they stay phase-locked) or a hardware input channel.
|
||||
- **In-app Help** — setup, rigs/boards, saving, iCloud, and MIDI control, from the macOS Help
|
||||
menu or an iOS help button.
|
||||
- **SwiftUI views** — a complete stompbox UI (`LyrebirdShoeGazeUI`) or just the headless
|
||||
framework (`LyrebirdShoeGaze`) to drive your own interface.
|
||||
|
||||
@@ -31,14 +43,16 @@ signal (no hardware needed) or on live guitar through an audio input.
|
||||
|
||||
| Category | Pedals |
|
||||
|---|---|
|
||||
| Gain | Overdrive, Distortion, Fuzz |
|
||||
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate |
|
||||
| EQ & filter | Graphic EQ, Auto-Wah, Mutant |
|
||||
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Rotary, Ring Modulator |
|
||||
| Pitch | Bass Octaver, Octave Splitter, Harmonizer |
|
||||
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay |
|
||||
| Reverb | Reverb, Shimmer Reverb |
|
||||
| Texture | Diffuser, Bitcrusher, Granulator, Auto Granulator |
|
||||
| Gain | Overdrive, Distortion, Fuzz, Sustain Fuzz |
|
||||
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate, Volume |
|
||||
| EQ & filter | Graphic EQ, Auto-Wah, Wah, Mutant |
|
||||
| Modulation | Tremolo, Phaser, Script Phaser, Modulation, Chorus, Flanger, Vibrato, Vibe, Rotary, Ring Modulator |
|
||||
| Pitch | Bass Octaver, Octave Splitter, Harmonizer, Whammy, Poly Octave |
|
||||
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay, DL4 |
|
||||
| Reverb | Reverb, Shimmer Reverb, Plate Reverb, Room Reverb, Spring Reverb, Reverse Reverb, Granular Reverb, FreezVerb, TunedVerb |
|
||||
| Texture | Diffuser, Bitcrusher, Granulator, Auto Granulator, Karplus Resonator, Looper, Tape Looper |
|
||||
| Amp Model | Fullerton Reverb / Deluxe / Ivy League / Drive, California, Jazz Clean, British / Plexi / JTM / Bluesbreaker / Master / Dual, Chime / Chime Top Boost / 15 / Normal / Baby, Boutique Lead / OD, Cali Hi-Gain, Modern High-Gain, Command, Citrus, Sixties Combo, Magna Vibrato, Anaheim |
|
||||
| Cabinet | Cabinet (speaker-voice + microphone modeling) |
|
||||
|
||||
Every pedal exposes its parameters as knobs/switches and round-trips through the rig save format.
|
||||
|
||||
@@ -46,7 +60,7 @@ Every pedal exposes its parameters as knobs/switches and round-trips through the
|
||||
|
||||
- macOS 15+ / iPadOS 18+ (iPad, landscape)
|
||||
- Swift 6.0 toolchain / Xcode 16+
|
||||
- [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird) 1.2.0+
|
||||
- [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird) 1.7.0+
|
||||
|
||||
## Packages
|
||||
|
||||
@@ -99,12 +113,11 @@ struct ContentView: View {
|
||||
}
|
||||
```
|
||||
|
||||
## Demo apps
|
||||
## Apps
|
||||
|
||||
Open `ShoeGaze.xcworkspace` in Xcode and run a scheme from `Demo/`:
|
||||
|
||||
- **ShoeGazeBuilder** (macOS) / **ShoeGazeBuilderiOS** (iPad) — the full palette + board builder.
|
||||
- **ShoeGazeDemo** / **ShoeGazeiOSDemo** — a minimal player view.
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
||||
@@ -1,4 +1,232 @@
|
||||
# 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
|
||||
|
||||
A small fix for the Mutant envelope filter's control panel.
|
||||
|
||||
### Fixed
|
||||
- **Mutant switch captions no longer wrap.** Its three segmented switches (Direction / Mode /
|
||||
Range) were cramped into a single-width pedal, wrapping "Down" to "Do wn". Mutant is now
|
||||
double-width — like the Cabinet and amp pedals — so the captions fit.
|
||||
|
||||
## ShoeGaze 3.1.0
|
||||
|
||||
Starter rigs, two new pedals, and a deeper envelope filter — plus smoother rig switching.
|
||||
|
||||
### Highlights
|
||||
- **Starter rigs** — a library of ready-to-play rigs ships with the app, grouped by style
|
||||
(Shoegaze Walls, Dreampop, Classic, Ambient, Experimental) behind a **Mine / Starters** toggle
|
||||
in the rig sidebar. Includes a two-board clean/effects split. **Restore Starter Rigs** reinstalls
|
||||
them any time.
|
||||
- **Vibe** — a photocell "vibe" (four staggered all-pass stages swept by one LFO) with Chorus and
|
||||
Vibrato modes.
|
||||
- **Sustain Fuzz** — a mid-scooped, high-sustain fuzz, distinct from the brighter single-stage Fuzz.
|
||||
- **A deeper Mutant envelope filter** — a **Range** switch (Lo / Hi) that shifts the whole sweep
|
||||
band like the original Mu-Tron III, plus **Sweep**, **Attack**, and **Release** in the advanced
|
||||
pop-over.
|
||||
- **Rig switching keeps your input** — your live guitar stays selected across a rig change instead
|
||||
of snapping back to the test loop.
|
||||
|
||||
### Fixed
|
||||
- No more spurious "Save changes?" prompt when switching between rigs.
|
||||
- Shimmer Reverb no longer self-oscillates into a screech at its defaults.
|
||||
- Saving over a starter rig asks first (Overwrite / Save as New Rig / Cancel).
|
||||
- Multi-board signal-router rigs now save and load.
|
||||
|
||||
## ShoeGaze 3.0.0
|
||||
|
||||
The big one: ShoeGaze becomes an amp-modeling rig — a full lineup of tube-amp voices plus a deep
|
||||
speaker-cabinet and microphone section, all original DSP built from the Lyrebird engine with no
|
||||
third-party captures or IR packs.
|
||||
|
||||
### Highlights
|
||||
- **26 amp-model pedals** in their own **Amp Model** palette category — Fullerton blackface combos,
|
||||
California and Jazz Clean cleans, British stack / combo voices, the Chime top-boost family,
|
||||
Boutique and high-gain amps, and character amps (Command, Citrus, Sixties Combo, Magna Vibrato,
|
||||
Anaheim). Each has its own tone stack, a selectable speaker cabinet, and a real master volume that
|
||||
drives the power-amp stage.
|
||||
- **Speaker-cabinet + microphone section** on the Cabinet pedal — eight speaker voicings, mic
|
||||
modeling (Dynamic / Ribbon / Condenser), placement and proximity, and a dual-mic blend.
|
||||
- **Power-amp feel controls** — Sag, Bias, and Bias X in an advanced pop-over — and analog-style
|
||||
soft limiting, so a driven amp compresses toward its ceiling instead of clipping harshly.
|
||||
- **Gain and Drive read 1–11** with a musical taper.
|
||||
|
||||
### Fixed
|
||||
- Noise Gate no longer pops as a note decays.
|
||||
|
||||
## ShoeGaze 2.1.3
|
||||
|
||||
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output — even
|
||||
with "Mute while tuning" on — until you played a steady note.
|
||||
|
||||
### Fixed
|
||||
- **Tuner no longer leaks into the output.** The pitch-detection stage was written to an
|
||||
audio output bus instead of its internal analysis bus, so the tracked frequency was
|
||||
summed onto an output channel — bypassing the rig mute and crackling while the pitch was
|
||||
unstable (it stopped once a note locked). The tuner now writes only to its analysis bus.
|
||||
|
||||
## ShoeGaze 2.1.1
|
||||
|
||||
A quieter, more predictable startup. The signal feeding the pedals now has its own mute
|
||||
that arms every time you start the engine, new rigs open listening to your instrument,
|
||||
and your input and I/O settings travel with the rig instead of a local-only setting.
|
||||
|
||||
### Highlights
|
||||
- **Input mute** — a hard kill-switch on the incoming guitar / mic signal, separate from
|
||||
the rig-output mute. Arms automatically on every Start (silent until you're ready),
|
||||
sits by the Start/Stop transport with a pulsing red glow while active, and is
|
||||
MIDI-mappable like Rig Mute. A muted input is exactly silent from the first sample.
|
||||
- **Opens on In 0** — new rigs listen to live input instead of the test-loop phrase.
|
||||
- **Input & I/O persist with the rig** — the input selection and engine input/output
|
||||
channel counts are stored in the rig (and iCloud) and reapplied on launch, so a
|
||||
multi-channel setup and a chosen input survive a restart. Replaces the old local-only
|
||||
input setting.
|
||||
- **Tidier transport** — the docked macOS Bypass / Mute / Input toggles are icons so the
|
||||
row no longer crowds the rate and channel controls.
|
||||
|
||||
### Compatibility
|
||||
Additive: rigs saved before this release load unchanged, and 2.1.1 rigs still open in
|
||||
older builds (input-mute state isn't persisted; the extra I/O fields are ignored there).
|
||||
|
||||
## ShoeGaze 2.1.0
|
||||
|
||||
Tempo comes to the pedals. Delay times and LFO rates can lock to note divisions of the
|
||||
live tempo — shown with real music-notation glyphs and following the tempo as it
|
||||
changes — plus a directly-editable BPM, longer delays, and per-control MIDI/key mapping
|
||||
badges on every pedal.
|
||||
|
||||
### Highlights
|
||||
- **Tempo-synced parameters** — lock a delay time or a modulation rate to a note value
|
||||
(whole → sixteenth, dotted, triplet); it follows tap tempo, the stepper, the BPM
|
||||
field, and MIDI. Delay, Feedback Delay, Ping-Pong, Reverse, and Multi-Tap (per tap);
|
||||
Tremolo, Vibrato, Chorus, Flanger, Phaser, Modulation.
|
||||
- **Notation glyphs** — the picker draws real note glyphs (augmentation dot for dotted
|
||||
values, a bracketed "3" over triplets) instead of text.
|
||||
- **Editable BPM** — type a tempo directly (integer, 30–300); the stepper and tap still
|
||||
work, and synced pedals follow immediately.
|
||||
- **Longer delays** — maximum delay time raised to 5 s so slow synced values fit.
|
||||
- **Control mapping badges** — every pedal shows the PC (footswitch), CC (expression),
|
||||
or KEY (letter key) binding on each control, with a legend above the board.
|
||||
- **CC respects tempo sync** — a CC bound to a synced parameter is ignored while synced
|
||||
(the tempo drives it) and resumes control once the parameter is set back to Free.
|
||||
|
||||
### Compatibility
|
||||
Additive persistence — older rigs load unchanged (every parameter defaults to free),
|
||||
and 2.1 rigs open in older builds with the tempo-sync state ignored.
|
||||
|
||||
## ShoeGaze 2.0.0
|
||||
|
||||
Major release. Performance-focused: a visual metronome, a real rig mute with
|
||||
keyboard control, and rigs that remember their tempo, input, and I/O — plus a
|
||||
saveable set-list order for hands-free switching between rigs live. The version
|
||||
jumps to 2.0.0 to align ShoeGaze's numbering with the wider project family.
|
||||
|
||||
### Highlights
|
||||
- **Visual metronome** — a horizontal playhead eases wall-to-wall each beat so you
|
||||
can anticipate the downbeat, replacing the old flashing LED.
|
||||
- **Rig Mute (⌘Z)** — hard-silences the whole rig; distinct from Bypass Rig (dry passthrough).
|
||||
- **Keyboard shortcuts** — ⌘1–⌘9 switch/solo boards, ⌘⇧1–⌘⇧0 load set-list rigs 1–10,
|
||||
⌘Z mutes. macOS menus + iOS/iPadOS hardware keyboards.
|
||||
- **Set lists** — reorder rigs by drag or Move Up/Down; the order saves, travels with
|
||||
an exported archive, and drives the ⌘⇧ slots.
|
||||
- **Per-rig memory** — tempo, input selection, and engine I/O now persist with a rig.
|
||||
|
||||
### Fixed
|
||||
- Archive import no longer collides set-list positions with existing rigs.
|
||||
|
||||
### Removed
|
||||
- The ShoeGazeDemo / ShoeGazeiOSDemo apps — only the ShoeGazeBuilder (macOS) and
|
||||
ShoeGazeBuilderiOS (iPad) apps remain.
|
||||
|
||||
**Compatibility:** rig persistence is additive — older rigs load unchanged, and 2.0.0
|
||||
rigs still open in older builds. The bump reflects feature scope + version alignment,
|
||||
not a format break.
|
||||
|
||||
## 1.5.0 — 2026-07-04
|
||||
|
||||
### New Looper pedal (catalog now 36)
|
||||
- **Multitrack looper** with a smart Loop footswitch (record → overdub → play), up to four
|
||||
tracks (A/B/C/D), per-track mute via the track dots, undo, reverse, and a timeline view.
|
||||
- **Beat-quantized transport** with a **Sync / Free** mode toggle; stop and cue-stop honour the
|
||||
loop boundary in Sync. Clean-through and a Playback balance let the dry signal pass while
|
||||
looped layers play back.
|
||||
- **MIDI-mappable** transport (record/play/stop), per-track A/B/C/D taps, and the Sync toggle.
|
||||
- Stomp-style **Reset** button that also fires on engine stop and rig teardown; `effect()` is
|
||||
idempotent across graph rebuilds, and the multitrack engine is RT-safe (findings from review
|
||||
addressed, with regression coverage for record-after-reset).
|
||||
|
||||
### iPad / iOS layout rework
|
||||
- **Canvas-first compact layout** — composition panels move into sheets so the pedal canvas
|
||||
fills the screen; the sheet-based layout is now used at every size class (no forced min width).
|
||||
- **Header compaction** — performance controls sit inline right of the title; rig controls group
|
||||
with Tempo/Tuner; the scope drops to a full-width strip below the rows in portrait. Fixes
|
||||
Tempo/Tuner truncation, Mute-toggle expansion, mixer overflow into the CPU meters, and portrait
|
||||
clipping/centering.
|
||||
- **Add-Pedal sheet** is a scrollable list with a fixed header and type filter at a stable size;
|
||||
fixed compact sheets that failed to present (one sheet per view node).
|
||||
|
||||
### Dependency
|
||||
- Bumped to **Lyrebird 1.2.3**. Lyrebird now ships framework-neutral project templates only —
|
||||
its ShoeGaze-specific CLI scaffolding was removed, since ShoeGaze lives in this standalone repo.
|
||||
|
||||
### Fixes
|
||||
- A transport-only **Start** no longer reverts Settings configuration (external-review fix).
|
||||
- Dropped a stale doc and a dead `looperTimeline` property.
|
||||
|
||||
## 1.4.0 — 2026-07-01
|
||||
|
||||
### MIDI foot-controller support
|
||||
- **Program Change switches** — map a footswitch to Rig Bypass, Rig Mute, All Boards On, board
|
||||
Solo/Audible/Bypass, or any pedal's Bypass. MIDI Learn captures the incoming program number;
|
||||
one Program Change can drive **multiple actions at once** ("scenes").
|
||||
- **Control Change (expression pedal) mapping** — bind a CC to any pedal knob/slider, a board's
|
||||
master level, or the new rig-wide output volume. Per-binding **invert**, so one expression
|
||||
pedal can crossfade two controls in opposite directions.
|
||||
- Bindings are per-rig, travel with the saved rig file, and decode resiliently — an
|
||||
incompatible/malformed MIDI map drops just the bindings (re-learnable) rather than the whole
|
||||
rig.
|
||||
- New **MIDI Mapping** sheet (from the transport row) lists every switch/expression target with
|
||||
live Learn / Clear / Invert controls, plus a connected-device list.
|
||||
|
||||
### Rig-wide output volume + mute
|
||||
- New **Volume** slider and **Mute** button in the board-mixer bar, alongside Solo / Blend / All
|
||||
and Crossfade — applies after every board's output, independent of per-board levels.
|
||||
- Mute is a hard output gate, distinct from the existing dry-signal Bypass. Both volume and mute
|
||||
are MIDI-mappable (CC for volume, Program Change for mute) and click-free (lagged).
|
||||
|
||||
### New reverb pedals (catalog now 35)
|
||||
- **Plate Reverb** — dense, bright metallic-plate character (Decay / Tone / Damp / Mod).
|
||||
- **Room Reverb** — natural room/hall ambience (Size / Decay / Damp / Tail).
|
||||
- **Spring Reverb** — classic amp-tank boing and drip (Decay / Tension / Damp).
|
||||
|
||||
### In-app Help
|
||||
- New **Help** view covering setup & starting the engine, input sources, boards & rigs, saving &
|
||||
autosave, iCloud documents, and MIDI control — reachable from the macOS **Help menu** and an
|
||||
iOS help button.
|
||||
|
||||
### Fixes
|
||||
- Fixed a rig-library bug where the sidebar's highlighted rig could disagree with the actually
|
||||
loaded pedal graph after a restart — the current rig id and its saved state now live in one
|
||||
atomic autosave file instead of two files that could drift apart.
|
||||
- The whole rig-library sidebar row is now tappable, not just its text label.
|
||||
|
||||
## 1.3.0 — 2026-06-28
|
||||
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
<FileRef
|
||||
location = "group:.">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Demo/ShoeGazeDemo.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Demo/ShoeGazeiOSDemo.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Demo/ShoeGazeBuilder.xcodeproj">
|
||||
</FileRef>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a",
|
||||
"originHash" : "9e278ce69e19f7dabaaaed1b75fb6112a02ece1e30e2aad82c12942c5ddeb192",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||
"version" : "1.2.0"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -28,6 +28,14 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// Defaults to a short 20 ms so normal use is click-free; raise it for a slow crossfade.
|
||||
@UIParam var crossfadeTime: Double = 0.02
|
||||
|
||||
/// Per-board full-bypass state. `0` = board engaged (processed output), `1` = bypassed
|
||||
/// (dry input passes straight through, skipping every pedal). Smoothed by `bypassLagTime`.
|
||||
@UIParam var boardBypass: Double = 0.0
|
||||
|
||||
/// Rig-wide full-bypass state, driven across every board at once. `0` = engaged,
|
||||
/// `1` = bypassed (dry). Independent of `boardBypass`; either engaged routes to dry.
|
||||
@UIParam var rigBypass: Double = 0.0
|
||||
|
||||
/// The live `UIParamNode` backing `masterGain`, exposed so the board (and its UI)
|
||||
/// can bind a master-volume knob to this stage.
|
||||
var gainNode: UIParamNode { $masterGain }
|
||||
@@ -38,6 +46,26 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// The live `UIParamNode` backing `crossfadeTime` (board crossfade seconds).
|
||||
var crossfadeTimeNode: UIParamNode { $crossfadeTime }
|
||||
|
||||
/// The live `UIParamNode` backing `boardBypass` (per-board full bypass).
|
||||
var boardBypassNode: UIParamNode { $boardBypass }
|
||||
|
||||
/// The live `UIParamNode` backing `rigBypass` (rig-wide full bypass).
|
||||
var rigBypassNode: UIParamNode { $rigBypass }
|
||||
|
||||
/// Rig-wide output volume in [0, 1], applied to the final output. Driven across every board by
|
||||
/// `ShoeGaze.setRigVolume(_:)`. Defaults to `1` (unity).
|
||||
@UIParam var rigVolume: Double = 1.0
|
||||
|
||||
/// Rig-wide output mute — `0` = audible, `1` = silenced (a hard gate, not a dry bypass). Driven
|
||||
/// across every board by `ShoeGaze.setRigMuted(_:)`. Defaults to `0`.
|
||||
@UIParam var rigMute: Double = 0.0
|
||||
|
||||
/// The live `UIParamNode` backing `rigVolume` (rig-wide output volume).
|
||||
var rigVolumeNode: UIParamNode { $rigVolume }
|
||||
|
||||
/// The live `UIParamNode` backing `rigMute` (rig-wide output mute).
|
||||
var rigMuteNode: UIParamNode { $rigMute }
|
||||
|
||||
// MARK: - Routing
|
||||
|
||||
/// Left / mono board output bus index.
|
||||
@@ -48,10 +76,25 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// bypassing the mono `Pan2` spread.
|
||||
private let boardOutputBusRightIndex: Int?
|
||||
|
||||
/// The board's dry head-bus index (the mono input feeding the first pedal). Read as the
|
||||
/// bypass source so a bypassed board passes its untouched input straight through.
|
||||
private let dryInputBusIndex: Int
|
||||
|
||||
/// Destination buses for the master's stereo output — hardware 0 / 1 by default. When a
|
||||
/// post-board chain exists, the masters are pointed at a shared **mix bus** instead, and the
|
||||
/// post-chain reads that mix and writes hardware. All boards share the same destination.
|
||||
private let outputLeftBusIndex: Int
|
||||
private let outputRightBusIndex: Int
|
||||
|
||||
// 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
|
||||
/// transitions to prevent clicks. Matches the per-pedal bypass lag.
|
||||
private let bypassLagTime: Double = 0.02
|
||||
|
||||
/// Remaps a `[0, 1]` bypass value to CrossFade's `[-1, +1]` equal-power pan.
|
||||
private let bipolarSpan: Double = 2.0
|
||||
private let bipolarOffset: Double = 1.0
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
@@ -61,9 +104,19 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// - boardOutputBusIndex: Left / mono board output bus index.
|
||||
/// - boardOutputBusRightIndex: Right board output bus index for a stereo (width-2) board,
|
||||
/// or `nil` for a mono board (the signal is panned to centre instead).
|
||||
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil) {
|
||||
/// - dryInputBusIndex: The board's head-bus index, read as the dry bypass source.
|
||||
init(
|
||||
boardOutputBusIndex: Int,
|
||||
boardOutputBusRightIndex: Int? = nil,
|
||||
dryInputBusIndex: Int,
|
||||
outputLeftBusIndex: Int = 0,
|
||||
outputRightBusIndex: Int = 1
|
||||
) {
|
||||
self.boardOutputBusIndex = boardOutputBusIndex
|
||||
self.boardOutputBusRightIndex = boardOutputBusRightIndex
|
||||
self.dryInputBusIndex = dryInputBusIndex
|
||||
self.outputLeftBusIndex = outputLeftBusIndex
|
||||
self.outputRightBusIndex = outputRightBusIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
@@ -74,18 +127,59 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
// seconds rather than clicking. The user master-gain knob is applied directly.
|
||||
let smoothedSelect: Lag.Control = Lag.Control(input: $selectGain, time: $crossfadeTime)
|
||||
|
||||
// Rig-wide output volume × mute, shared across both channels (like `smoothedSelect`).
|
||||
let rigOutputGain: any ValidGeneratorInput = rigOutputGainStage()
|
||||
|
||||
// The dry input tap — read once, used as the bypass source for both channels (the head
|
||||
// bus is mono, so a bypassed stereo board passes the same dry signal to both sides).
|
||||
let dry: In.Audio = input(bus: dryInputBusIndex)
|
||||
|
||||
let boardOutLeft: In.Audio = input(bus: boardOutputBusIndex)
|
||||
let gainedLeft: any ValidGeneratorInput = (boardOutLeft * smoothedSelect) * $masterGain
|
||||
let switchedLeft: any ValidGeneratorInput = applyBypass(wet: boardOutLeft, dry: dry)
|
||||
let gainedLeft: any ValidGeneratorInput =
|
||||
((switchedLeft * smoothedSelect) * $masterGain) * rigOutputGain
|
||||
|
||||
if let rightIndex: Int = boardOutputBusRightIndex {
|
||||
// Stereo board: left tail → hardware 0, right tail → hardware 1, no pan spread.
|
||||
let boardOutRight: In.Audio = input(bus: rightIndex)
|
||||
let gainedRight: any ValidGeneratorInput = (boardOutRight * smoothedSelect) * $masterGain
|
||||
output(bus: 0, source: gainedLeft)
|
||||
output(bus: 1, source: gainedRight)
|
||||
let switchedRight: any ValidGeneratorInput = applyBypass(wet: boardOutRight, dry: dry)
|
||||
let gainedRight: any ValidGeneratorInput =
|
||||
((switchedRight * smoothedSelect) * $masterGain) * rigOutputGain
|
||||
output(bus: outputLeftBusIndex, source: gainedLeft)
|
||||
output(bus: outputRightBusIndex, source: gainedRight)
|
||||
} else {
|
||||
// Mono board: Pan2 spreads the mono output to stereo hardware buses 0 + 1.
|
||||
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan))
|
||||
// Mono board: write the mono signal to both hardware buses at unity (0 dB). Using an
|
||||
// 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: outputLeftBusIndex, source: gainedLeft)
|
||||
output(bus: outputRightBusIndex, source: gainedLeft)
|
||||
}
|
||||
}
|
||||
|
||||
/// Rig-wide output gain: the smoothed rig volume gated by the smoothed mute. Mute `0` → gain 1
|
||||
/// (audible), mute `1` → gain 0 (silent). Both lagged to avoid clicks.
|
||||
private func rigOutputGainStage() -> any ValidGeneratorInput {
|
||||
let rigVol: Lag.Control = Lag.Control(input: $rigVolume, time: bypassLagTime)
|
||||
let muteLagged: Lag.Control = Lag.Control(input: $rigMute, time: bypassLagTime)
|
||||
// (mute − 1) × −1 ⇒ 0→1, 1→0, using only generator−scalar and generator×scalar.
|
||||
let muteGain: any ValidGeneratorInput = (muteLagged - 1.0) * -1.0
|
||||
return rigVol * muteGain
|
||||
}
|
||||
|
||||
/// Routes `wet` to `dry` when either the per-board or rig-wide bypass is engaged. Two cascaded
|
||||
/// equal-power crossfades (each lagged to prevent clicks) give an independent "OR" of the two
|
||||
/// bypass sources: rig bypass overrides even a board that is otherwise engaged.
|
||||
private func applyBypass(
|
||||
wet: any ValidGeneratorInput,
|
||||
dry: any ValidGeneratorInput
|
||||
) -> any ValidGeneratorInput {
|
||||
let boardLagged: Lag.Control = Lag.Control(input: $boardBypass, time: bypassLagTime)
|
||||
let boardPan: any ValidGeneratorInput = (boardLagged * bipolarSpan) - bipolarOffset
|
||||
let afterBoard: CrossFade.Audio = CrossFade.Audio(inA: wet, inB: dry, pan: boardPan)
|
||||
|
||||
let rigLagged: Lag.Control = Lag.Control(input: $rigBypass, time: bypassLagTime)
|
||||
let rigPan: any ValidGeneratorInput = (rigLagged * bipolarSpan) - bipolarOffset
|
||||
return CrossFade.Audio(inA: afterBoard, inB: dry, pan: rigPan)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// CabIRStage.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// One filter stage in an off-RT cabinet-IR cascade, as a kind plus parameters.
|
||||
///
|
||||
/// Consumed by ``CabinetIRFactory`` when it bakes an impulse response: the cab voice contributes a
|
||||
/// fixed cascade, and a ``MicVoice`` contributes extra stages (presence bump, top-end/low-end
|
||||
/// shelving) appended to it. `q` is used by high-pass / low-pass / peaking stages; `gainDb` by
|
||||
/// peaking and the shelves; shelves use a fixed slope set by the factory.
|
||||
struct CabIRStage {
|
||||
|
||||
/// The biquad kind this stage bakes into.
|
||||
enum Kind {
|
||||
case highPass
|
||||
case lowPass
|
||||
case peaking
|
||||
case lowShelf
|
||||
case highShelf
|
||||
}
|
||||
|
||||
let kind: Kind
|
||||
let freq: Double
|
||||
let q: Double
|
||||
let gainDb: Double
|
||||
|
||||
/// A resonant peak/dip at `freq`.
|
||||
static func peaking(_ freq: Double, q: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .peaking, freq: freq, q: q, gainDb: gainDb)
|
||||
}
|
||||
|
||||
/// A low-frequency shelf at `freq` (slope fixed by the factory).
|
||||
static func lowShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .lowShelf, freq: freq, q: 0.0, gainDb: gainDb)
|
||||
}
|
||||
|
||||
/// A high-frequency shelf at `freq` (slope fixed by the factory).
|
||||
static func highShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .highShelf, freq: freq, q: 0.0, gainDb: gainDb)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
// CabinetIRFactory.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import Darwin
|
||||
|
||||
/// Fraction of the sample rate above which a filter centre frequency is clamped, so the RBJ
|
||||
/// coefficients stay well-behaved below Nyquist even at low sample rates.
|
||||
private let cabinetBiquadNyquistFraction: Double = 0.49
|
||||
/// RBJ-cookbook divisor converting a filter gain in dB to its `A` amplitude term (peaking + shelves).
|
||||
private let cabinetDbToAmplitudeDivisor: Double = 40.0
|
||||
|
||||
/// Synthesizes a short cabinet impulse response for a ``CabinetVoice`` by running a unit
|
||||
/// impulse through a cascade of RBJ biquads (high-pass → two-stage low-pass → low-mid body
|
||||
/// peak → presence peak → cone-breakup peak → mid notch) and capturing the result into a mono
|
||||
/// ``LyrebirdBuffer``.
|
||||
///
|
||||
/// This runs **off the RT thread** (at pedal build time), so it uses plain `Double` math with
|
||||
/// no allocation constraints. The produced buffer is a normal IR consumed by `ConvolutionReverb`.
|
||||
public enum CabinetIRFactory {
|
||||
|
||||
/// Default IR length in frames. 1024 taps (~21 ms at 48 kHz) is ample for a speaker-cab
|
||||
/// magnitude curve, which has no long tail.
|
||||
public static let defaultFrames: Int = 1024
|
||||
|
||||
/// Butterworth Q for the high-pass (low rolloff) stage.
|
||||
private static let highPassQ: Double = 0.707
|
||||
/// Per-stage Q values for a true 4th-order Butterworth low-pass built as two cascaded
|
||||
/// biquads (maximally flat passband). Q ≈ 0.5412 and 1.3066.
|
||||
private static let lowPassCascadeQ: [Double] = [0.541_196_100_146_197, 1.306_562_964_876_377]
|
||||
/// Q for the resonant body / presence peaks.
|
||||
private static let peakQ: Double = 1.2
|
||||
/// Q for the narrower cone-breakup peak (higher than the body/presence peaks).
|
||||
private static let breakupQ: Double = 2.0
|
||||
/// Q for the mid interference notch (narrow, so it dips without gutting the midrange).
|
||||
private static let notchQ: Double = 2.5
|
||||
/// Fixed shelf slope for the ``MicVoice`` low-/high-shelf stages (gentle, like the amp shelves).
|
||||
private static let micShelfSlope: Double = 0.7
|
||||
|
||||
/// Builds the impulse response for `voice` (optionally mic'd by `mic`) at `sampleRate`.
|
||||
///
|
||||
/// The cab voice's fixed cascade is baked first; any ``MicVoice`` stages are appended before the
|
||||
/// impulse is run, so the mic colour is folded into the same single IR (no extra render-time
|
||||
/// cost). ``MicVoice/off`` appends nothing, so the result is byte-for-byte the raw cab voice.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - voice: The cabinet voicing to synthesize.
|
||||
/// - mic: The microphone voicing layered on top. Defaults to ``MicVoice/off`` (no mic).
|
||||
/// - sampleRate: Engine sample rate in Hz.
|
||||
/// - frames: IR length in frames. Defaults to ``defaultFrames``.
|
||||
/// - Returns: A mono `LyrebirdBuffer` holding the normalized IR, tagged with `sampleRate`.
|
||||
public static func makeIR(
|
||||
voice: CabinetVoice,
|
||||
mic: MicVoice = .off,
|
||||
sampleRate: Double,
|
||||
frames: Int = CabinetIRFactory.defaultFrames
|
||||
) -> LyrebirdBuffer {
|
||||
var chain: [OfflineBiquad] = [
|
||||
OfflineBiquad.highPass(freq: voice.highPassHz, q: highPassQ, sampleRate: sampleRate),
|
||||
OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[0], sampleRate: sampleRate),
|
||||
OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[1], sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.bodyHz, q: peakQ, gainDb: voice.bodyGainDb, sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.presenceHz, q: peakQ, gainDb: voice.presenceGainDb, sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.breakupHz, q: breakupQ, gainDb: voice.breakupGainDb, sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.notchHz, q: notchQ, gainDb: voice.notchGainDb, sampleRate: sampleRate),
|
||||
]
|
||||
|
||||
// Append the mic voicing's stages (none for `.off`) so its colour bakes into the same IR.
|
||||
for stage: CabIRStage in mic.stages {
|
||||
switch stage.kind {
|
||||
case .highPass:
|
||||
chain.append(OfflineBiquad.highPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
|
||||
case .lowPass:
|
||||
chain.append(OfflineBiquad.lowPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
|
||||
case .peaking:
|
||||
chain.append(OfflineBiquad.peaking(
|
||||
freq: stage.freq, q: stage.q, gainDb: stage.gainDb, sampleRate: sampleRate))
|
||||
case .lowShelf:
|
||||
chain.append(OfflineBiquad.lowShelf(
|
||||
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
|
||||
case .highShelf:
|
||||
chain.append(OfflineBiquad.highShelf(
|
||||
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
|
||||
}
|
||||
}
|
||||
|
||||
var ir: [Double] = [Double](repeating: 0.0, count: frames)
|
||||
for n: Int in 0..<frames {
|
||||
var sample: Double = n == 0 ? 1.0 : 0.0
|
||||
for i: Int in chain.indices {
|
||||
sample = chain[i].process(sample)
|
||||
}
|
||||
ir[n] = sample
|
||||
}
|
||||
|
||||
// Peak-normalize so the cab contributes unity-ish level regardless of the filter gains.
|
||||
let peak: Double = ir.reduce(0.0) { Swift.max($0, abs($1)) }
|
||||
if peak > 0.0 {
|
||||
let inv: Double = 1.0 / peak
|
||||
for i: Int in ir.indices { ir[i] *= inv }
|
||||
}
|
||||
|
||||
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: frames, channelCount: 1)
|
||||
buffer.fill(using: { (frame: Int, _: Int) -> Double in ir[frame] })
|
||||
buffer.setSampleRate(sampleRate)
|
||||
return buffer
|
||||
}
|
||||
}
|
||||
|
||||
/// A minimal off-RT RBJ biquad (transposed Direct Form II) used only to render cabinet IRs.
|
||||
private struct OfflineBiquad {
|
||||
private let b0: Double
|
||||
private let b1: Double
|
||||
private let b2: Double
|
||||
private let a1: Double
|
||||
private let a2: Double
|
||||
private var z1: Double = 0.0
|
||||
private var z2: Double = 0.0
|
||||
|
||||
private init(
|
||||
b0: Double,
|
||||
b1: Double,
|
||||
b2: Double,
|
||||
a1: Double,
|
||||
a2: Double
|
||||
) {
|
||||
self.b0 = b0
|
||||
self.b1 = b1
|
||||
self.b2 = b2
|
||||
self.a1 = a1
|
||||
self.a2 = a2
|
||||
}
|
||||
|
||||
/// Centre frequency clamped below Nyquist for the given sample rate.
|
||||
private static func clampedFreq(_ freq: Double, sampleRate: Double) -> Double {
|
||||
Swift.min(freq, sampleRate * cabinetBiquadNyquistFraction)
|
||||
}
|
||||
|
||||
mutating func process(_ x: Double) -> Double {
|
||||
let y: Double = b0 * x + z1
|
||||
z1 = b1 * x - a1 * y + z2
|
||||
z2 = b2 * x - a2 * y
|
||||
return y
|
||||
}
|
||||
|
||||
static func highPass(freq: Double, q: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
let a0: Double = 1.0 + alpha
|
||||
let b0: Double = (1.0 + cosW0) / 2.0
|
||||
let b1: Double = -(1.0 + cosW0)
|
||||
let b2: Double = (1.0 + cosW0) / 2.0
|
||||
let a1: Double = -2.0 * cosW0
|
||||
let a2: Double = 1.0 - alpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
static func lowPass(freq: Double, q: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
let a0: Double = 1.0 + alpha
|
||||
let b0: Double = (1.0 - cosW0) / 2.0
|
||||
let b1: Double = 1.0 - cosW0
|
||||
let b2: Double = (1.0 - cosW0) / 2.0
|
||||
let a1: Double = -2.0 * cosW0
|
||||
let a2: Double = 1.0 - alpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
static func peaking(freq: Double, q: Double, gainDb: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
let a0: Double = 1.0 + alpha / amplitude
|
||||
let b0: Double = 1.0 + alpha * amplitude
|
||||
let b1: Double = -2.0 * cosW0
|
||||
let b2: Double = 1.0 - alpha * amplitude
|
||||
let a1: Double = -2.0 * cosW0
|
||||
let a2: Double = 1.0 - alpha / amplitude
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
/// RBJ low-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
|
||||
static func lowShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let sinW0: Double = sin(w0)
|
||||
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
|
||||
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
|
||||
let ap1: Double = amplitude + 1.0
|
||||
let am1: Double = amplitude - 1.0
|
||||
let b0: Double = amplitude * (ap1 - am1 * cosW0 + twoSqrtAAlpha)
|
||||
let b1: Double = 2.0 * amplitude * (am1 - ap1 * cosW0)
|
||||
let b2: Double = amplitude * (ap1 - am1 * cosW0 - twoSqrtAAlpha)
|
||||
let a0: Double = ap1 + am1 * cosW0 + twoSqrtAAlpha
|
||||
let a1: Double = -2.0 * (am1 + ap1 * cosW0)
|
||||
let a2: Double = ap1 + am1 * cosW0 - twoSqrtAAlpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
/// RBJ high-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
|
||||
static func highShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let sinW0: Double = sin(w0)
|
||||
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
|
||||
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
|
||||
let ap1: Double = amplitude + 1.0
|
||||
let am1: Double = amplitude - 1.0
|
||||
let b0: Double = amplitude * (ap1 + am1 * cosW0 + twoSqrtAAlpha)
|
||||
let b1: Double = -2.0 * amplitude * (am1 + ap1 * cosW0)
|
||||
let b2: Double = amplitude * (ap1 + am1 * cosW0 - twoSqrtAAlpha)
|
||||
let a0: Double = ap1 - am1 * cosW0 + twoSqrtAAlpha
|
||||
let a1: Double = 2.0 * (am1 - ap1 * cosW0)
|
||||
let a2: Double = ap1 - am1 * cosW0 - twoSqrtAAlpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// CabinetVoice.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A built-in guitar-speaker-cabinet voicing.
|
||||
///
|
||||
/// Each voice is a compact set of target-response parameters — low/high rolloff, a low-mid
|
||||
/// "body" bump, an upper-mid "presence" peak, a higher cone-"breakup" peak, and a mid
|
||||
/// interference "notch" — from which ``CabinetIRFactory`` synthesizes a short impulse response
|
||||
/// entirely in code. These IRs are **our own content** (MIT, generated, no third-party capture),
|
||||
/// so they ship with the pedal without licensing concerns. (Loading a user-supplied captured
|
||||
/// `.wav` cab IR is a planned follow-up.)
|
||||
///
|
||||
/// The values are deliberately broad-strokes voicings, not measurements of specific hardware.
|
||||
public enum CabinetVoice: String, CaseIterable, Sendable {
|
||||
case americanCombo
|
||||
case britishStack
|
||||
case vintageDark
|
||||
case modernStack
|
||||
case boutiqueOpen
|
||||
case brightCombo
|
||||
case fullRange
|
||||
case loFiBox
|
||||
|
||||
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
|
||||
/// range. Used by the cab selector to pick the single voice to instantiate on a board rebuild.
|
||||
///
|
||||
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
|
||||
/// - Returns: The corresponding voice, clamped to `allCases`.
|
||||
public static func voice(atSelectorValue selectorValue: Double) -> CabinetVoice {
|
||||
let all: [CabinetVoice] = allCases
|
||||
guard selectorValue.isFinite else { return all[0] }
|
||||
// Clamp in Double space first so a huge/NaN-adjacent value can never trap `Int(_:)`.
|
||||
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
|
||||
let index: Int = Int(bounded.rounded())
|
||||
return all[index]
|
||||
}
|
||||
|
||||
/// Human-readable name for pickers.
|
||||
public var displayName: String {
|
||||
switch self {
|
||||
case .americanCombo: return "American 1×12"
|
||||
case .britishStack: return "British 4×12"
|
||||
case .vintageDark: return "Vintage Dark"
|
||||
case .modernStack: return "Modern 4×12"
|
||||
case .boutiqueOpen: return "Boutique 2×12"
|
||||
case .brightCombo: return "Bright 1×12"
|
||||
case .fullRange: return "Full-Range (FRFR)"
|
||||
case .loFiBox: return "Lo-Fi 1×8"
|
||||
}
|
||||
}
|
||||
|
||||
/// Low-frequency rolloff (high-pass cutoff) in Hz — the speaker's bass limit.
|
||||
var highPassHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 80.0
|
||||
case .britishStack: return 95.0
|
||||
case .vintageDark: return 90.0
|
||||
case .modernStack: return 100.0
|
||||
case .boutiqueOpen: return 70.0
|
||||
case .brightCombo: return 85.0
|
||||
case .fullRange: return 45.0
|
||||
case .loFiBox: return 180.0
|
||||
}
|
||||
}
|
||||
|
||||
/// High-frequency rolloff (low-pass cutoff) in Hz — the speaker's top-end limit. Applied as a
|
||||
/// two-stage cascade for a steeper, more speaker-like slope.
|
||||
var lowPassHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 5500.0
|
||||
case .britishStack: return 4500.0
|
||||
case .vintageDark: return 3800.0
|
||||
case .modernStack: return 4000.0
|
||||
case .boutiqueOpen: return 6000.0
|
||||
case .brightCombo: return 6500.0
|
||||
case .fullRange: return 9000.0
|
||||
case .loFiBox: return 3000.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Low-mid "body" peak centre in Hz.
|
||||
var bodyHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 420.0
|
||||
case .britishStack: return 700.0
|
||||
case .vintageDark: return 500.0
|
||||
case .modernStack: return 900.0
|
||||
case .boutiqueOpen: return 450.0
|
||||
case .brightCombo: return 550.0
|
||||
case .fullRange: return 300.0
|
||||
case .loFiBox: return 900.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Low-mid body peak gain in dB (may be negative for a scoop).
|
||||
var bodyGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 1.5
|
||||
case .britishStack: return -2.0
|
||||
case .vintageDark: return 2.0
|
||||
case .modernStack: return 2.0
|
||||
case .boutiqueOpen: return -1.0
|
||||
case .brightCombo: return 1.0
|
||||
case .fullRange: return 0.0
|
||||
case .loFiBox: return 4.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Presence peak centre in Hz — the upper-mid "bite".
|
||||
var presenceHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 3000.0
|
||||
case .britishStack: return 2500.0
|
||||
case .vintageDark: return 2200.0
|
||||
case .modernStack: return 3200.0
|
||||
case .boutiqueOpen: return 3500.0
|
||||
case .brightCombo: return 3800.0
|
||||
case .fullRange: return 4000.0
|
||||
case .loFiBox: return 2400.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Presence peak gain in dB.
|
||||
var presenceGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 3.0
|
||||
case .britishStack: return 4.0
|
||||
case .vintageDark: return 2.0
|
||||
case .modernStack: return 5.0
|
||||
case .boutiqueOpen: return 2.0
|
||||
case .brightCombo: return 4.0
|
||||
case .fullRange: return 1.0
|
||||
case .loFiBox: return 1.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Cone-"breakup" peak centre in Hz — the higher, narrower bite/clank a real driver adds as
|
||||
/// the cone breaks up. Sits above the presence peak.
|
||||
var breakupHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 4200.0
|
||||
case .britishStack: return 3800.0
|
||||
case .vintageDark: return 3500.0
|
||||
case .modernStack: return 3800.0
|
||||
case .boutiqueOpen: return 5000.0
|
||||
case .brightCombo: return 5200.0
|
||||
case .fullRange: return 6000.0
|
||||
case .loFiBox: return 2600.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Cone-breakup peak gain in dB. Small; `0` disables the peak (identity).
|
||||
var breakupGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 2.0
|
||||
case .britishStack: return 3.0
|
||||
case .vintageDark: return 1.5
|
||||
case .modernStack: return 3.0
|
||||
case .boutiqueOpen: return 1.5
|
||||
case .brightCombo: return 3.0
|
||||
case .fullRange: return 0.5
|
||||
case .loFiBox: return 2.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Mid interference "notch" centre in Hz — the characteristic dip from cone/mic
|
||||
/// comb-filtering, typically ~1.2–2.5 kHz.
|
||||
var notchHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 1800.0
|
||||
case .britishStack: return 1600.0
|
||||
case .vintageDark: return 1500.0
|
||||
case .modernStack: return 1700.0
|
||||
case .boutiqueOpen: return 2000.0
|
||||
case .brightCombo: return 2100.0
|
||||
case .fullRange: return 2000.0
|
||||
case .loFiBox: return 1200.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Notch depth in dB (negative). `0` disables the notch (identity).
|
||||
var notchGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return -3.0
|
||||
case .britishStack: return -4.0
|
||||
case .vintageDark: return -2.5
|
||||
case .modernStack: return -5.0
|
||||
case .boutiqueOpen: return -2.0
|
||||
case .brightCombo: return -2.0
|
||||
case .fullRange: return 0.0
|
||||
case .loFiBox: return -1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// MicVoice.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A microphone voicing baked into the cabinet impulse response — the frequency signature of the
|
||||
/// mic in front of the speaker, layered on top of the ``CabinetVoice`` cab curve.
|
||||
///
|
||||
/// Each voice is a compact set of ``CabIRStage`` filter stages (a presence bump, low-end and
|
||||
/// top-end shelving) that ``CabinetIRFactory`` appends to the cab cascade before baking, so mic
|
||||
/// choice costs nothing extra at render time — it is folded into the single convolution IR. These
|
||||
/// are **broad-strokes synthesized curves** (our own MIT content, not captures of any specific
|
||||
/// microphone), analogous to ``CabinetVoice``.
|
||||
///
|
||||
/// ``off`` contributes no stages, so a cab with no mic bakes exactly the raw cab voice — the
|
||||
/// original, mic-less behaviour.
|
||||
public enum MicVoice: String, CaseIterable, Sendable {
|
||||
case off
|
||||
case dynamic
|
||||
case ribbon
|
||||
case condenser
|
||||
|
||||
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
|
||||
/// range. Mirrors ``CabinetVoice/voice(atSelectorValue:)`` so a huge / NaN selector never traps.
|
||||
///
|
||||
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
|
||||
/// - Returns: The corresponding voice, clamped to `allCases`.
|
||||
public static func voice(atSelectorValue selectorValue: Double) -> MicVoice {
|
||||
let all: [MicVoice] = allCases
|
||||
guard selectorValue.isFinite else { return all[0] }
|
||||
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
|
||||
let index: Int = Int(bounded.rounded())
|
||||
return all[index]
|
||||
}
|
||||
|
||||
/// Human-readable name for pickers.
|
||||
public var displayName: String {
|
||||
switch self {
|
||||
case .off: return "No Mic"
|
||||
case .dynamic: return "Dynamic"
|
||||
case .ribbon: return "Ribbon"
|
||||
case .condenser: return "Condenser"
|
||||
}
|
||||
}
|
||||
|
||||
/// The mic's filter stages, appended to the cab cascade before baking. Empty for ``off``.
|
||||
///
|
||||
/// Broad-strokes voicings: the **dynamic** (moving-coil, close-mic staple) adds an upper-mid
|
||||
/// presence bump with a tightened low end and rolled-off extreme top; the **ribbon** is dark and
|
||||
/// smooth (warm low-mid, steep top rolloff, no presence spike); the **condenser** is the most
|
||||
/// extended and airy (gentle top-end lift, light presence sheen).
|
||||
var stages: [CabIRStage] {
|
||||
switch self {
|
||||
case .off:
|
||||
return []
|
||||
case .dynamic:
|
||||
return [
|
||||
CabIRStage.lowShelf(120.0, gainDb: -2.0),
|
||||
CabIRStage.peaking(5500.0, q: 1.0, gainDb: 4.0),
|
||||
CabIRStage.highShelf(9000.0, gainDb: -3.0),
|
||||
]
|
||||
case .ribbon:
|
||||
return [
|
||||
CabIRStage.lowShelf(200.0, gainDb: 2.5),
|
||||
CabIRStage.peaking(2500.0, q: 0.8, gainDb: -1.5),
|
||||
CabIRStage.highShelf(6500.0, gainDb: -7.0),
|
||||
]
|
||||
case .condenser:
|
||||
return [
|
||||
CabIRStage.peaking(8000.0, q: 1.0, gainDb: 1.5),
|
||||
CabIRStage.highShelf(11000.0, gainDb: 3.0),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// OversampledRingModulator.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import Darwin
|
||||
|
||||
/// Shared zero-fill fallback block, allocated once at module load. Returned when an upstream
|
||||
/// input yields no channel for a `_computeSamples` call, so the RT path never allocates.
|
||||
private let oversampledRingModZeroBlock: [Double] = makeSampleBuffer()
|
||||
|
||||
/// Ring modulator (`input × sine carrier`) evaluated at 2× or 4× the engine sample rate.
|
||||
///
|
||||
/// A ring modulator's product produces sum-and-difference sidebands at `f_in ± f_carrier`. The
|
||||
/// sum sideband can land above the engine Nyquist and fold back as an inharmonic alias —
|
||||
/// worst with a high carrier and bright input. Evaluating the multiply at an oversampled rate
|
||||
/// (the input upsampled through a halfband FIR, the carrier generated directly at the
|
||||
/// oversampled rate) pushes the sum term below the upsampled Nyquist, then the matching
|
||||
/// downsampler filters it out before returning to the engine rate.
|
||||
///
|
||||
/// Output is mono (channel 0 of the input is used).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to modulate.
|
||||
/// - freq: Carrier frequency in Hz. Read once per block. Defaults to `220.0`.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||
public final class OversampledRingModulator: GeneratorBase, AudioGenerator {
|
||||
|
||||
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||
private let inputSource: any ValidGeneratorInput
|
||||
|
||||
/// Resolved carrier-frequency control. Read once per block.
|
||||
private let freqInput: any ValidGeneratorInput
|
||||
|
||||
/// Oversampling factor — `2` or `4`, fixed at init.
|
||||
private let oversampleFactor: Int
|
||||
|
||||
/// Carrier phase in radians, advanced at the oversampled rate and wrapped to `[0, 2π)`.
|
||||
private var phase: Double = 0.0
|
||||
|
||||
/// 2× halfband oversampling state (used when `oversampleFactor == 2`).
|
||||
private var upsampler2x: HalfbandUpsampler2x
|
||||
private var downsampler2x: HalfbandDownsampler2x
|
||||
|
||||
/// 4× halfband oversampling state (used when `oversampleFactor == 4`).
|
||||
private var upsampler4x: HalfbandUpsampler4x
|
||||
private var downsampler4x: HalfbandDownsampler4x
|
||||
|
||||
private let twoPi: Double = 2.0 * Double.pi
|
||||
|
||||
/// Creates an oversampled ring modulator.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to modulate.
|
||||
/// - freq: Carrier frequency in Hz. Read once per block. Defaults to `220.0`.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||
public init(
|
||||
_ input: any ValidGeneratorInput,
|
||||
freq: any ValidGeneratorInput = 220.0,
|
||||
oversample: Int = 2
|
||||
) {
|
||||
precondition(
|
||||
oversample == 2 || oversample == 4,
|
||||
"OversampledRingModulator: oversample must be 2 or 4"
|
||||
)
|
||||
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||
let resolvedFreq: any ValidGeneratorInput = freq._resolvedInput()
|
||||
inputSource = resolvedInput
|
||||
freqInput = resolvedFreq
|
||||
oversampleFactor = oversample
|
||||
upsampler2x = HalfbandUpsampler2x()
|
||||
downsampler2x = HalfbandDownsampler2x()
|
||||
upsampler4x = HalfbandUpsampler4x()
|
||||
downsampler4x = HalfbandDownsampler4x()
|
||||
super.init()
|
||||
}
|
||||
|
||||
public func _computeSamples(
|
||||
graph: SynthGraph,
|
||||
count: Int
|
||||
) -> [[Double]] {
|
||||
_checkCount(count)
|
||||
guard count > 0 else { return _result }
|
||||
|
||||
let input: [Double] = inputSource.calculatedSamples(graph: graph, count: count).first
|
||||
?? oversampledRingModZeroBlock
|
||||
let sr: Double = graph.engine.sampleRate
|
||||
// A degenerate sample rate would make phaseInc NaN/Inf and latch NaN into the
|
||||
// persisted phase; zero-fill and bail, matching MoogLadder's guard.
|
||||
guard sr >= 1.0 else {
|
||||
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||
for i: Int in 0..<count { dstP[i] = 0 }
|
||||
}
|
||||
return _result
|
||||
}
|
||||
let freq: Double = freqInput.floatValue(graph: graph)
|
||||
let inCount: Int = input.count
|
||||
let useFourX: Bool = oversampleFactor == 4
|
||||
// Phase increment per oversampled sample.
|
||||
let factor: Double = useFourX ? 4.0 : 2.0
|
||||
let phaseInc: Double = twoPi * freq / (sr * factor)
|
||||
|
||||
var localPhase: Double = phase
|
||||
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||
if useFourX {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b, c, d) = upsampler4x.process(x)
|
||||
let ya: Double = a * sin(localPhase); localPhase += phaseInc
|
||||
let yb: Double = b * sin(localPhase); localPhase += phaseInc
|
||||
let yc: Double = c * sin(localPhase); localPhase += phaseInc
|
||||
let yd: Double = d * sin(localPhase); localPhase += phaseInc
|
||||
// Wrap both directions — a negative carrier frequency drives phaseInc
|
||||
// negative, so an upward-only wrap would let the phase grow unbounded.
|
||||
if localPhase >= twoPi || localPhase < 0 {
|
||||
localPhase = localPhase.truncatingRemainder(dividingBy: twoPi)
|
||||
if localPhase < 0 { localPhase += twoPi }
|
||||
}
|
||||
dstP[i] = downsampler4x.process(ya, yb, yc, yd)
|
||||
}
|
||||
} else {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b) = upsampler2x.process(x)
|
||||
let ya: Double = a * sin(localPhase); localPhase += phaseInc
|
||||
let yb: Double = b * sin(localPhase); localPhase += phaseInc
|
||||
// Wrap both directions (see 4× branch).
|
||||
if localPhase >= twoPi || localPhase < 0 {
|
||||
localPhase = localPhase.truncatingRemainder(dividingBy: twoPi)
|
||||
if localPhase < 0 { localPhase += twoPi }
|
||||
}
|
||||
dstP[i] = downsampler2x.process(ya, yb)
|
||||
}
|
||||
}
|
||||
}
|
||||
phase = localPhase
|
||||
return _result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
// OversampledSaturator.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Shared zero-fill fallback block, allocated once at module load. Returned when an upstream
|
||||
/// input yields no channel for a `_computeSamples` call, so the RT path never allocates.
|
||||
private let oversampledSaturatorZeroBlock: [Double] = makeSampleBuffer()
|
||||
|
||||
/// A waveshaping saturator that evaluates its nonlinearity at 2× or 4× the engine sample
|
||||
/// rate to keep the harmonics it generates from folding back into the audible band as
|
||||
/// aliasing.
|
||||
///
|
||||
/// A hard or steep nonlinearity (`tanh` driven hard, a hard clipper) produces harmonics well
|
||||
/// above the engine Nyquist. Evaluated at the base rate those harmonics alias — an
|
||||
/// inharmonic, buzzy "crackle" that gets worse the louder and brighter the input and the
|
||||
/// harder the drive. This generator upsamples the input, applies the ``SaturationCurve``
|
||||
/// per oversampled sample, then downsamples with the matching halfband FIR, so the aliased
|
||||
/// content is filtered out before returning to the engine rate.
|
||||
///
|
||||
/// Linear stages (DC-block high-pass, tone low-pass, output trim) do **not** alias and should
|
||||
/// stay as ordinary graph nodes around this one — only the nonlinearity needs oversampling.
|
||||
///
|
||||
/// Output is mono (channel 0 of the input is used).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to saturate.
|
||||
/// - drive: Drive amount fed to the curve. Clamped to a small positive floor. Defaults to `1.0`.
|
||||
/// - curve: The ``SaturationCurve`` to apply per oversampled sample.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Use `4` for hard-clipping curves whose
|
||||
/// harmonics extend furthest; `2` is enough for `tanh`-family soft saturation. Defaults to `2`.
|
||||
public final class OversampledSaturator: GeneratorBase, AudioGenerator {
|
||||
|
||||
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||
private let inputSource: any ValidGeneratorInput
|
||||
|
||||
/// Resolved drive control. Read once per block.
|
||||
private let driveInput: any ValidGeneratorInput
|
||||
|
||||
/// The waveshaping curve applied per oversampled sample.
|
||||
private let curve: SaturationCurve
|
||||
|
||||
/// Oversampling factor — `2` or `4`, fixed at init.
|
||||
private let oversampleFactor: Int
|
||||
|
||||
/// Lower bound on drive so `softClipNormalized`'s `tanh(drive)` denominator is never zero.
|
||||
private let minDrive: Double = 1.0e-4
|
||||
|
||||
/// 2× halfband oversampling state (used when `oversampleFactor == 2`).
|
||||
private var upsampler2x: HalfbandUpsampler2x
|
||||
private var downsampler2x: HalfbandDownsampler2x
|
||||
|
||||
/// 4× halfband oversampling state (used when `oversampleFactor == 4`).
|
||||
private var upsampler4x: HalfbandUpsampler4x
|
||||
private var downsampler4x: HalfbandDownsampler4x
|
||||
|
||||
/// Creates an oversampled saturator.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to saturate.
|
||||
/// - drive: Drive amount fed to the curve. Clamped to a small positive floor. Defaults to `1.0`.
|
||||
/// - curve: The ``SaturationCurve`` to apply per oversampled sample.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||
public init(
|
||||
_ input: any ValidGeneratorInput,
|
||||
drive: any ValidGeneratorInput = 1.0,
|
||||
curve: SaturationCurve,
|
||||
oversample: Int = 2
|
||||
) {
|
||||
precondition(
|
||||
oversample == 2 || oversample == 4,
|
||||
"OversampledSaturator: oversample must be 2 or 4"
|
||||
)
|
||||
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||
let resolvedDrive: any ValidGeneratorInput = drive._resolvedInput()
|
||||
inputSource = resolvedInput
|
||||
driveInput = resolvedDrive
|
||||
self.curve = curve
|
||||
oversampleFactor = oversample
|
||||
upsampler2x = HalfbandUpsampler2x()
|
||||
downsampler2x = HalfbandDownsampler2x()
|
||||
upsampler4x = HalfbandUpsampler4x()
|
||||
downsampler4x = HalfbandDownsampler4x()
|
||||
super.init()
|
||||
}
|
||||
|
||||
public func _computeSamples(
|
||||
graph: SynthGraph,
|
||||
count: Int
|
||||
) -> [[Double]] {
|
||||
_checkCount(count)
|
||||
guard count > 0 else { return _result }
|
||||
|
||||
let input: [Double] = inputSource.calculatedSamples(graph: graph, count: count).first
|
||||
?? oversampledSaturatorZeroBlock
|
||||
let driveRaw: Double = driveInput.floatValue(graph: graph)
|
||||
let drive: Double = Swift.max(minDrive, driveRaw)
|
||||
let inCount: Int = input.count
|
||||
let useFourX: Bool = oversampleFactor == 4
|
||||
|
||||
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||
if useFourX {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b, c, d) = upsampler4x.process(x)
|
||||
dstP[i] = downsampler4x.process(
|
||||
curve.apply(a, drive: drive),
|
||||
curve.apply(b, drive: drive),
|
||||
curve.apply(c, drive: drive),
|
||||
curve.apply(d, drive: drive)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b) = upsampler2x.process(x)
|
||||
dstP[i] = downsampler2x.process(
|
||||
curve.apply(a, drive: drive),
|
||||
curve.apply(b, drive: drive)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// SaturationCurve.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Darwin
|
||||
|
||||
/// The waveshaping curve applied per (oversampled) sample by ``OversampledSaturator``.
|
||||
///
|
||||
/// Each case reproduces the nonlinearity a specific drive pedal used to build inline from
|
||||
/// stock generators, so moving that pedal onto the oversampled path is voicing-preserving:
|
||||
///
|
||||
/// - `tanhPreGain` — `tanh(drive · x)`. Symmetric soft saturation with the drive applied
|
||||
/// *before* the `tanh` (the fuzz voicing: hard pre-gain squares the wave off).
|
||||
/// - `softClipNormalized` — `tanh(drive · x) / tanh(drive)`. The same curve normalised so a
|
||||
/// unity-drive signal passes near-linearly (the overdrive voicing).
|
||||
/// - `tanhPostGainHardClip(low:high:)` — `clip(tanh(x) · drive, low, high)`. A gentle `tanh`
|
||||
/// stage, post-gained by drive into a hard clipper (the distortion voicing). The hard clip
|
||||
/// is the dominant harmonic source and the reason this curve wants the highest oversampling
|
||||
/// factor.
|
||||
public enum SaturationCurve: Sendable {
|
||||
case tanhPreGain
|
||||
case softClipNormalized
|
||||
case tanhPostGainHardClip(low: Double, high: Double)
|
||||
|
||||
/// Applies the curve to a single sample.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - x: Input sample (already at the oversampled rate).
|
||||
/// - drive: Drive amount. The caller clamps this to a small positive floor so
|
||||
/// `softClipNormalized`'s `tanh(drive)` denominator is never zero.
|
||||
/// - Returns: The shaped sample.
|
||||
@inline(__always)
|
||||
func apply(_ x: Double, drive: Double) -> Double {
|
||||
switch self {
|
||||
case .tanhPreGain:
|
||||
return tanh(drive * x)
|
||||
case .softClipNormalized:
|
||||
return tanh(drive * x) / tanh(drive)
|
||||
case .tanhPostGainHardClip(let low, let high):
|
||||
let shaped: Double = tanh(x) * drive
|
||||
return Swift.min(high, Swift.max(low, shaped))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// FeedPassThrough.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Internal synthesizer that copies one mono bus straight to another — the writer of the shared
|
||||
/// **feed bus** that every board taps.
|
||||
///
|
||||
/// The feed bus sits between the input source and the boards: a `FeedPassThrough` copies either the
|
||||
/// raw input source (when there is no pre-board chain) or the pre-board chain's mono output onto a
|
||||
/// single stable feed bus, and every board's input tap reads that feed bus. Keeping the feed bus
|
||||
/// stable means a pre-board edit only rebuilds the pre-chain + this one node, never the boards.
|
||||
///
|
||||
/// Unlike ``TestLoopTap`` / ``HardwareInputPassThrough`` it carries no input-mute gain: the input
|
||||
/// mute lives on the per-board taps (downstream of the feed), so a tail-producing pedal in the
|
||||
/// pre-board chain is unaffected by it.
|
||||
///
|
||||
/// - Note: Must be removed from the engine before the feed bus it writes is released.
|
||||
final class FeedPassThrough: SynthesizerBase {
|
||||
|
||||
/// Index of the bus to read from — the input source bus, or the pre-board chain's mono output.
|
||||
private let inputBusIndex: Int
|
||||
|
||||
/// Index of the shared feed bus to write to.
|
||||
private let outputBusIndex: Int
|
||||
|
||||
/// Creates a pass-through that copies `inputBusIndex` to `outputBusIndex`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBusIndex: Bus to read from (input source, or pre-board chain output).
|
||||
/// - outputBusIndex: The shared feed bus to write to.
|
||||
init(inputBusIndex: Int, outputBusIndex: Int) {
|
||||
self.inputBusIndex = inputBusIndex
|
||||
self.outputBusIndex = outputBusIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func build() {
|
||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Internal synthesizer that copies one hardware input bus to a board head bus.
|
||||
///
|
||||
@@ -18,6 +19,17 @@ import LyrebirdSynth
|
||||
/// `teardown()` releases the head bus back to the allocator.
|
||||
final class HardwareInputPassThrough: SynthesizerBase {
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Input mute — `0` = audible, `1` = muted (a hard gate on the incoming signal, distinct from
|
||||
/// the rig-output mute). Driven across every board input node by `ShoeGaze.setInputMuted(_:)`,
|
||||
/// which sets a newly-added node to the session's current mute state. Defaults audible so
|
||||
/// direct users (e.g. `ChainRouter`) that don't drive the mute pass the signal through.
|
||||
@UIParam var inputMute: Double = 0.0
|
||||
|
||||
/// The live `UIParamNode` backing `inputMute`, driven by `ShoeGaze.setInputMuted(_:)`.
|
||||
var inputMuteNode: UIParamNode { $inputMute }
|
||||
|
||||
// MARK: - Routing
|
||||
|
||||
/// Index of the hardware input bus to read from (typically `engine.numOutputChannels`).
|
||||
@@ -43,6 +55,11 @@ final class HardwareInputPassThrough: SynthesizerBase {
|
||||
// MARK: - Build
|
||||
|
||||
override func build() {
|
||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
||||
// Hard kill-switch gate: `1 − inputMute`, so mute 0 → gain 1 (audible), 1 → gain 0 (exactly
|
||||
// silent). Unlagged on purpose — a lagged gate never settles to exactly zero on its first
|
||||
// blocks and leaks a faint transient right when the mute is meant to keep things quiet; a
|
||||
// kill-switch mute is expected to be abrupt anyway.
|
||||
let muteGain: any ValidGeneratorInput = ($inputMute - 1.0) * -1.0
|
||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex) * muteGain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,46 @@ public enum InputSource: Equatable {
|
||||
case liveInput(channel: Int)
|
||||
}
|
||||
|
||||
// MARK: - Codable
|
||||
|
||||
/// Persisted so a saved rig round-trips its input selection. Encoded as a `kind` discriminator
|
||||
/// plus an optional `channel`, so adding future cases stays forward-tolerant.
|
||||
extension InputSource: Codable {
|
||||
|
||||
private enum Kind: String, Codable {
|
||||
case testLoop
|
||||
case liveInput
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case kind
|
||||
case channel
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let kind: Kind = try container.decode(Kind.self, forKey: .kind)
|
||||
switch kind {
|
||||
case .testLoop:
|
||||
self = .testLoop
|
||||
case .liveInput:
|
||||
let channel: Int = try container.decode(Int.self, forKey: .channel)
|
||||
self = .liveInput(channel: channel)
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container: KeyedEncodingContainer<CodingKeys> = encoder.container(keyedBy: CodingKeys.self)
|
||||
switch self {
|
||||
case .testLoop:
|
||||
try container.encode(Kind.testLoop, forKey: .kind)
|
||||
case .liveInput(let channel):
|
||||
try container.encode(Kind.liveInput, forKey: .kind)
|
||||
try container.encode(channel, forKey: .channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Validates a `.liveInput` channel against the engine and returns the engine audio-bus
|
||||
/// index of that hardware input channel.
|
||||
///
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Internal synthesizer that copies the shared global test-loop bus to a board head bus.
|
||||
///
|
||||
@@ -19,6 +20,16 @@ import LyrebirdSynth
|
||||
/// - Note: Must be removed from the engine before the board's `teardown()` releases the head bus.
|
||||
final class TestLoopTap: SynthesizerBase {
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Input mute — `0` = audible, `1` = muted. Driven across every board input node by
|
||||
/// `ShoeGaze.setInputMuted(_:)`, which sets a newly-added node to the session's current mute
|
||||
/// state. Defaults audible so direct users that don't drive the mute pass the signal through.
|
||||
@UIParam var inputMute: Double = 0.0
|
||||
|
||||
/// The live `UIParamNode` backing `inputMute`, driven by `ShoeGaze.setInputMuted(_:)`.
|
||||
var inputMuteNode: UIParamNode { $inputMute }
|
||||
|
||||
// MARK: - Routing
|
||||
|
||||
/// Index of the shared global test-loop bus to read from.
|
||||
@@ -44,6 +55,11 @@ final class TestLoopTap: SynthesizerBase {
|
||||
// MARK: - Build
|
||||
|
||||
override func build() {
|
||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
||||
// Hard kill-switch gate: `1 − inputMute`, so mute 0 → gain 1 (audible), 1 → gain 0 (exactly
|
||||
// silent). Unlagged on purpose — a lagged gate never settles to exactly zero on its first
|
||||
// blocks and leaks a faint transient right when the mute is meant to keep things quiet; a
|
||||
// kill-switch mute is expected to be abrupt anyway.
|
||||
let muteGain: any ValidGeneratorInput = ($inputMute - 1.0) * -1.0
|
||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex) * muteGain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
// LegacyMIDIMap.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Decoder for the **pre-UUID** `MIDIMap` format, which addressed pedals and boards by chain
|
||||
/// position (`boardIndex` / `pedalIndex`) rather than by stable id.
|
||||
///
|
||||
/// Used only on load: `ShoeGazeState.init(from:)` tries the current id-based `MIDIMap` first and,
|
||||
/// if that fails, decodes this legacy shape and calls ``migrated(boards:)`` to convert each
|
||||
/// positional binding to the id of the pedal/board now sitting at that position. Because the saved
|
||||
/// positions are stable, this reconstructs correct id-bindings on every load — even though the ids
|
||||
/// themselves are freshly assigned to a legacy rig each time it is decoded.
|
||||
///
|
||||
/// Bindings whose indices fall outside the loaded rig are dropped.
|
||||
struct LegacyMIDIMap: Codable {
|
||||
|
||||
var switches: [LegacySwitchBinding]
|
||||
var ccs: [LegacyCCBinding]
|
||||
|
||||
enum LegacyAction: Codable {
|
||||
case rigBypass
|
||||
case rigMute
|
||||
case allBoards
|
||||
case boardSolo(boardIndex: Int)
|
||||
case boardAudible(boardIndex: Int)
|
||||
case boardBypass(boardIndex: Int)
|
||||
case pedalBypass(boardIndex: Int, pedalIndex: Int)
|
||||
case pedalAction(boardIndex: Int, pedalIndex: Int, kind: MIDIMap.PedalActionKind)
|
||||
case tunerToggle
|
||||
case tapTempo
|
||||
}
|
||||
|
||||
enum LegacyCCTarget: Codable {
|
||||
case pedalControl(
|
||||
boardIndex: Int,
|
||||
pedalIndex: Int,
|
||||
controlIndex: Int,
|
||||
pedalNameHint: String?,
|
||||
controlLabelHint: String?
|
||||
)
|
||||
case boardLevel(boardIndex: Int, boardLabelHint: String?)
|
||||
case rigVolume
|
||||
}
|
||||
|
||||
struct LegacySwitchBinding: Codable {
|
||||
var program: UInt8
|
||||
var channel: UInt8?
|
||||
var action: LegacyAction
|
||||
var displayNameHint: String?
|
||||
}
|
||||
|
||||
struct LegacyCCBinding: Codable {
|
||||
var controller: UInt8
|
||||
var channel: UInt8?
|
||||
var target: LegacyCCTarget
|
||||
var inverted: Bool
|
||||
}
|
||||
|
||||
// MARK: - Migration
|
||||
|
||||
/// Converts this positional map to the current id-based ``MIDIMap`` using the ids of the pedals
|
||||
/// and boards in `boards` (whose ids were freshly assigned when the rig was decoded). Bindings
|
||||
/// addressing an out-of-range board/pedal are dropped.
|
||||
func migrated(boards: [BoardState]) -> MIDIMap {
|
||||
func boardID(_ index: Int) -> UUID? {
|
||||
guard index >= 0, index < boards.count else { return nil }
|
||||
return boards[index].id
|
||||
}
|
||||
func pedalID(_ boardIndex: Int, _ pedalIndex: Int) -> UUID? {
|
||||
guard boardIndex >= 0, boardIndex < boards.count else { return nil }
|
||||
let pedals: [PedalState] = boards[boardIndex].pedals
|
||||
guard pedalIndex >= 0, pedalIndex < pedals.count else { return nil }
|
||||
return pedals[pedalIndex].id
|
||||
}
|
||||
|
||||
let migratedSwitches: [MIDIMap.SwitchBinding] = switches.compactMap { binding in
|
||||
guard let action: MIDIMap.Action = migrate(binding.action, boardID: boardID, pedalID: pedalID) else {
|
||||
return nil
|
||||
}
|
||||
return MIDIMap.SwitchBinding(
|
||||
program: binding.program,
|
||||
channel: binding.channel,
|
||||
action: action,
|
||||
displayNameHint: binding.displayNameHint
|
||||
)
|
||||
}
|
||||
|
||||
let migratedCCs: [MIDIMap.CCBinding] = ccs.compactMap { binding in
|
||||
guard let target: MIDIMap.CCTarget = migrate(binding.target, boardID: boardID, pedalID: pedalID) else {
|
||||
return nil
|
||||
}
|
||||
return MIDIMap.CCBinding(
|
||||
controller: binding.controller,
|
||||
channel: binding.channel,
|
||||
target: target,
|
||||
inverted: binding.inverted
|
||||
)
|
||||
}
|
||||
|
||||
return MIDIMap(switches: migratedSwitches, ccs: migratedCCs)
|
||||
}
|
||||
|
||||
private func migrate(
|
||||
_ action: LegacyAction,
|
||||
boardID: (Int) -> UUID?,
|
||||
pedalID: (Int, Int) -> UUID?
|
||||
) -> MIDIMap.Action? {
|
||||
switch action {
|
||||
case .rigBypass: return .rigBypass
|
||||
case .rigMute: return .rigMute
|
||||
case .allBoards: return .allBoards
|
||||
case .tunerToggle: return .tunerToggle
|
||||
case .tapTempo: return .tapTempo
|
||||
case .boardSolo(let b):
|
||||
guard let id: UUID = boardID(b) else { return nil }
|
||||
return .boardSolo(boardID: id)
|
||||
case .boardAudible(let b):
|
||||
guard let id: UUID = boardID(b) else { return nil }
|
||||
return .boardAudible(boardID: id)
|
||||
case .boardBypass(let b):
|
||||
guard let id: UUID = boardID(b) else { return nil }
|
||||
return .boardBypass(boardID: id)
|
||||
case .pedalBypass(let b, let p):
|
||||
guard let id: UUID = pedalID(b, p) else { return nil }
|
||||
return .pedalBypass(pedalID: id)
|
||||
case .pedalAction(let b, let p, let kind):
|
||||
guard let id: UUID = pedalID(b, p) else { return nil }
|
||||
return .pedalAction(pedalID: id, kind: kind)
|
||||
}
|
||||
}
|
||||
|
||||
private func migrate(
|
||||
_ target: LegacyCCTarget,
|
||||
boardID: (Int) -> UUID?,
|
||||
pedalID: (Int, Int) -> UUID?
|
||||
) -> MIDIMap.CCTarget? {
|
||||
switch target {
|
||||
case .rigVolume:
|
||||
return .rigVolume
|
||||
case .pedalControl(let b, let p, let controlIndex, let nameHint, let labelHint):
|
||||
guard let id: UUID = pedalID(b, p) else { return nil }
|
||||
return .pedalControl(pedalID: id, controlIndex: controlIndex,
|
||||
pedalNameHint: nameHint, controlLabelHint: labelHint)
|
||||
case .boardLevel(let b, let labelHint):
|
||||
guard let id: UUID = boardID(b) else { return nil }
|
||||
return .boardLevel(boardID: id, boardLabelHint: labelHint)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,562 @@
|
||||
// MIDIController.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Owns the Core MIDI connection for a ShoeGaze session and routes incoming messages to the rig.
|
||||
///
|
||||
/// Constructed once by the app (it is recreated against a fresh engine when the engine is rebuilt),
|
||||
/// and started with ``start()``. Handlers fire on Lyrebird's background MIDI queue; this controller
|
||||
/// hops to the main actor before touching any `@MainActor` rig state.
|
||||
///
|
||||
/// It establishes the Core MIDI connection, publishes device-connection state for the UI indicator,
|
||||
/// and routes incoming messages to the rig: Control Change drives bound pedal controls, and Program
|
||||
/// Change toggles bound pedal / board / rig actions. MIDI Learn arms a control so the next matching
|
||||
/// message binds to it.
|
||||
@MainActor
|
||||
@Observable
|
||||
public final class MIDIController {
|
||||
|
||||
// MARK: - Connection state
|
||||
|
||||
/// `true` when at least one MIDI input source is currently connected.
|
||||
public private(set) var isConnected: Bool = false
|
||||
|
||||
/// Names of the connected MIDI input sources (e.g. `"FCB1010"`), for the indicator's tooltip.
|
||||
public private(set) var connectedDeviceNames: [String] = []
|
||||
|
||||
// MARK: - Learn
|
||||
|
||||
/// A control armed for MIDI Learn: the next matching message captures a binding to it.
|
||||
public enum LearnTarget: Equatable, Sendable {
|
||||
/// A continuous control awaiting a Control Change (address-only; hints are `nil`).
|
||||
case cc(MIDIMap.CCTarget)
|
||||
/// A toggle action awaiting a Program Change.
|
||||
case action(MIDIMap.Action)
|
||||
/// A toggle action awaiting a computer key press.
|
||||
case key(MIDIMap.Action)
|
||||
}
|
||||
|
||||
/// The control currently armed for Learn, or `nil` when not learning. Observable so the UI can
|
||||
/// show a "Listening…" state and a global learn banner.
|
||||
public private(set) var learnTarget: LearnTarget?
|
||||
|
||||
/// Invoked on the main actor after the map changes (a binding learned or cleared), so the host
|
||||
/// can persist the rig. Optional — when unset, the map still persists on the next rig autosave.
|
||||
public var onMapChanged: (() -> Void)?
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private let midi: MIDI
|
||||
private var handlerToken: MIDIHandlerToken?
|
||||
|
||||
/// The rig this controller drives. Weak + retargetable: the app owns both, and an iOS engine
|
||||
/// rebuild swaps `ShoeGaze` out from under us.
|
||||
private weak var shoeGaze: ShoeGaze?
|
||||
|
||||
/// Main-queue timer that re-reads `midi.sources` to publish connection state. Polling is used
|
||||
/// because Lyrebird 1.2.0's `MIDI` refreshes endpoints internally but exposes no change callback.
|
||||
private var detectionTimer: DispatchSourceTimer?
|
||||
|
||||
/// Poll interval for connection state, in seconds. A foot controller is plugged in before a set,
|
||||
/// so ~1 s latency is imperceptible.
|
||||
private let detectionInterval: Double = 1.0
|
||||
|
||||
/// Crossfade time (seconds) applied to board solo/audible changes triggered by a footswitch.
|
||||
private let boardActionCrossfade: Double = 0.05
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a MIDI controller bound to an engine.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - engine: The engine the underlying `MIDI` client attaches to. On iOS this is rebuilt when
|
||||
/// live input is enabled; recreate the controller against the new engine in that case.
|
||||
/// - shoeGaze: The rig to drive. May be set later via ``retarget(_:)``.
|
||||
/// - clientName: Core MIDI client name. Defaults to `"ShoeGaze"`.
|
||||
public init(
|
||||
engine: SynthesisEngine,
|
||||
shoeGaze: ShoeGaze? = nil,
|
||||
clientName: String = "ShoeGaze"
|
||||
) {
|
||||
self.midi = MIDI(engine: engine, clientName: clientName)
|
||||
self.shoeGaze = shoeGaze
|
||||
}
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
/// Starts the MIDI client, installs the message handler, and begins polling for devices.
|
||||
/// Safe to call once; a failed `MIDI.start()` is logged and leaves the controller inert.
|
||||
public func start() {
|
||||
do {
|
||||
try midi.start()
|
||||
} catch {
|
||||
print("[MIDIController] MIDI start failed: \(error)")
|
||||
}
|
||||
installHandler()
|
||||
refreshDevices()
|
||||
startDetectionTimer()
|
||||
}
|
||||
|
||||
/// Removes the handler, stops polling, and tears down the MIDI client.
|
||||
public func stop() {
|
||||
stopDetectionTimer()
|
||||
if let token: MIDIHandlerToken = handlerToken {
|
||||
midi.removeHandler(token)
|
||||
handlerToken = nil
|
||||
}
|
||||
midi.stop()
|
||||
}
|
||||
|
||||
// MARK: - Message handling
|
||||
|
||||
private func installHandler() {
|
||||
handlerToken = midi.addHandler(name: "shoegaze.midi") { [weak self] message, _ in
|
||||
// Handlers fire on the background `lyrebird.midi` queue. Hop to the main actor (FIFO on
|
||||
// the main queue) before touching any `@MainActor` rig state.
|
||||
DispatchQueue.main.async {
|
||||
MainActor.assumeIsolated {
|
||||
self?.handle(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Routes one incoming message to the rig: captures a binding when armed for Learn, otherwise
|
||||
/// applies any matching binding. Control Change drives bound controls; Program Change toggles
|
||||
/// bound actions.
|
||||
private func handle(_ message: MIDIMessage) {
|
||||
switch message {
|
||||
case .controlChange(let channel, let controller, let value):
|
||||
if case .cc(let target) = learnTarget {
|
||||
captureCC(controller: controller, channel: channel, target: target)
|
||||
} else {
|
||||
applyCC(controller: controller, channel: channel, value: value)
|
||||
}
|
||||
case .programChange(let channel, let program):
|
||||
if case .action(let action) = learnTarget {
|
||||
captureSwitch(program: program, channel: channel, action: action)
|
||||
} else {
|
||||
applyProgram(program: program, channel: channel)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
/// Test hook: routes a message synchronously, bypassing the background-queue hop. The queue hop
|
||||
/// is exercised only in a live session; tests drive `handle` directly on the main actor.
|
||||
func ingestForTesting(_ message: MIDIMessage) {
|
||||
handle(message)
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - Learn API
|
||||
|
||||
/// Master-level range for a board fader, mirroring the UI slider.
|
||||
private let boardLevelRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
/// Arms MIDI Learn for a continuous control: the next incoming Control Change binds to it. Pass
|
||||
/// an address-only target (hints `nil`); hints are captured from the live rig at bind time.
|
||||
public func armCCLearn(_ target: MIDIMap.CCTarget) {
|
||||
learnTarget = .cc(target)
|
||||
}
|
||||
|
||||
/// Cancels any in-progress Learn.
|
||||
public func cancelLearn() {
|
||||
learnTarget = nil
|
||||
}
|
||||
|
||||
/// The CC binding currently assigned to a control, or `nil` if unbound.
|
||||
public func ccBinding(for target: MIDIMap.CCTarget) -> MIDIMap.CCBinding? {
|
||||
shoeGaze?.midiMap?.ccs.first { $0.target.addresses(target) }
|
||||
}
|
||||
|
||||
/// Whether the CC binding on a control is inverted (CC 0 → control max), or `false` if unbound.
|
||||
public func isCCInverted(for target: MIDIMap.CCTarget) -> Bool {
|
||||
ccBinding(for: target)?.inverted ?? false
|
||||
}
|
||||
|
||||
/// Sets the invert flag on the CC binding assigned to a control. Inverting swaps the sweep so a
|
||||
/// single expression pedal can crossfade — e.g. fade one control down as it moves, another up.
|
||||
public func setCCInverted(for target: MIDIMap.CCTarget, _ inverted: Bool) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap,
|
||||
let index: Int = map.ccs.firstIndex(where: { $0.target.addresses(target) }),
|
||||
map.ccs[index].inverted != inverted else { return }
|
||||
map.ccs[index].inverted = inverted
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Removes any CC binding assigned to a control.
|
||||
public func clearCCBinding(for target: MIDIMap.CCTarget) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap else { return }
|
||||
let before: Int = map.ccs.count
|
||||
map.ccs.removeAll { $0.target.addresses(target) }
|
||||
guard map.ccs.count != before else { return }
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
// MARK: - CC handling
|
||||
|
||||
/// Captures a learned CC binding for the armed control and clears the Learn state.
|
||||
private func captureCC(controller: UInt8, channel: UInt8, target: MIDIMap.CCTarget) {
|
||||
learnTarget = nil
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze else { return }
|
||||
|
||||
// `rigVolume` is applied via a setter (it has no single node) and is always valid, so it
|
||||
// needs no resolve; pedal/board targets resolve to re-stamp their display-name hints.
|
||||
let hinted: MIDIMap.CCTarget
|
||||
if case .rigVolume = target {
|
||||
hinted = .rigVolume
|
||||
} else {
|
||||
guard let resolved: ResolvedCC = resolveCC(target) else { return }
|
||||
hinted = resolved.hinted
|
||||
}
|
||||
|
||||
let binding: MIDIMap.CCBinding = MIDIMap.CCBinding(
|
||||
controller: controller,
|
||||
channel: channel,
|
||||
target: hinted
|
||||
)
|
||||
var map: MIDIMap = shoeGaze.midiMap ?? MIDIMap.empty
|
||||
// One binding per control — re-learning a control replaces its binding. A single CC may
|
||||
// drive MULTIPLE controls on purpose (e.g. map one expression pedal to two board levels and
|
||||
// invert one for a crossfade), so we deliberately do NOT steal by controller number.
|
||||
map.ccs.removeAll { $0.target.addresses(hinted) }
|
||||
map.ccs.append(binding)
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Applies an incoming CC to the control it is bound to, if any (channel-filtered).
|
||||
private func applyCC(controller: UInt8, channel: UInt8, value: UInt8) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, let map: MIDIMap = shoeGaze.midiMap else { return }
|
||||
for binding: MIDIMap.CCBinding in map.ccs where binding.controller == controller {
|
||||
if let boundChannel: UInt8 = binding.channel, boundChannel != channel { continue }
|
||||
let ccMax: Double = 127.0
|
||||
var norm: Double = Double(value) / ccMax
|
||||
if binding.inverted { norm = 1.0 - norm }
|
||||
|
||||
if case .rigVolume = binding.target {
|
||||
shoeGaze.setRigVolume(norm) // rig volume spans [0, 1] directly
|
||||
continue
|
||||
}
|
||||
guard let resolved: ResolvedCC = resolveCC(binding.target) else { continue }
|
||||
// A parameter locked to a note division is driven by the tempo; a CC write would be
|
||||
// overwritten on the next tempo change, so ignore it here. The binding stays intact and
|
||||
// resumes control the moment the parameter is set back to Free.
|
||||
if case let .pedalControl(pedalID, _, _, _) = binding.target,
|
||||
let pedal: Pedal = pedal(id: pedalID),
|
||||
pedal.isNodeTempoSynced(resolved.node) {
|
||||
continue
|
||||
}
|
||||
let mapped: Double = resolved.range.lowerBound
|
||||
+ norm * (resolved.range.upperBound - resolved.range.lowerBound)
|
||||
resolved.node.update(mapped)
|
||||
}
|
||||
}
|
||||
|
||||
/// A resolved CC target: the live node + range to drive, plus the target re-stamped with the
|
||||
/// current display-name hints (for storing at capture time).
|
||||
private struct ResolvedCC {
|
||||
let node: UIParamNode
|
||||
let range: ClosedRange<Double>
|
||||
let hinted: MIDIMap.CCTarget
|
||||
}
|
||||
|
||||
/// Resolves a CC target to its live node + range, skipping it (returns `nil`) when the positional
|
||||
/// address is out of range or a captured display-name hint no longer matches (stale binding).
|
||||
private func resolveCC(_ target: MIDIMap.CCTarget) -> ResolvedCC? {
|
||||
switch target {
|
||||
case let .pedalControl(pedalID, controlIndex, _, _):
|
||||
guard let pedal: Pedal = pedal(id: pedalID) else { return nil }
|
||||
let controls: [PedalControl] = pedal.ccMappableControls
|
||||
guard controlIndex >= 0, controlIndex < controls.count else { return nil }
|
||||
let control: PedalControl = controls[controlIndex]
|
||||
let hinted: MIDIMap.CCTarget = .pedalControl(
|
||||
pedalID: pedalID,
|
||||
controlIndex: controlIndex,
|
||||
pedalNameHint: pedal.displayName,
|
||||
controlLabelHint: control.label
|
||||
)
|
||||
return ResolvedCC(node: control.node, range: control.range, hinted: hinted)
|
||||
case let .boardLevel(boardID, _):
|
||||
guard let board: PedalBoard = board(id: boardID),
|
||||
let node: UIParamNode = board.masterGainNode else { return nil }
|
||||
let hinted: MIDIMap.CCTarget = .boardLevel(boardID: boardID, boardLabelHint: board.label)
|
||||
return ResolvedCC(node: node, range: boardLevelRange, hinted: hinted)
|
||||
case .rigVolume:
|
||||
// Applied via `ShoeGaze.setRigVolume` (fans out to every board), not a single node.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Switch (Program Change) learn + apply
|
||||
|
||||
/// Arms MIDI Learn for a toggle action: the next incoming Program Change binds to it.
|
||||
public func armSwitchLearn(_ action: MIDIMap.Action) {
|
||||
learnTarget = .action(action)
|
||||
}
|
||||
|
||||
/// The switch binding currently assigned to an action, or `nil` if unbound.
|
||||
public func switchBinding(for action: MIDIMap.Action) -> MIDIMap.SwitchBinding? {
|
||||
shoeGaze?.midiMap?.switches.first { $0.action == action }
|
||||
}
|
||||
|
||||
/// Removes any switch binding assigned to an action.
|
||||
public func clearSwitchBinding(for action: MIDIMap.Action) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap else { return }
|
||||
let before: Int = map.switches.count
|
||||
map.switches.removeAll { $0.action == action }
|
||||
guard map.switches.count != before else { return }
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Captures a learned switch binding for the armed action and clears the Learn state.
|
||||
private func captureSwitch(program: UInt8, channel: UInt8, action: MIDIMap.Action) {
|
||||
learnTarget = nil
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze else { return }
|
||||
let binding: MIDIMap.SwitchBinding = MIDIMap.SwitchBinding(
|
||||
program: program,
|
||||
channel: channel,
|
||||
action: action,
|
||||
displayNameHint: hint(for: action)
|
||||
)
|
||||
var map: MIDIMap = shoeGaze.midiMap ?? MIDIMap.empty
|
||||
// One binding per action — re-learning an action replaces its binding. A single footswitch
|
||||
// (program) may drive MULTIPLE actions on purpose (a "scene": e.g. bypass two pedals, or
|
||||
// solo a board and bypass another, from one press), so we do NOT steal by program number.
|
||||
map.switches.removeAll { $0.action == action }
|
||||
map.switches.append(binding)
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Performs every action bound to an incoming Program Change (channel-filtered).
|
||||
private func applyProgram(program: UInt8, channel: UInt8) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, let map: MIDIMap = shoeGaze.midiMap else { return }
|
||||
for binding: MIDIMap.SwitchBinding in map.switches where binding.program == program {
|
||||
if let boundChannel: UInt8 = binding.channel, boundChannel != channel { continue }
|
||||
perform(binding.action)
|
||||
}
|
||||
}
|
||||
|
||||
/// Executes a toggle action by reading the live rig state and flipping it. Boolean actions latch;
|
||||
/// `boardSolo` is exclusive (radio). Pedals/boards resolve by UUID, so a binding whose target no
|
||||
/// longer exists (removed pedal/board) simply no-ops.
|
||||
private func perform(_ action: MIDIMap.Action) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze else { return }
|
||||
switch action {
|
||||
case .rigBypass:
|
||||
shoeGaze.toggleRigBypassed()
|
||||
case .rigMute:
|
||||
shoeGaze.toggleRigMuted()
|
||||
case .inputMute:
|
||||
shoeGaze.toggleInputMuted()
|
||||
case .allBoards:
|
||||
// One-shot: cancel any solo and bring every board back up.
|
||||
shoeGaze.selectAllBoards(crossfadeSeconds: boardActionCrossfade)
|
||||
case .boardSolo(let boardID):
|
||||
guard let board: PedalBoard = board(id: boardID) else { return }
|
||||
shoeGaze.soloBoard(board, crossfadeSeconds: boardActionCrossfade)
|
||||
case .boardAudible(let boardID):
|
||||
guard let board: PedalBoard = board(id: boardID) else { return }
|
||||
shoeGaze.setBoard(board, audible: !shoeGaze.isBoardAudible(board),
|
||||
crossfadeSeconds: boardActionCrossfade)
|
||||
case .boardBypass(let boardID):
|
||||
guard let board: PedalBoard = board(id: boardID) else { return }
|
||||
shoeGaze.setBoard(board, bypassed: !shoeGaze.isBoardBypassed(board))
|
||||
case .pedalBypass(let pedalID):
|
||||
guard let pedal: Pedal = pedal(id: pedalID) else { return }
|
||||
let engagedThreshold: Double = 0.5
|
||||
let node: UIParamNode = pedal.$bypass
|
||||
node.update(node.value < engagedThreshold ? 1.0 : 0.0)
|
||||
case .pedalAction(let pedalID, let kind):
|
||||
guard let pedal: Pedal = pedal(id: pedalID) else { return }
|
||||
performPedalAction(kind, on: pedal)
|
||||
case .tunerToggle:
|
||||
shoeGaze.toggleTunerEngaged()
|
||||
case .tapTempo:
|
||||
shoeGaze.tapTempo()
|
||||
}
|
||||
}
|
||||
|
||||
/// Dispatches a pedal-specific momentary action. New `PedalActionKind` cases add a
|
||||
/// branch here once the pedal type they target exists.
|
||||
private func performPedalAction(_ kind: MIDIMap.PedalActionKind, on pedal: Pedal) {
|
||||
let toggleThreshold: Double = 0.5
|
||||
switch kind {
|
||||
case .looperRecordStop:
|
||||
// The smart Loop footswitch drives record / set-end / overdub / play by state.
|
||||
(pedal as? LooperPedal)?.pressLoop()
|
||||
case .looperOverdubToggle:
|
||||
// Overdub is toggled by the same Loop press once a loop is playing.
|
||||
(pedal as? LooperPedal)?.pressLoop()
|
||||
case .looperLoopToggle:
|
||||
guard let looper: LooperPedal = pedal as? LooperPedal else { return }
|
||||
let node: UIParamNode = looper.$loopOn
|
||||
node.update(node.value < toggleThreshold ? 1.0 : 0.0)
|
||||
case .looperReset:
|
||||
(pedal as? LooperPedal)?.resetLoop()
|
||||
case .looperStop:
|
||||
(pedal as? LooperPedal)?.stopPlayback()
|
||||
case .looperCueStop:
|
||||
(pedal as? LooperPedal)?.toggleStopAtLoopEnd()
|
||||
case .looperReverse:
|
||||
(pedal as? LooperPedal)?.toggleReverse()
|
||||
case .looperSyncToggle:
|
||||
(pedal as? LooperPedal)?.cycleSyncMode()
|
||||
case .looperTrack(let index):
|
||||
(pedal as? LooperPedal)?.tapTrack(index)
|
||||
case .pedalPrimaryTransport:
|
||||
(pedal as? MIDITransportPedal)?.toggleMIDITransport()
|
||||
}
|
||||
}
|
||||
|
||||
/// A display-name hint for an action, captured at learn time for the mapping-sheet UI label.
|
||||
/// Not used for resolution (bindings resolve by UUID) — purely a human-readable snapshot.
|
||||
private func hint(for action: MIDIMap.Action) -> String? {
|
||||
switch action {
|
||||
case .rigBypass, .rigMute, .inputMute, .allBoards:
|
||||
return nil
|
||||
case .boardSolo(let boardID), .boardAudible(let boardID), .boardBypass(let boardID):
|
||||
return board(id: boardID)?.label
|
||||
case .pedalBypass(let pedalID), .pedalAction(let pedalID, _):
|
||||
return pedal(id: pedalID)?.displayName
|
||||
case .tunerToggle, .tapTempo:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolves a board by its stable id, or `nil` if no board in the rig has that id.
|
||||
private func board(id: UUID) -> PedalBoard? {
|
||||
shoeGaze?.boards.first { $0.id == id }
|
||||
}
|
||||
|
||||
/// Resolves a pedal by its stable id across all boards' linear pedal chains, or `nil` if no
|
||||
/// pedal in the rig has that id.
|
||||
private func pedal(id: UUID) -> Pedal? {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze else { return nil }
|
||||
for board: PedalBoard in shoeGaze.boards {
|
||||
if let match: Pedal = board.pedals.first(where: { $0.id == id }) { return match }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: - Key learn + apply
|
||||
|
||||
/// Arms MIDI Learn for a toggle action awaiting a key: the next ingested key press binds to it.
|
||||
public func armKeyLearn(_ action: MIDIMap.Action) {
|
||||
learnTarget = .key(action)
|
||||
}
|
||||
|
||||
/// The key binding currently assigned to an action, or `nil` if unbound.
|
||||
public func keyBinding(for action: MIDIMap.Action) -> MIDIMap.KeyBinding? {
|
||||
shoeGaze?.midiMap?.keys.first { $0.action == action }
|
||||
}
|
||||
|
||||
/// Removes any key binding assigned to an action.
|
||||
public func clearKeyBinding(for action: MIDIMap.Action) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap else { return }
|
||||
let before: Int = map.keys.count
|
||||
map.keys.removeAll { $0.action == action }
|
||||
guard map.keys.count != before else { return }
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Normalizes a raw key string to the single lowercased character used for storage and matching,
|
||||
/// or `nil` when the input is not exactly one letter or digit. Restricting to alphanumerics keeps
|
||||
/// non-printing keys (Return, Tab, Escape, arrows — all single `Character`s) from being learned
|
||||
/// and then silently swallowed app-wide.
|
||||
private func normalizedKey(_ raw: String) -> String? {
|
||||
let lowered: String = raw.lowercased()
|
||||
guard lowered.count == 1, let character: Character = lowered.first, character.isASCII,
|
||||
character.isLetter || character.isNumber else { return nil }
|
||||
return lowered
|
||||
}
|
||||
|
||||
/// Routes a computer key press: captures a binding when armed for key Learn, otherwise performs
|
||||
/// every action bound to that key + modifier combination. Returns `true` when the press was
|
||||
/// consumed (learned or matched a binding) so the caller can swallow the event; `false` lets it
|
||||
/// fall through.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - rawKey: The pressed key; normalized to a single lowercased character.
|
||||
/// - modifiers: The modifier keys held with the press. `a` and `⇧a` bind independently.
|
||||
@discardableResult
|
||||
public func ingestKey(_ rawKey: String, modifiers: MIDIMap.KeyModifiers = []) -> Bool {
|
||||
guard let key: String = normalizedKey(rawKey) else { return false }
|
||||
if case .key(let action) = learnTarget {
|
||||
captureKey(key: key, modifiers: modifiers, action: action)
|
||||
return true
|
||||
}
|
||||
return applyKey(key, modifiers: modifiers)
|
||||
}
|
||||
|
||||
/// Captures a learned key binding for the armed action and clears the Learn state. One binding
|
||||
/// per action — re-learning replaces it — but a single key may drive multiple actions (a scene),
|
||||
/// so we do not steal by key.
|
||||
private func captureKey(key: String, modifiers: MIDIMap.KeyModifiers, action: MIDIMap.Action) {
|
||||
learnTarget = nil
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze else { return }
|
||||
let binding: MIDIMap.KeyBinding = MIDIMap.KeyBinding(
|
||||
key: key,
|
||||
modifiers: modifiers,
|
||||
action: action,
|
||||
displayNameHint: hint(for: action)
|
||||
)
|
||||
var map: MIDIMap = shoeGaze.midiMap ?? MIDIMap.empty
|
||||
map.keys.removeAll { $0.action == action }
|
||||
map.keys.append(binding)
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Performs every action bound to a key + modifier combination. Returns `true` when at least one
|
||||
/// binding matched (key and modifiers both equal).
|
||||
private func applyKey(_ key: String, modifiers: MIDIMap.KeyModifiers) -> Bool {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, let map: MIDIMap = shoeGaze.midiMap else { return false }
|
||||
var matched: Bool = false
|
||||
for binding: MIDIMap.KeyBinding in map.keys
|
||||
where binding.key == key && binding.modifiers == modifiers {
|
||||
perform(binding.action)
|
||||
matched = true
|
||||
}
|
||||
return matched
|
||||
}
|
||||
|
||||
// MARK: - Device detection
|
||||
|
||||
private func refreshDevices() {
|
||||
let names: [String] = midi.sources.map { $0.name }
|
||||
connectedDeviceNames = names
|
||||
isConnected = !names.isEmpty
|
||||
}
|
||||
|
||||
private func startDetectionTimer() {
|
||||
let timer: DispatchSourceTimer = DispatchSource.makeTimerSource(queue: .main)
|
||||
timer.schedule(deadline: .now() + detectionInterval, repeating: detectionInterval)
|
||||
timer.setEventHandler { [weak self] in
|
||||
MainActor.assumeIsolated {
|
||||
self?.refreshDevices()
|
||||
}
|
||||
}
|
||||
timer.resume()
|
||||
detectionTimer = timer
|
||||
}
|
||||
|
||||
private func stopDetectionTimer() {
|
||||
detectionTimer?.cancel()
|
||||
detectionTimer = nil
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
// MIDIMap.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
|
||||
/// A per-rig map of MIDI foot-controller bindings — which Program Change toggles which control, and
|
||||
/// which Control Change drives which pedal knob.
|
||||
///
|
||||
/// Stored inside the rig (embedded in `ShoeGazeState`) so it travels with a saved rig. Pedals and
|
||||
/// boards are addressed by **stable UUID** (`Pedal.id` / `PedalBoard.id`, persisted in
|
||||
/// `PedalState`/`BoardState`), so a binding follows its pedal/board through insert, remove, move,
|
||||
/// and reorder edits with no reindexing — the id survives the capture → rebuild round-trip. A
|
||||
/// binding whose target no longer exists simply stops resolving (inert). The `*Hint` fields carry
|
||||
/// the display name at learn time, for UI labels only (not resolution). Control-within-pedal is
|
||||
/// still indexed into `Pedal.ccMappableControls`, which is stable for a given pedal type.
|
||||
public struct MIDIMap: Codable, Equatable, Sendable {
|
||||
|
||||
/// Program-Change → action bindings (footswitch toggles). Populated in the switch phase.
|
||||
public var switches: [SwitchBinding]
|
||||
|
||||
/// Control-Change → pedal-knob bindings (expression pedals).
|
||||
public var ccs: [CCBinding]
|
||||
|
||||
/// Computer letter/digit key → action bindings. Same toggle ``Action`` set as ``switches`` —
|
||||
/// a key press is a software footswitch — but keys never drive continuous CC targets.
|
||||
public var keys: [KeyBinding]
|
||||
|
||||
/// An empty map (no bindings).
|
||||
public static let empty: MIDIMap = MIDIMap()
|
||||
|
||||
/// Creates a MIDI map.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - switches: Program-Change bindings. Defaults to empty.
|
||||
/// - ccs: Control-Change bindings. Defaults to empty.
|
||||
/// - keys: Letter-key bindings. Defaults to empty.
|
||||
public init(
|
||||
switches: [SwitchBinding] = [],
|
||||
ccs: [CCBinding] = [],
|
||||
keys: [KeyBinding] = []
|
||||
) {
|
||||
self.switches = switches
|
||||
self.ccs = ccs
|
||||
self.keys = keys
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case switches
|
||||
case ccs
|
||||
case keys
|
||||
}
|
||||
|
||||
/// Decodes a map, tolerating an absent `keys` list so a rig saved before keyboard mapping
|
||||
/// existed still decodes with its `switches` / `ccs` intact (synthesized Codable would fail
|
||||
/// the whole map on the missing key, silently dropping the MIDI bindings too). `encode(to:)`
|
||||
/// stays synthesized and always writes `keys` (empty when there are none).
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.switches = try container.decode([SwitchBinding].self, forKey: .switches)
|
||||
self.ccs = try container.decode([CCBinding].self, forKey: .ccs)
|
||||
self.keys = try container.decodeIfPresent([KeyBinding].self, forKey: .keys) ?? []
|
||||
}
|
||||
|
||||
// MARK: - Action
|
||||
|
||||
/// A toggle-style control a footswitch (Program Change) can drive. Program Change is momentary,
|
||||
/// so boolean actions latch in software; `boardSolo` is exclusive (radio).
|
||||
public enum Action: Codable, Equatable, Sendable {
|
||||
case rigBypass
|
||||
/// Mutes/unmutes the rig output (a hard silence, not a bypass).
|
||||
case rigMute
|
||||
/// Mutes/unmutes the input feeding every board (the incoming guitar / mic signal).
|
||||
case inputMute
|
||||
/// Cancels any solo and makes every board audible again (the "All" button).
|
||||
case allBoards
|
||||
case boardSolo(boardID: UUID)
|
||||
case boardAudible(boardID: UUID)
|
||||
case boardBypass(boardID: UUID)
|
||||
case pedalBypass(pedalID: UUID)
|
||||
/// A pedal-specific momentary action beyond generic bypass (e.g. a looper's
|
||||
/// record/stop or reset footswitch). `kind` is opaque to `MIDIMap` — `MIDIController`
|
||||
/// resolves the target pedal (by id) and dispatches on `kind` itself.
|
||||
case pedalAction(pedalID: UUID, kind: PedalActionKind)
|
||||
/// Toggles the rig-level tuner on/off.
|
||||
case tunerToggle
|
||||
/// Registers one tap-tempo press (see `ShoeGaze.tapTempo()`).
|
||||
case tapTempo
|
||||
}
|
||||
|
||||
/// A pedal-specific momentary action addressable by ``Action/pedalAction(pedalID:kind:)``.
|
||||
/// New pedals with more than a simple bypass toggle add cases here.
|
||||
public enum PedalActionKind: Codable, Equatable, Sendable {
|
||||
/// Looper: presses the smart Loop footswitch (record → set end → overdub → play by
|
||||
/// state) — same as ``looperOverdubToggle``; both dispatch to `LooperPedal.pressLoop()`.
|
||||
// TODO: collapse looperRecordStop / looperOverdubToggle into one case (both call pressLoop).
|
||||
case looperRecordStop
|
||||
/// Looper: presses the smart Loop footswitch (toggles overdub once a loop is playing).
|
||||
case looperOverdubToggle
|
||||
/// Looper: flips `loopOn` (loop mute) between `0` and `1`.
|
||||
case looperLoopToggle
|
||||
/// Looper: reset — clears all tracks and returns to the clear state.
|
||||
case looperReset
|
||||
/// Looper: immediately stops playback (`LooperPedal.stopPlayback()`).
|
||||
case looperStop
|
||||
/// Looper: arms / cancels a stop at the loop end (`LooperPedal.toggleStopAtLoopEnd()`).
|
||||
case looperCueStop
|
||||
/// Looper: flips playback direction (`LooperPedal.toggleReverse()`).
|
||||
case looperReverse
|
||||
/// Looper: cycles the Sync/Free transport mode (`LooperPedal.cycleSyncMode()`).
|
||||
case looperSyncToggle
|
||||
/// Looper: taps track `index` (0 = A) — selects it, or mutes it if already selected and
|
||||
/// recorded (`LooperPedal.tapTrack(_:)`), matching the A/B/C/D dots.
|
||||
case looperTrack(index: Int)
|
||||
|
||||
/// Toggles a pedal's primary transport footswitch — any ``MIDITransportPedal`` (e.g.
|
||||
/// TunedVerb's Capture, FreezVerb's Freeze). Dispatched to `toggleMIDITransport()`.
|
||||
case pedalPrimaryTransport
|
||||
}
|
||||
|
||||
// MARK: - Switch binding
|
||||
|
||||
/// A Program-Change number bound to a toggle ``Action``.
|
||||
public struct SwitchBinding: Codable, Equatable, Sendable {
|
||||
|
||||
/// The Program Change number (0–127) that triggers the action.
|
||||
public var program: UInt8
|
||||
|
||||
/// The MIDI channel (0–15), or `nil` to match any channel (omni).
|
||||
public var channel: UInt8?
|
||||
|
||||
/// The control to toggle.
|
||||
public var action: Action
|
||||
|
||||
/// The resolved control's display name at learn time, for stale-binding detection.
|
||||
public var displayNameHint: String?
|
||||
|
||||
/// Creates a switch binding.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - program: Program Change number (0–127).
|
||||
/// - channel: MIDI channel (0–15), or `nil` for omni. Defaults to `nil`.
|
||||
/// - action: The toggle action to perform.
|
||||
/// - displayNameHint: Resolved control name at learn time. Defaults to `nil`.
|
||||
public init(
|
||||
program: UInt8,
|
||||
channel: UInt8? = nil,
|
||||
action: Action,
|
||||
displayNameHint: String? = nil
|
||||
) {
|
||||
self.program = program
|
||||
self.channel = channel
|
||||
self.action = action
|
||||
self.displayNameHint = displayNameHint
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Key modifiers
|
||||
|
||||
/// The modifier keys that qualify a ``KeyBinding``, so `a` and `⇧a` (and `⌃a`, `⌥a`) are
|
||||
/// distinct triggers. Shift is a modifier here rather than being folded into the key's case,
|
||||
/// which keeps the base key a single lowercased character on every platform. Command is
|
||||
/// deliberately absent — it is reserved for the app's menu keyboard shortcuts.
|
||||
public struct KeyModifiers: OptionSet, Codable, Equatable, Hashable, Sendable {
|
||||
|
||||
public let rawValue: Int
|
||||
|
||||
public init(rawValue: Int) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
/// The Shift key (`⇧`).
|
||||
public static let shift: KeyModifiers = KeyModifiers(rawValue: 1 << 0)
|
||||
/// The Control key (`⌃`).
|
||||
public static let control: KeyModifiers = KeyModifiers(rawValue: 1 << 1)
|
||||
/// The Option key (`⌥`).
|
||||
public static let option: KeyModifiers = KeyModifiers(rawValue: 1 << 2)
|
||||
}
|
||||
|
||||
// MARK: - Key binding
|
||||
|
||||
/// A computer letter/digit key bound to a toggle ``Action``. Fires on key-down when no text
|
||||
/// field is focused; the same latch semantics as a footswitch (booleans flip in software,
|
||||
/// `boardSolo` is exclusive). `key` is a single lowercased character; ``modifiers`` distinguish
|
||||
/// `a` from `⇧a`, `⌃a`, and `⌥a`.
|
||||
public struct KeyBinding: Codable, Equatable, Sendable {
|
||||
|
||||
/// The bound key as a single lowercased character (e.g. `"b"`, `"3"`).
|
||||
public var key: String
|
||||
|
||||
/// The modifier keys held with ``key``. Empty for an unmodified press.
|
||||
public var modifiers: KeyModifiers
|
||||
|
||||
/// The control to toggle.
|
||||
public var action: Action
|
||||
|
||||
/// The resolved control's display name at learn time, for stale-binding detection.
|
||||
public var displayNameHint: String?
|
||||
|
||||
/// Creates a key binding.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - key: The bound key, normalized to a single lowercased character.
|
||||
/// - modifiers: The qualifying modifier keys. Defaults to none.
|
||||
/// - action: The toggle action to perform.
|
||||
/// - displayNameHint: Resolved control name at learn time. Defaults to `nil`.
|
||||
public init(
|
||||
key: String,
|
||||
modifiers: KeyModifiers = [],
|
||||
action: Action,
|
||||
displayNameHint: String? = nil
|
||||
) {
|
||||
self.key = key
|
||||
self.modifiers = modifiers
|
||||
self.action = action
|
||||
self.displayNameHint = displayNameHint
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case key
|
||||
case modifiers
|
||||
case action
|
||||
case displayNameHint
|
||||
}
|
||||
|
||||
/// Decodes a key binding, defaulting `modifiers` to none when absent so a binding saved
|
||||
/// before modifiers existed still decodes (unmodified, as it was learned). `encode(to:)`
|
||||
/// stays synthesized.
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.key = try container.decode(String.self, forKey: .key)
|
||||
self.modifiers = try container.decodeIfPresent(KeyModifiers.self, forKey: .modifiers) ?? []
|
||||
self.action = try container.decode(Action.self, forKey: .action)
|
||||
self.displayNameHint = try container.decodeIfPresent(String.self, forKey: .displayNameHint)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CC target
|
||||
|
||||
/// A continuous control an expression pedal can drive — either a specific pedal control (a knob
|
||||
/// or slider, addressed by index into the pedal's ``Pedal/ccMappableControls``) or a board's
|
||||
/// master level. The `*Hint` payloads capture the resolved display name at learn time so a
|
||||
/// binding that no longer matches (chain edited) can be detected and skipped.
|
||||
public enum CCTarget: Codable, Equatable, Sendable {
|
||||
|
||||
/// A knob or slider on a pedal, indexed into `pedal.ccMappableControls`.
|
||||
case pedalControl(
|
||||
pedalID: UUID,
|
||||
controlIndex: Int,
|
||||
pedalNameHint: String?,
|
||||
controlLabelHint: String?
|
||||
)
|
||||
|
||||
/// A board's master output level (the board fader).
|
||||
case boardLevel(boardID: UUID, boardLabelHint: String?)
|
||||
|
||||
/// The rig-wide output volume (applies to the whole rig).
|
||||
case rigVolume
|
||||
|
||||
/// Whether two targets address the same control, ignoring the display-name hints (used to
|
||||
/// find and replace a binding regardless of the name captured at learn time).
|
||||
public func addresses(_ other: CCTarget) -> Bool {
|
||||
switch (self, other) {
|
||||
case let (.pedalControl(p1, c1, _, _), .pedalControl(p2, c2, _, _)):
|
||||
return p1 == p2 && c1 == c2
|
||||
case let (.boardLevel(b1, _), .boardLevel(b2, _)):
|
||||
return b1 == b2
|
||||
case (.rigVolume, .rigVolume):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CC binding
|
||||
|
||||
/// A Control-Change number bound to a pedal knob. The incoming value (0–127) is mapped across
|
||||
/// the knob's own range; `inverted` swaps heel/toe for reversed expression pedals.
|
||||
public struct CCBinding: Codable, Equatable, Sendable {
|
||||
|
||||
/// The Control Change number (0–127).
|
||||
public var controller: UInt8
|
||||
|
||||
/// The MIDI channel (0–15), or `nil` to match any channel (omni).
|
||||
public var channel: UInt8?
|
||||
|
||||
/// The pedal knob this CC drives.
|
||||
public var target: CCTarget
|
||||
|
||||
/// When `true`, CC 0 maps to the knob's maximum and 127 to its minimum.
|
||||
public var inverted: Bool
|
||||
|
||||
/// Creates a CC binding.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - controller: Control Change number (0–127).
|
||||
/// - channel: MIDI channel (0–15), or `nil` for omni. Defaults to `nil`.
|
||||
/// - target: The pedal knob to drive.
|
||||
/// - inverted: Reverse the sweep direction. Defaults to `false`.
|
||||
public init(
|
||||
controller: UInt8,
|
||||
channel: UInt8? = nil,
|
||||
target: CCTarget,
|
||||
inverted: Bool = false
|
||||
) {
|
||||
self.controller = controller
|
||||
self.channel = channel
|
||||
self.target = target
|
||||
self.inverted = inverted
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// MIDITransportPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A pedal with a primary **transport footswitch** — a momentary, latching action beyond generic
|
||||
/// bypass (e.g. TunedVerb's *Capture*, FreezVerb's *Freeze*) — that can be driven by a MIDI
|
||||
/// footswitch.
|
||||
///
|
||||
/// Conforming makes the action appear in the MIDI mapping sheet automatically and lets a mapped
|
||||
/// Program Change fire it: the sheet lists `midiTransportName`, and `MIDIController` calls
|
||||
/// ``toggleMIDITransport()`` for a `PedalActionKind/pedalPrimaryTransport` binding. A pedal with a
|
||||
/// richer transport surface (the looper) is handled by its own dedicated action kinds instead.
|
||||
@MainActor
|
||||
public protocol MIDITransportPedal: AnyObject {
|
||||
|
||||
/// Short display name of the primary transport footswitch (e.g. `"Capture"`, `"Freeze"`), shown
|
||||
/// in the MIDI mapping sheet after the pedal name.
|
||||
var midiTransportName: String { get }
|
||||
|
||||
/// Toggles the primary transport footswitch — called when a mapped MIDI footswitch fires. Same
|
||||
/// effect as pressing the pedal's on-screen footswitch.
|
||||
func toggleMIDITransport()
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
@@ -18,7 +19,7 @@ import LyrebirdUI
|
||||
/// inputBus → dry → effect(_:) → wet
|
||||
/// ↕ mix (equal-power crossfade)
|
||||
/// blended
|
||||
/// ↕ bypass (lagged equal-power crossfade with dry)
|
||||
/// ↕ bypass (linear equal-power crossfade with dry)
|
||||
/// switched → × level → outputBus
|
||||
/// ```
|
||||
///
|
||||
@@ -31,7 +32,7 @@ import LyrebirdUI
|
||||
///
|
||||
/// - `mix`: Wet/dry blend in `[0, 1]`. `0` = fully dry, `1` = fully wet.
|
||||
/// - `bypass`: Bypass state. `0` = engaged (effect active), `1` = bypassed (pure dry).
|
||||
/// Transitions are smoothed with a 20 ms lag to avoid clicks.
|
||||
/// Transitions are smoothed with a linear crossfade (see ``bypassFadeTime``) to avoid clicks.
|
||||
/// - `level`: Output gain as a linear multiplier. `1.0` = unity gain.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -46,12 +47,17 @@ open class Pedal: SynthesizerBase {
|
||||
@UIParam public var mix: Double = 1.0
|
||||
|
||||
/// Bypass state. `0` = engaged (effect active), `1` = bypassed (dry signal only).
|
||||
/// Transitions are smoothed by `bypassLagTime` seconds to prevent clicks.
|
||||
/// Transitions are smoothed by a linear crossfade over ``bypassFadeTime`` seconds to prevent clicks.
|
||||
@UIParam public var bypass: Double = 0.0
|
||||
|
||||
/// Output gain as a linear multiplier. `1.0` = unity gain.
|
||||
@UIParam public var level: Double = 1.0
|
||||
|
||||
/// Optional path to an external resource this pedal references (e.g. a neural-amp model file).
|
||||
/// Not a `@UIParam` — it's a `String`, applied at `build()`, and persisted separately in
|
||||
/// ``PedalState/resourcePath``. Default `nil`. Pedals that don't use an external file ignore it.
|
||||
public var resourcePath: String?
|
||||
|
||||
// MARK: - Sample rate
|
||||
|
||||
/// Engine sample rate, injected by `PedalBoard.add(_:)` before the pedal is added
|
||||
@@ -59,8 +65,37 @@ open class Pedal: SynthesizerBase {
|
||||
/// safe 48 kHz fallback.
|
||||
public var sampleRate: Double = 48000.0
|
||||
|
||||
// MARK: - Tempo / engine (injected)
|
||||
|
||||
/// Shared tempo clock, injected by `PedalBoard.add(_:)` for tempo-aware pedals (the
|
||||
/// looper's beat-quantized transport). `nil` for pedals added to a board that was
|
||||
/// created without a clock (e.g. a bare parallel sub-board). Weak: the clock is owned
|
||||
/// by `ShoeGaze` and outlives every pedal.
|
||||
public internal(set) weak var clock: LyrebirdClock?
|
||||
|
||||
/// The engine that owns this pedal's nodes, injected by `PedalBoard.add(_:)`. Needed by
|
||||
/// tempo-aware pedals to start a `LyrebirdRoutine` that waits on beat boundaries. Weak:
|
||||
/// the engine owns the node tree, not the reverse.
|
||||
public internal(set) weak var hostEngine: SynthesisEngine?
|
||||
|
||||
// MARK: - Tempo sync
|
||||
|
||||
/// Sync state per tempo-syncable parameter, keyed by ``TempoSyncableParam/key``. A missing
|
||||
/// key means ``TempoSync/free``. Persisted in ``PedalState`` and restored on rig load.
|
||||
public internal(set) var tempoSync: [String: TempoSync] = [:]
|
||||
|
||||
/// Observable signal bumped on every ``tempoSync`` change so a SwiftUI badge re-renders when the
|
||||
/// sync state changes through any path (the picker, a preset load, or a lightweight recall).
|
||||
public let tempoSyncRevision: TempoSyncRevision = TempoSyncRevision()
|
||||
|
||||
// MARK: - Identity / routing
|
||||
|
||||
/// Stable identity for this pedal instance, persisted in ``PedalState`` and used by MIDI
|
||||
/// bindings to address the pedal by id rather than by chain position. Defaults to a fresh
|
||||
/// `UUID` for a newly-created pedal; a rebuild from a saved rig restores the saved id
|
||||
/// (`board.add(_:)` / preset apply sets it), so a pedal keeps its identity across edits.
|
||||
public internal(set) var id: UUID = UUID()
|
||||
|
||||
/// Human-readable name for the pedal (e.g. "Overdrive", "Delay").
|
||||
public let displayName: String
|
||||
|
||||
@@ -87,14 +122,56 @@ open class Pedal: SynthesizerBase {
|
||||
/// Override in a widener or stereo-native subclass.
|
||||
open var channelKind: PedalChannelKind { .mono }
|
||||
|
||||
/// Whether the UI shows the common wet/dry `Mix` control for this pedal. Defaults to `true`.
|
||||
/// A pedal that manages its own dry/wet balance internally (e.g. the looper, where the clean
|
||||
/// signal always passes through) overrides this to `false` so the confusing Mix knob is hidden
|
||||
/// and `mix` stays at its fully-wet default.
|
||||
open var showsMixControl: Bool { true }
|
||||
|
||||
/// Called on the main thread when the audio engine is stopped by the user (via
|
||||
/// `ShoeGaze.stopEngine()`), not during a transient stop-around-rebuild. Stateful pedals
|
||||
/// (e.g. the looper) override this to return to a clean state. Default: no-op.
|
||||
open func engineDidStop() {}
|
||||
|
||||
/// Called on the main thread just before the rig is torn down (rig load / clear / input-source
|
||||
/// change), while the pedal is still live. Stateful pedals override this to stop any background
|
||||
/// work and return to a clean state before their instance is discarded. Default: no-op.
|
||||
///
|
||||
/// - Important: Fired from `ShoeGaze.teardown()`, which — like all node-removal paths — must
|
||||
/// run with the engine already stopped. An override that clears buffers or stops RT-adjacent
|
||||
/// work relies on that precondition; do not call `teardown()` with the engine running.
|
||||
open func rigWillTeardown() {}
|
||||
|
||||
/// Number of standard enclosure widths this pedal's card occupies in the UI. Defaults
|
||||
/// to `1`. This sets the card's **base width in knob columns**: `1` = a three-wide card, `≥ 2` =
|
||||
/// four-wide (and the knob grid packs that many across). It is both the grid's column count and
|
||||
/// the card's minimum width, so a `2` pedal is a four-wide card even with few knobs (e.g. the
|
||||
/// Cabinet, to keep its selector captions readable). A pedal whose selector/switch row is wider
|
||||
/// still pushes wider; values above `2` add nothing. (The looper is the sole exception: it
|
||||
/// overrides the UI to a fixed multi-column layout scaled by this value.)
|
||||
open var widthUnits: Int { 1 }
|
||||
|
||||
/// `true` when the board has placed this pedal in a stereo (width-2) region.
|
||||
public var isStereo: Bool { outputBusRight != nil }
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Lag time constant in seconds (60 dB convergence) for the bypass crossfade.
|
||||
/// Smooths engaged ↔ bypassed transitions to prevent audible clicks.
|
||||
private let bypassLagTime: Double = 0.02
|
||||
/// Duration in seconds of the engaged ↔ bypassed crossfade. The bypass control is slewed
|
||||
/// **linearly** and at **audio rate** from `0` to `1` (or back) over this time, so the
|
||||
/// equal-power crossfade sweeps smoothly, one step per sample. Two earlier approaches clicked
|
||||
/// here when the crossfade legs are decorrelated and full-scale (a wet-only pitch shifter such as
|
||||
/// the Whammy swapping against the dry note; masked when wet ≈ dry): a one-pole `Lag`, whose
|
||||
/// exponential curve is front-loaded (steepest slope at the very start); and a block-rate slew,
|
||||
/// which steps only once per audio block — at the engine's 512-sample block a short fade is just
|
||||
/// a few coarse jumps, each its own click. An audio-rate linear slew has neither flaw.
|
||||
/// Overridable for pedals needing a gentler fade.
|
||||
open var bypassFadeTime: Double { 0.03 }
|
||||
|
||||
/// Lower bound the effective fade time is clamped to before taking its reciprocal for the slew
|
||||
/// rate. Guards against an override returning `0` (reciprocal `.infinity` → instantaneous slew,
|
||||
/// which reintroduces the click this fade removes) or a negative value (which would invert the
|
||||
/// slew). One sample at 48 kHz, so a legitimate small fade is left untouched.
|
||||
private let minBypassFadeTime: Double = 1.0 / 48_000.0
|
||||
|
||||
// Bipolar-span constant used to remap a [0, 1] value to [-1, +1]
|
||||
// for CrossFade's equal-power pan parameter.
|
||||
@@ -177,6 +254,52 @@ open class Pedal: SynthesizerBase {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Secondary "advanced" knobs that read best tucked behind a pop-over rather than on the pedal
|
||||
/// face — deep-cut controls a player reaches for occasionally, not while performing (e.g. an
|
||||
/// amp's power-amp Sag / Bias / Bias X). When non-empty the pedal card shows a small button that
|
||||
/// presents these in a popover; when empty no button is drawn. Defaults to empty.
|
||||
///
|
||||
/// These are ordinary live `@UIParam` knobs — they round-trip through `PedalState` and are not
|
||||
/// topology controls (no `rebuildsOnChange`).
|
||||
open var advancedKnobs: [PedalKnob] {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Current values of every ``effectSelectors`` and ``effectSwitches`` entry flagged
|
||||
/// `rebuildsOnChange` — the controls whose choice changes the graph topology (e.g. a cabinet
|
||||
/// voice or a clean/drive channel). A lightweight recall compares this before/after applying a
|
||||
/// snapshot to decide whether the board must be rebuilt (a plain node write does not re-enter
|
||||
/// `effect(_:)`). Empty for pedals with no such controls.
|
||||
public var rebuildTopologyValues: [Double] {
|
||||
// Sanitize non-finite to a fixed sentinel: the before/after compare in a recall uses `!=`,
|
||||
// and `NaN != NaN` would force a spurious rebuild on every recall.
|
||||
let selectorValues: [Double] = effectSelectors
|
||||
.filter { $0.rebuildsOnChange }
|
||||
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||
let switchValues: [Double] = effectSwitches
|
||||
.filter { $0.rebuildsOnChange }
|
||||
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||
return selectorValues + switchValues
|
||||
}
|
||||
|
||||
/// Effect-specific transport controls, rendered as a row directly below the knobs — above
|
||||
/// ``effectButtons``. Use for the persistent state toggles and transport stops that read as
|
||||
/// a group distinct from the momentary "do it now" actions (e.g. a looper's Loop / Stop /
|
||||
/// Cue Stop / Reverse). Defaults to empty; a pedal with none simply skips the row.
|
||||
open var effectTransportButtons: [PedalButton] {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Effect-specific action buttons for this pedal, rendered as a row of stomp-style
|
||||
/// buttons beneath the transport row.
|
||||
///
|
||||
/// Override in subclasses to publish momentary actions (e.g. "Record / Stop", "Reset")
|
||||
/// that need a non-RT side effect beyond writing a single parameter value — see
|
||||
/// ``PedalButton``. Defaults to empty.
|
||||
open var effectButtons: [PedalButton] {
|
||||
[]
|
||||
}
|
||||
|
||||
/// All knobs a generic UI should render for this pedal: effect-specific knobs
|
||||
/// first, then the common `mix` and `level` knobs. The `bypass` parameter is
|
||||
/// surfaced separately as a header toggle, not as a knob.
|
||||
@@ -187,6 +310,81 @@ open class Pedal: SynthesizerBase {
|
||||
]
|
||||
}
|
||||
|
||||
/// Every continuous control on this pedal that a MIDI Control Change can drive — the pedal's
|
||||
/// knobs (effect knobs + Mix + Level), then its vertical-fader sliders, then its advanced
|
||||
/// (pop-over) knobs. Discrete controls (switches, stepped selectors) are excluded; they suit
|
||||
/// Program Change toggles, not CC sweeps.
|
||||
///
|
||||
/// Ordering is stable — knobs, then sliders, then advanced knobs (appended last so existing
|
||||
/// index-addressed CC bindings keep resolving to the same control across launches). Used by MIDI
|
||||
/// mapping.
|
||||
public var ccMappableControls: [PedalControl] {
|
||||
let knobControls: [PedalControl] = knobs.map {
|
||||
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||
}
|
||||
let sliderControls: [PedalControl] = effectSliders.map {
|
||||
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||
}
|
||||
let advancedControls: [PedalControl] = advancedKnobs.map {
|
||||
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||
}
|
||||
return knobControls + sliderControls + advancedControls
|
||||
}
|
||||
|
||||
// MARK: - Tempo sync
|
||||
|
||||
/// Parameters this pedal exposes to tempo sync (delay times, LFO rates). Empty by default —
|
||||
/// override in subclasses whose time- or rate-based parameters can lock to the tempo.
|
||||
///
|
||||
/// Each descriptor's ``TempoSyncableParam/key`` must be unique within the pedal and stable
|
||||
/// across versions (it is the persistence key). Order is the order the sync controls appear.
|
||||
open var tempoSyncableParams: [TempoSyncableParam] {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Recomputes and writes every parameter currently locked to a note division, from the shared
|
||||
/// clock's tempo. Main-thread only — writing a `@UIParam` is the same path as a knob turn.
|
||||
///
|
||||
/// A no-op when no clock is injected. Free parameters are left untouched. A synced value that
|
||||
/// falls outside the parameter's range (a long division past a delay's maximum time) is clamped.
|
||||
/// Called by `ShoeGaze` whenever the tempo changes and whenever a parameter's sync state changes.
|
||||
public func applyTempoSync() {
|
||||
guard let clock: LyrebirdClock = clock else { return }
|
||||
let bpm: Double = clock.bpm
|
||||
guard bpm > 0 else { return }
|
||||
for param: TempoSyncableParam in tempoSyncableParams {
|
||||
guard case .division(let division) = tempoSync[param.key] ?? .free else { continue }
|
||||
param.node.update(param.value(for: division, bpm: bpm).value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets one parameter's sync state and immediately recomputes it. Pass ``TempoSync/free`` to
|
||||
/// return the parameter to knob control (its value stays at the last synced number until the
|
||||
/// knob moves it), or `.division(_:)` to lock it to a note value of the live tempo.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - sync: The new sync state.
|
||||
/// - key: The ``TempoSyncableParam/key`` of the parameter to update.
|
||||
public func setSync(_ sync: TempoSync, for key: String) {
|
||||
tempoSync[key] = sync
|
||||
tempoSyncRevision.bump()
|
||||
applyTempoSync()
|
||||
}
|
||||
|
||||
/// Whether `node` backs a tempo-syncable parameter currently locked to a note division.
|
||||
///
|
||||
/// Used by MIDI to leave a synced parameter alone: its value is derived from the tempo, so a CC
|
||||
/// write would be immediately overwritten on the next tempo change. Matches by node identity, so
|
||||
/// it stays correct regardless of control ordering. Returns `false` for a free or non-syncable node.
|
||||
public func isNodeTempoSynced(_ node: UIParamNode) -> Bool {
|
||||
for param: TempoSyncableParam in tempoSyncableParams where param.node === node {
|
||||
if case .division = tempoSync[param.key] ?? .free {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// MARK: - Subclass hook
|
||||
|
||||
/// Returns the processed (wet) mono signal for this pedal.
|
||||
@@ -236,7 +434,7 @@ open class Pedal: SynthesizerBase {
|
||||
/// Builds the signal graph for one channel: dry → wet/dry blend → bypass switch → × level.
|
||||
///
|
||||
/// Returns the final post-`level` source for the channel. The `mix`, `bypass`, and `level`
|
||||
/// `@UIParam` nodes are shared across channels; each channel gets its own `Lag.Control`
|
||||
/// `@UIParam` nodes are shared across channels; each channel gets its own `Slew.Audio`
|
||||
/// for the bypass crossfade so smoothing is per-channel state driven by the same target.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -257,14 +455,25 @@ open class Pedal: SynthesizerBase {
|
||||
pan: mixPan
|
||||
)
|
||||
|
||||
// Smooth bypass transitions with a 20 ms lag to prevent clicks.
|
||||
let bypassLagged: Lag.Control = Lag.Control(
|
||||
// Smooth bypass transitions with a linear crossfade to prevent clicks. The slew runs at
|
||||
// AUDIO rate, not control rate: a block-rate smoother takes one step per audio block, so at
|
||||
// the engine's 512-sample block a short fade is only a handful of coarse steps — each a
|
||||
// click of its own. `Slew.Audio` ramps per sample, so the fade is smooth regardless of
|
||||
// block size. Linear slope (not a front-loaded one-pole lag) keeps it click-free even when
|
||||
// the two legs are decorrelated and full-scale, as for a wet-only pitch shifter.
|
||||
// Rate is in bypass-units per second: 0 → 1 traverses in exactly `bypassFadeTime` seconds.
|
||||
// Clamp to a positive floor first — a subclass override returning 0 or negative would
|
||||
// otherwise yield an infinite or inverted slew rate (see `minBypassFadeTime`).
|
||||
let effectiveFadeTime: Double = max(bypassFadeTime, minBypassFadeTime)
|
||||
let bypassFadeRate: Double = 1.0 / effectiveFadeTime
|
||||
let bypassSlewed: Slew.Audio = Slew.Audio(
|
||||
input: $bypass,
|
||||
time: bypassLagTime
|
||||
up: bypassFadeRate,
|
||||
dn: bypassFadeRate
|
||||
)
|
||||
|
||||
// Map bypass [0, 1] → pan [-1, +1]: −1 = blended (engaged), +1 = dry (bypassed).
|
||||
let bypassPan: any ValidGeneratorInput = (bypassLagged * bipolarSpan) - bipolarOffset
|
||||
let bypassPan: any ValidGeneratorInput = (bypassSlewed * bipolarSpan) - bipolarOffset
|
||||
|
||||
// Equal-power crossfade: engaged → blended; bypassed → dry.
|
||||
let switched: CrossFade.Audio = CrossFade.Audio(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
@@ -59,6 +60,10 @@ public final class PedalBoard {
|
||||
|
||||
private let engine: SynthesisEngine
|
||||
|
||||
/// Shared tempo clock, forwarded to each pedal in `add(_:)` so tempo-aware pedals (the
|
||||
/// looper) can quantize to beats. `nil` for boards created without one.
|
||||
private let clock: LyrebirdClock?
|
||||
|
||||
/// The bus that feeds the first pedal in the chain.
|
||||
public let headBus: AudioBus
|
||||
|
||||
@@ -89,6 +94,11 @@ public final class PedalBoard {
|
||||
/// call chains the first pedal after this node automatically (no `after:` arg needed).
|
||||
public internal(set) var headInputNode: (any Synthesizer)?
|
||||
|
||||
/// Stable identity for this board, persisted in ``BoardState`` and used by MIDI bindings to
|
||||
/// address the board by id rather than by position. Defaults to a fresh `UUID`; a rebuild from
|
||||
/// a saved rig restores the saved id, so a board keeps its identity across edits and reorders.
|
||||
public internal(set) var id: UUID = UUID()
|
||||
|
||||
/// Display label for the board, shown in the UI. Defaults to `"Board"`; `ShoeGaze`
|
||||
/// assigns a numbered label (`"Board 1"`, `"Board 2"`, …) when it creates the board.
|
||||
public var label: String = "Board"
|
||||
@@ -105,6 +115,22 @@ public final class PedalBoard {
|
||||
/// `nil` until `finalizeBoard(_:)`.
|
||||
public internal(set) var crossfadeTimeNode: UIParamNode?
|
||||
|
||||
/// The live per-board full-bypass `UIParamNode` (`0` = engaged, `1` = dry passthrough).
|
||||
/// `nil` until `finalizeBoard(_:)`. Driven by `ShoeGaze.setBoard(_:bypassed:)`.
|
||||
public internal(set) var boardBypassNode: UIParamNode?
|
||||
|
||||
/// The live rig-wide full-bypass `UIParamNode` (`0` = engaged, `1` = dry passthrough),
|
||||
/// driven across every board by `ShoeGaze.setRigBypassed(_:)`. `nil` until `finalizeBoard(_:)`.
|
||||
public internal(set) var rigBypassNode: UIParamNode?
|
||||
|
||||
/// The live rig-wide output-volume `UIParamNode` ([0, 1]), driven across every board by
|
||||
/// `ShoeGaze.setRigVolume(_:)`. `nil` until `finalizeBoard(_:)`.
|
||||
public internal(set) var rigVolumeNode: UIParamNode?
|
||||
|
||||
/// The live rig-wide output-mute `UIParamNode` (`0` = audible, `1` = silenced), driven across
|
||||
/// every board by `ShoeGaze.setRigMuted(_:)`. `nil` until `finalizeBoard(_:)`.
|
||||
public internal(set) var rigMuteNode: UIParamNode?
|
||||
|
||||
/// The output master synth for this board. Set by `ShoeGaze.finalizeBoard(_:)`;
|
||||
/// used by `ShoeGaze.removeBoard(_:)` to tear down just this board's master.
|
||||
internal var outputMaster: BoardOutputMaster?
|
||||
@@ -137,9 +163,13 @@ public final class PedalBoard {
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - engine: The `SynthesisEngine` that will own the pedal nodes.
|
||||
/// - clock: Shared tempo clock forwarded to tempo-aware pedals (the looper) for
|
||||
/// beat-quantized transport. Optional; `nil` disables quantization for pedals on
|
||||
/// this board.
|
||||
/// - Throws: `BusAllocatorError.noFreeBus` if no mono audio bus is available.
|
||||
public init(engine: SynthesisEngine) throws {
|
||||
public init(engine: SynthesisEngine, clock: LyrebirdClock? = nil) throws {
|
||||
self.engine = engine
|
||||
self.clock = clock
|
||||
let head: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
self.headBus = head
|
||||
self.outputBus = head
|
||||
@@ -180,6 +210,8 @@ public final class PedalBoard {
|
||||
/// - `EngineAddError` if the engine rejects the add (e.g. queue full, double-add).
|
||||
public func add(_ pedal: Pedal, after predecessor: (any Synthesizer)? = nil) throws {
|
||||
pedal.sampleRate = engine.sampleRate
|
||||
pedal.hostEngine = engine
|
||||
pedal.clock = clock
|
||||
|
||||
// Each arm configures the pedal's buses, inserts it, advances the tail, and only then
|
||||
// records it in `pedals` — so a pedal is never tracked unless it was fully wired and
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// PedalButton.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one pedal button — a momentary action trigger or a
|
||||
/// node-bound toggle, rendered as a stomp-style button.
|
||||
///
|
||||
/// Where ``PedalSwitch`` describes a multi-position segmented control, `PedalButton`
|
||||
/// describes a single button in one of two styles:
|
||||
/// - `.momentary`: runs a closure on each press (e.g. "Record / Stop", "Reset"). Use this
|
||||
/// whenever pressing the button must also perform a non-RT side effect (clearing a
|
||||
/// buffer, requesting a recorder reset) beyond writing a single parameter value.
|
||||
/// - `.toggle`: flips a bound ``UIParamNode`` between `0` and `1` on each press, with no
|
||||
/// side effect required — appropriate only when the live audio graph itself reads the
|
||||
/// node continuously (so toggling the raw value is sufficient).
|
||||
///
|
||||
/// A `Pedal` publishes an array of these via ``Pedal/effectButtons`` so a generic
|
||||
/// pedalboard UI can render a footswitch-style button per action without knowing the
|
||||
/// concrete pedal type.
|
||||
public struct PedalButton {
|
||||
|
||||
/// Style of button behavior, mirroring `ParameterButton.Style` in `LyrebirdUI`.
|
||||
public enum Style: Equatable {
|
||||
/// Executes `action` on each press.
|
||||
case momentary
|
||||
/// Flips `node` between `0` and `1` on each press.
|
||||
case toggle
|
||||
}
|
||||
|
||||
/// Short label shown on the button (e.g. "Record", "Reset").
|
||||
public let label: String
|
||||
|
||||
/// Button behavior style.
|
||||
public let style: Style
|
||||
|
||||
/// The live parameter node this button toggles. Non-`nil` only for `.toggle` style.
|
||||
public let node: UIParamNode?
|
||||
|
||||
/// The action run on each press. Non-`nil` only for `.momentary` style.
|
||||
public let action: (() -> Void)?
|
||||
|
||||
/// Optional LED-indicator node for a `.momentary` button. When non-`nil`, the button is
|
||||
/// drawn in the same LED + footswitch style as a `.toggle` button, with the LED lit while
|
||||
/// this node reads `≥ 0.5` — letting a momentary action reflect a persistent state (e.g. a
|
||||
/// looper's Stop lit while stopped, Cue Stop lit while armed). `nil` renders a plain button.
|
||||
public let indicator: UIParamNode?
|
||||
|
||||
/// Optional live caption describing what the *next* press does, polled by the UI. When set,
|
||||
/// the button shows this instead of the static `label` — letting a state-driven control (the
|
||||
/// looper's Loop footswitch) read "Record" → "Set End" → "Overdub" → "Play" as the state
|
||||
/// changes. `nil` shows the static `label`.
|
||||
public let dynamicLabel: (() -> String)?
|
||||
|
||||
/// Creates a momentary action button.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: Short label shown on the button.
|
||||
/// - indicator: Optional state node driving an LED (see ``indicator``). Defaults to `nil`
|
||||
/// for a plain button.
|
||||
/// - dynamicLabel: Optional live caption describing the next press (see ``dynamicLabel``).
|
||||
/// - action: Closure run on each press.
|
||||
public init(
|
||||
label: String,
|
||||
indicator: UIParamNode? = nil,
|
||||
dynamicLabel: (() -> String)? = nil,
|
||||
action: @escaping () -> Void
|
||||
) {
|
||||
self.label = label
|
||||
self.style = .momentary
|
||||
self.node = nil
|
||||
self.action = action
|
||||
self.indicator = indicator
|
||||
self.dynamicLabel = dynamicLabel
|
||||
}
|
||||
|
||||
/// Creates a toggle button bound to a `UIParamNode`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: Short label shown on the button.
|
||||
/// - node: The `UIParamNode` projected value of an `@UIParam` property
|
||||
/// (`pedal.$loopOn`, `pedal.$reverse`, …).
|
||||
/// - dynamicLabel: Optional live caption describing the next press (see ``dynamicLabel``).
|
||||
public init(label: String, node: UIParamNode, dynamicLabel: (() -> String)? = nil) {
|
||||
self.label = label
|
||||
self.style = .toggle
|
||||
self.node = node
|
||||
self.action = nil
|
||||
self.indicator = nil
|
||||
self.dynamicLabel = dynamicLabel
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// PedalControl.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A continuous pedal control that can be driven by a MIDI Control Change — the common shape of a
|
||||
/// ``PedalKnob`` and a ``PedalSlider`` (a labelled `UIParamNode` with a value range).
|
||||
///
|
||||
/// Used by MIDI mapping to enumerate every CC-assignable control on a pedal uniformly, regardless of
|
||||
/// how the pedal chose to present it (rotary knob vs vertical fader). Discrete controls (switches,
|
||||
/// stepped selectors) are intentionally excluded — they suit momentary Program Change bindings, not
|
||||
/// continuous expression control.
|
||||
public struct PedalControl {
|
||||
|
||||
/// Short display label (e.g. `"Rate"`, `"Position"`).
|
||||
public let label: String
|
||||
|
||||
/// The live parameter node the CC drives.
|
||||
public let node: UIParamNode
|
||||
|
||||
/// Inclusive value range the control spans, in the parameter's own units.
|
||||
public let range: ClosedRange<Double>
|
||||
|
||||
/// Creates a pedal control descriptor.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: Short display label.
|
||||
/// - node: The live parameter node.
|
||||
/// - range: Inclusive value range in the parameter's own units.
|
||||
public init(label: String, node: UIParamNode, range: ClosedRange<Double>) {
|
||||
self.label = label
|
||||
self.node = node
|
||||
self.range = range
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one controllable pedal knob.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of a knob that snaps to a fixed set of labelled stops.
|
||||
@@ -49,20 +50,31 @@ public struct PedalSelectorKnob {
|
||||
/// contain at least two.
|
||||
public let stops: [Stop]
|
||||
|
||||
/// When `true`, committing a new stop asks the host to rebuild the board (as the Neural Amp
|
||||
/// model loader does) instead of relying on the live graph to react to the node value. Use for
|
||||
/// selectors whose choice changes the *graph topology* — e.g. a cabinet whose voice picks which
|
||||
/// single convolver is instantiated — rather than a value an always-running node reads live.
|
||||
/// Defaults to `false`.
|
||||
public let rebuildsOnChange: Bool
|
||||
|
||||
/// Creates a selector-knob descriptor.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: Short label shown beneath the knob.
|
||||
/// - node: The `UIParamNode` projected value of an `@UIParam` property (`pedal.$voice1`, …).
|
||||
/// - stops: Ordered stops, CCW → CW. At least two.
|
||||
/// - rebuildsOnChange: Ask the host to rebuild the board when a new stop is committed. Use for
|
||||
/// selectors that change graph topology. Defaults to `false`.
|
||||
public init(
|
||||
label: String,
|
||||
node: UIParamNode,
|
||||
stops: [Stop]
|
||||
stops: [Stop],
|
||||
rebuildsOnChange: Bool = false
|
||||
) {
|
||||
precondition(stops.count >= 2, "PedalSelectorKnob requires at least two stops")
|
||||
self.label = label
|
||||
self.node = node
|
||||
self.stops = stops
|
||||
self.rebuildsOnChange = rebuildsOnChange
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one continuous vertical pedal fader.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one multi-position pedal switch.
|
||||
@@ -49,6 +50,16 @@ public struct PedalSwitch {
|
||||
/// three-state switch. Must contain at least two options.
|
||||
public let options: [Option]
|
||||
|
||||
/// `true` when this switch controls a tempo-synced behaviour (e.g. the looper's
|
||||
/// Sync-to-Tempo mode). A generic UI can disable such switches — and the host can force them
|
||||
/// to their first (off) option — while the tempo indicator is turned off. Defaults to `false`.
|
||||
public let tempoDependent: Bool
|
||||
|
||||
/// When `true`, committing a new position asks the host to rebuild the board — for switches that
|
||||
/// change the *graph topology* (e.g. a clean/drive channel that adds or removes a gain stage),
|
||||
/// the same mechanism as ``PedalSelectorKnob/rebuildsOnChange``. Defaults to `false`.
|
||||
public let rebuildsOnChange: Bool
|
||||
|
||||
/// Creates a switch descriptor.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -56,14 +67,32 @@ public struct PedalSwitch {
|
||||
/// - node: The `UIParamNode` projected value of an `@UIParam` property
|
||||
/// (`pedal.$mode`, `pedal.$direction`, …).
|
||||
/// - options: Ordered switch positions, left to right. At least two.
|
||||
/// - tempoDependent: `true` if the switch depends on the tempo/clock. Defaults to `false`.
|
||||
/// - rebuildsOnChange: Ask the host to rebuild the board when a new position is committed. Use
|
||||
/// for switches that change graph topology (e.g. a channel switch). Defaults to `false`.
|
||||
public init(
|
||||
label: String,
|
||||
node: UIParamNode,
|
||||
options: [Option]
|
||||
options: [Option],
|
||||
tempoDependent: Bool = false,
|
||||
rebuildsOnChange: Bool = false
|
||||
) {
|
||||
precondition(options.count >= 2, "PedalSwitch requires at least two options")
|
||||
self.label = label
|
||||
self.node = node
|
||||
self.options = options
|
||||
self.tempoDependent = tempoDependent
|
||||
self.rebuildsOnChange = rebuildsOnChange
|
||||
}
|
||||
|
||||
/// The value of the next option after the one nearest `current`, wrapping to the first — so a
|
||||
/// momentary trigger (e.g. a MIDI switch) can oscillate through the positions on each press.
|
||||
public func nextValue(after current: Double) -> Double {
|
||||
guard !options.isEmpty else { return current }
|
||||
let currentIndex: Int = options.indices.min(by: {
|
||||
abs(options[$0].value - current) < abs(options[$1].value - current)
|
||||
}) ?? 0
|
||||
let nextIndex: Int = (currentIndex + 1) % options.count
|
||||
return options[nextIndex].value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,16 +44,46 @@ public struct PedalType: RawRepresentable, Hashable, Sendable {
|
||||
public extension PedalType {
|
||||
|
||||
// Drive & dynamics
|
||||
static let california = PedalType("California")
|
||||
static let british = PedalType("British")
|
||||
static let britishPlexi = PedalType("British Plexi")
|
||||
static let britishJTM = PedalType("British JTM")
|
||||
static let britishBluesbreaker = PedalType("British Bluesbreaker")
|
||||
static let britishMaster = PedalType("British Master")
|
||||
static let britishDual = PedalType("British Dual")
|
||||
static let boutiqueLead = PedalType("Boutique Lead")
|
||||
static let boutiqueOD = PedalType("Boutique OD")
|
||||
static let caliHiGain = PedalType("Cali Hi-Gain")
|
||||
static let command = PedalType("Command")
|
||||
static let citrus = PedalType("Citrus")
|
||||
static let sixtiesCombo = PedalType("Sixties Combo")
|
||||
static let magnaVibrato = PedalType("Magna Vibrato")
|
||||
static let anaheim = PedalType("Anaheim")
|
||||
static let modernHighGain = PedalType("Modern High-Gain")
|
||||
static let chime = PedalType("Chime")
|
||||
static let chimeFifteen = PedalType("Chime 15")
|
||||
static let chimeNormal = PedalType("Chime Normal")
|
||||
static let chimeBaby = PedalType("Chime Baby")
|
||||
static let fullertonReverb = PedalType("Fullerton Reverb")
|
||||
static let fullertonDeluxe = PedalType("Fullerton Deluxe")
|
||||
static let fullertonPrinceton = PedalType("Fullerton Ivy League")
|
||||
static let fullertonDrive = PedalType("Fullerton Drive")
|
||||
static let jazzClean = PedalType("Jazz Clean")
|
||||
static let chimeTopBoost = PedalType("Chime Top Boost")
|
||||
static let neuralAmp = PedalType("Neural Amp")
|
||||
static let overdrive = PedalType("Overdrive")
|
||||
static let distortion = PedalType("Distortion")
|
||||
static let fuzz = PedalType("Fuzz")
|
||||
static let sustainFuzz = PedalType("Sustain Fuzz")
|
||||
static let compressor = PedalType("Compressor")
|
||||
static let limiter = PedalType("Limiter")
|
||||
static let noiseGate = PedalType("Noise Gate")
|
||||
static let cabinet = PedalType("Cabinet")
|
||||
|
||||
// EQ & filter
|
||||
static let graphicEQ = PedalType("Graphic EQ")
|
||||
static let autoWah = PedalType("Auto-Wah")
|
||||
static let wah = PedalType("Wah")
|
||||
static let mutant = PedalType("Mutant")
|
||||
static let phaser = PedalType("Phaser")
|
||||
|
||||
@@ -63,27 +93,47 @@ public extension PedalType {
|
||||
static let chorus = PedalType("Chorus")
|
||||
static let flanger = PedalType("Flanger")
|
||||
static let vibrato = PedalType("Vibrato")
|
||||
static let vibe = PedalType("Vibe")
|
||||
static let rotary = PedalType("Rotary")
|
||||
static let ringModulator = PedalType("Ring Modulator")
|
||||
static let scriptPhaser = PedalType("Script Phaser")
|
||||
static let diffuser = PedalType("Diffuser")
|
||||
static let bitcrusher = PedalType("Bitcrusher")
|
||||
static let granulator = PedalType("Granulator")
|
||||
static let autoGranulator = PedalType("Auto Granulator")
|
||||
static let karplusResonator = PedalType("Karplus Resonator")
|
||||
|
||||
// Dynamics (additional)
|
||||
static let sustainer = PedalType("Sustainer")
|
||||
|
||||
// Gain (additional)
|
||||
static let volume = PedalType("Volume")
|
||||
|
||||
// Delay & reverb
|
||||
static let delay = PedalType("Delay")
|
||||
static let feedbackDelay = PedalType("Feedback Delay")
|
||||
static let multiTapDelay = PedalType("Multi-Tap Delay")
|
||||
static let pingPong = PedalType("Ping-Pong")
|
||||
static let reverseDelay = PedalType("Reverse Delay")
|
||||
static let dl4 = PedalType("DL4")
|
||||
static let reverb = PedalType("Reverb")
|
||||
static let shimmerReverb = PedalType("Shimmer Reverb")
|
||||
static let plateReverb = PedalType("Plate Reverb")
|
||||
static let roomReverb = PedalType("Room Reverb")
|
||||
static let springReverb = PedalType("Spring Reverb")
|
||||
static let reverseReverb = PedalType("Reverse Reverb")
|
||||
static let granularReverb = PedalType("Granular Reverb")
|
||||
static let freezVerb = PedalType("FreezVerb")
|
||||
static let tunedVerb = PedalType("TunedVerb")
|
||||
|
||||
// Pitch & octave
|
||||
static let octaveSplitter = PedalType("Octave Splitter")
|
||||
static let bassOctaver = PedalType("Bass Octaver")
|
||||
static let harmonizer = PedalType("Harmonizer")
|
||||
static let whammy = PedalType("Whammy")
|
||||
static let polyOctave = PedalType("Poly Octave")
|
||||
|
||||
// Looper
|
||||
static let looper = PedalType("Looper")
|
||||
static let tapeLooper = PedalType("Tape Looper")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
// AmpVoicePedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Shared base for the tube-amp voice pedals — the fixed-voicing amps and the full-surface amps
|
||||
/// (those adding onboard reverb / tremolo / chorus and switches via the hooks below).
|
||||
///
|
||||
/// Each concrete amp fixes one tone-stack ``ToneStackModel`` and adds one signature control, but
|
||||
/// shares the common chain built here:
|
||||
/// ```
|
||||
/// dry → inputShaping(_:) (subclass hook — e.g. bright switch; default identity)
|
||||
/// → TriodeStage(drive: gain) (preamp)
|
||||
/// → ToneStack(bass, mid, treble, model) (fixed per amp)
|
||||
/// → onboardEffects(_:) (subclass hook — e.g. reverb + tremolo; default identity)
|
||||
/// → powerAmpStage(_:) (power amp — two TriodeStage halves blended by
|
||||
/// Bias X; single-stage tone at biasX = 0)
|
||||
/// → shapeVoice(_:) (subclass signature filter)
|
||||
/// → applySag(_:) (shared power-supply Sag droop; identity at sag = 0)
|
||||
/// → ConvolutionReverb(cab IR) (speaker cabinet — voice-selectable, or None for a
|
||||
/// separate cab block; rebuild on change)
|
||||
/// → TriodeStage(bias: 0) → Clip(±1) (output soft-limit + hard safety ceiling — always on)
|
||||
/// ```
|
||||
/// Fully wet (the amp replaces the dry signal); `Level` is the master. Double-width amp-head card.
|
||||
///
|
||||
/// The `tanh` output stage models output-transformer / speaker compression: a real amp has no
|
||||
/// brickwall, and its analog output can't digital-clip. Small signals pass at ~unit gain (clean
|
||||
/// playing largely intact); peaks soft-limit toward ±1, adding gentle output compression. Because
|
||||
/// that soft-limit sits *after* the cab (the overshoot it guards is a digital convolution /
|
||||
/// oversampling artifact, not literal circuit order) and the `tanh`'s own DC-blocker can leave a
|
||||
/// sub-percent overshoot, a final `Clip(±1)` hard-clamps the residue so the amp stage never emits a
|
||||
/// sample past ±1. At the normal master `Level` (≤ 1) that ceiling carries through to the output.
|
||||
///
|
||||
/// Subclasses override ``toneStackModel``, ``summaryText``, ``signatureKnobs``, and
|
||||
/// ``shapeVoice(_:)``, and may set a voice-appropriate default `gain` in their `init`.
|
||||
open class AmpVoicePedal: Pedal {
|
||||
|
||||
// MARK: - Common parameters
|
||||
|
||||
/// Preamp **Gain** dial in `[1, 11]` (yes, it goes to eleven). Mapped to the tube-drive range
|
||||
/// `[1, 30]` through a musical exponential taper — see ``taperedDrive(_:)`` — so low settings give
|
||||
/// fine control and the top of the dial pushes hard into saturation.
|
||||
@UIParam public var gain: Double = 6.27
|
||||
/// Tone-stack bass control in [0, 1].
|
||||
@UIParam public var bass: Double = 0.5
|
||||
/// Tone-stack mid control in [0, 1].
|
||||
@UIParam public var mid: Double = 0.5
|
||||
/// Tone-stack treble control in [0, 1].
|
||||
@UIParam public var treble: Double = 0.6
|
||||
/// Selected cabinet voice as an index into `CabinetVoice.allCases`.
|
||||
@UIParam public var cab: Double = 0.0
|
||||
/// Power-amp **Sag** in `[0, 1]`: `0` = stiff (no droop), `1` = heavy power-supply sag/bloom.
|
||||
/// Surfaced in the advanced pop-over, not on the pedal face. See ``applySag(_:)``.
|
||||
@UIParam public var sag: Double = 0.0
|
||||
/// Power-amp **Bias** in `[0, 1]`, mapped to the power-amp `TriodeStage` grid bias. `0.5` = the
|
||||
/// neutral (symmetric) operating point; lower = colder (tighter, more odd harmonics), higher =
|
||||
/// hotter (warmer, more even harmonics). Surfaced in the advanced pop-over. See
|
||||
/// ``powerAmpBiasInput``.
|
||||
@UIParam public var bias: Double = 0.5
|
||||
/// Power-amp **Bias X** (bias balance) in `[0, 1]`, default `0` = balanced. At `0` the power amp
|
||||
/// is a single stage — the shipped tone, exactly. Turning it up spreads the two power-amp
|
||||
/// half-stages' bias operating points and averages them, re-shaping the saturation knee for a
|
||||
/// distinct power-amp character (named after the "bias balance" trim on amps that expose one).
|
||||
/// Surfaced in the advanced pop-over. See `powerAmpStage(_:)`.
|
||||
@UIParam public var biasX: Double = 0.0
|
||||
|
||||
// MARK: - Subclass configuration
|
||||
|
||||
/// The fixed tone-stack model for this amp voice. Subclasses override.
|
||||
open var toneStackModel: ToneStackModel { .fender }
|
||||
/// One-line description. Subclasses override.
|
||||
open var summaryText: String { "Tube amp." }
|
||||
/// The amp's signature knob(s), appended after Gain/Bass/Mid/Treble. Default none.
|
||||
open var signatureKnobs: [PedalKnob] { [] }
|
||||
|
||||
/// Applies the amp's signature post-power-amp shaping (e.g. a bright/presence shelf or a cut
|
||||
/// low-pass). Default: identity. Subclasses override.
|
||||
///
|
||||
/// - Parameter signal: The post-power-amp signal.
|
||||
/// - Returns: The shaped signal fed to the cabinet.
|
||||
open func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
signal
|
||||
}
|
||||
|
||||
/// Shaping applied to the dry input *before* the preamp — e.g. a bright-switch treble lift that
|
||||
/// hits the tubes pre-distortion. Default: identity. Subclasses override.
|
||||
///
|
||||
/// - Parameter signal: The dry input signal.
|
||||
/// - Returns: The shaped signal fed into the preamp.
|
||||
open func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
signal
|
||||
}
|
||||
|
||||
/// Onboard effects inserted *after* the tone stack and *before* the power amp — the slot a
|
||||
/// combo amp's built-in reverb and tremolo occupy. Default: identity. Subclasses override.
|
||||
///
|
||||
/// - Parameter signal: The post-tone-stack signal.
|
||||
/// - Returns: The signal fed into the power-amp stage.
|
||||
open func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
signal
|
||||
}
|
||||
|
||||
/// Depth scale for the shared ``tremolo(_:speed:depth:enabled:)`` helper — at full depth the
|
||||
/// unipolar sine swings over half the normalised range, so the peak gain is `1.0` and the trough
|
||||
/// is `1 − depth`.
|
||||
private static let tremoloDepthScale: Double = 0.5
|
||||
|
||||
/// A unipolar-sine tremolo: `signal ×` an LFO over `[1 − depth·enabled, 1]`. Returns a bit-exact
|
||||
/// pass-through (a constant-`1.0` LFO) when `depth·enabled == 0`, so a zeroed depth or a
|
||||
/// footswitch `enabled = 0` is a true identity. Shared by the combo amps' `onboardEffects(_:)`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - signal: The signal to amplitude-modulate.
|
||||
/// - speed: LFO rate in Hz.
|
||||
/// - depth: Modulation depth in `[0, 1]`.
|
||||
/// - enabled: Footswitch gate (`0` or `1`) multiplied into the depth.
|
||||
/// - Returns: The amplitude-modulated signal.
|
||||
func tremolo(
|
||||
_ signal: any ValidGeneratorInput,
|
||||
speed: any ValidGeneratorInput,
|
||||
depth: any ValidGeneratorInput,
|
||||
enabled: any ValidGeneratorInput
|
||||
) -> any ValidGeneratorInput {
|
||||
let swing: any ValidGeneratorInput = (depth * enabled) * AmpVoicePedal.tremoloDepthScale
|
||||
let lfo: OscSin.Audio = OscSin.Audio(freq: speed, mul: swing, add: 1.0 - swing)
|
||||
return signal * lfo
|
||||
}
|
||||
|
||||
/// Maps a `Master` knob `[0, 1]` to a power-amp drive range — the canonical body of a
|
||||
/// master-volume amp's ``powerAmpDriveInput`` override. Turning Master up drives the power-amp
|
||||
/// stage harder (real master-volume saturation, unlike `level`).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - master: The `Master` knob node (`[0, 1]`).
|
||||
/// - minDrive: Power-amp drive at `master = 0`.
|
||||
/// - maxDrive: Power-amp drive at `master = 1`.
|
||||
/// - Returns: The mapped drive to feed the power-amp stage.
|
||||
func masterDrive(
|
||||
_ master: any ValidGeneratorInput,
|
||||
minDrive: Double,
|
||||
maxDrive: Double
|
||||
) -> any ValidGeneratorInput {
|
||||
LinLin.Audio(master, inLo: 0.0, inHi: 1.0, outLo: minDrive, outHi: maxDrive)
|
||||
}
|
||||
|
||||
/// The preamp gain stage — the (post-`inputShaping`) input driven through the first tube stage
|
||||
/// at `Gain`. Default: one `TriodeStage`. A channel-switching amp overrides this to cascade an
|
||||
/// extra stage on its drive channel (call `super.preampStage(_:)` for the clean stage first).
|
||||
///
|
||||
/// - Parameter signal: The post-`inputShaping` input signal.
|
||||
/// - Returns: The preamp output fed into the tone stack.
|
||||
open func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: preampBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Maps a `Gain` / `Drive` dial `[1, 11]` to the tube-drive range `[dialDriveMin, dialDriveMax]`
|
||||
/// through an exponential (musical) taper: `drive = dialDriveMin · (dialDriveMax/dialDriveMin) ^
|
||||
/// ((dial − 1) / 10)`. A live node, so the dial stays a smooth knob. Every amp's preamp and
|
||||
/// drive-channel stage runs its dial through this so `1` is nearly clean, `11` is full saturation,
|
||||
/// and the useful grind spreads across the dial rather than bunching at the bottom.
|
||||
///
|
||||
/// - Parameter dial: A `[1, 11]` Gain/Drive knob node.
|
||||
/// - Returns: The mapped tube drive to feed a `TriodeStage`.
|
||||
func taperedDrive(_ dial: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
LinExp.Audio(dial, inLo: dialMin, inHi: dialMax, outLo: dialDriveMin, outHi: dialDriveMax)
|
||||
}
|
||||
|
||||
/// Drive into the power-amp `TriodeStage`. Defaults to the fixed power-amp drive. Two kinds of
|
||||
/// amp override it: a **master-volume** amp returns a live `Master` knob mapped to a drive range
|
||||
/// (turning Master up pushes the power-amp stage into saturation — the real master-volume
|
||||
/// behaviour, unlike `level`, which only attenuates the finished output); a **lower-headroom
|
||||
/// variant** returns a fixed value *higher* than the default to model an amp that breaks up
|
||||
/// earlier. Either way, higher drive = more power-amp saturation.
|
||||
open var powerAmpDriveInput: any ValidGeneratorInput { powerAmpDrive }
|
||||
|
||||
/// Oversampling factor for the power-amp stage — `2` or `4`. Any amp that drives the power amp
|
||||
/// harder than the default fixed value (a `Master` control, or a lower-headroom variant with a
|
||||
/// higher fixed drive) should override to `4` for more anti-alias headroom, since higher drive
|
||||
/// generates more high-order harmonics. Defaults to `2` (ample for the lightly-driven fixed
|
||||
/// power stage of the standard voices).
|
||||
open var powerAmpOversample: Int { 2 }
|
||||
|
||||
/// Grid bias fed to the power-amp `TriodeStage`, from the live `Bias` knob: `[0, 1]` mapped to
|
||||
/// `[coldPowerAmpBias, hotPowerAmpBias]`. The neutral `bias = 0.5` maps to `0.0`, so the default
|
||||
/// leaves the power-amp stage symmetric (unchanged from the old fixed bias).
|
||||
var powerAmpBiasInput: any ValidGeneratorInput {
|
||||
LinLin.Audio($bias, inLo: 0.0, inHi: 1.0, outLo: coldPowerAmpBias, outHi: hotPowerAmpBias)
|
||||
}
|
||||
|
||||
/// The power-amp stage. **Bias X** (``biasX``) spreads the two `TriodeStage` halves' bias
|
||||
/// operating points to `powerAmpBiasInput ± (biasX · biasXMaxSpread)` and averages them. At
|
||||
/// `biasX = 0` both halves share the base bias, so the average is bit-identical to a single stage
|
||||
/// (the shipped tone); turning `biasX` up widens the spread, re-shaping the saturation character.
|
||||
///
|
||||
/// > Note: a deliberate approximation — a *character* control on the single-ended power-stage
|
||||
/// > model, not a literal push-pull topology (which would re-voice every amp). It reduces to the
|
||||
/// > exact prior tone at `biasX = 0`. Both halves are always built, so an amp pays two oversampled
|
||||
/// > stages even at `biasX = 0` — a smooth, live knob was preferred over a rebuild-on-change
|
||||
/// > single-stage fast path.
|
||||
///
|
||||
/// - Parameter signal: The post-`onboardEffects` signal into the power amp.
|
||||
/// - Returns: The blended power-amp output.
|
||||
func powerAmpStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let imbalance: any ValidGeneratorInput = $biasX * biasXMaxSpread
|
||||
let hotHalf: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: powerAmpDriveInput,
|
||||
bias: powerAmpBiasInput + imbalance,
|
||||
oversample: powerAmpOversample
|
||||
)
|
||||
let coldHalf: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: powerAmpDriveInput,
|
||||
bias: powerAmpBiasInput - imbalance,
|
||||
oversample: powerAmpOversample
|
||||
)
|
||||
return (hotHalf + coldHalf) * powerAmpHalfBlend
|
||||
}
|
||||
|
||||
/// Applies power-supply **Sag**: an `AmplitudeFollower` on `signal` reduces gain as it gets loud
|
||||
/// (droop) and recovers slowly (bloom). `Sag` scales the depth; at `sag = 0` the droop is `0` and
|
||||
/// the gain is a constant `1.0` (an identity multiply), so a sag-less amp is unchanged.
|
||||
///
|
||||
/// The droop gain is clamped to `[sagGainFloor, 1]`: the envelope tracks a post-power-amp,
|
||||
/// post-`shapeVoice` signal that can exceed 1 (Presence/Depth shelves), so an unclamped
|
||||
/// `1 − sag·env` would go negative and phase-invert loud content instead of attenuating it.
|
||||
///
|
||||
/// - Parameter signal: The post-`shapeVoice` signal to apply sag to.
|
||||
/// - Returns: The sagged signal.
|
||||
func applySag(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: signal, attackTime: sagAttackSeconds, releaseTime: sagReleaseSeconds)
|
||||
let sagGain: any ValidGeneratorInput = Clip.Audio(
|
||||
1.0 - ($sag * envelope), lo: sagGainFloor, hi: 1.0)
|
||||
return signal * sagGain
|
||||
}
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let defaultMix: Double = 1.0
|
||||
/// Preamp grid bias — a little asymmetry for even-harmonic warmth.
|
||||
private let preampBias: Double = 0.2
|
||||
/// Oversampling factor for the preamp stage (4× — the preamp can be driven hard by `Gain`).
|
||||
let preampOversample: Int = 4
|
||||
/// Grid bias of a cascaded lead/drive `TriodeStage` — a little asymmetry for even-harmonic
|
||||
/// grind. Shared by the channel/master amps' cascaded ``preampStage(_:)`` overrides.
|
||||
let leadBias: Double = 0.15
|
||||
/// Generic `PedalSwitch` off / on values, shared by every amp that publishes switches.
|
||||
let switchOffValue: Double = 0.0
|
||||
let switchOnValue: Double = 1.0
|
||||
/// Gain/Drive dial endpoints and the tube-drive range they taper onto (see ``taperedDrive(_:)``).
|
||||
/// `11` is the top of the dial; `30` is the maximum tube drive it reaches. `dialDriveMin > 0` is
|
||||
/// required by `LinExp`.
|
||||
let dialMin: Double = 1.0
|
||||
let dialMax: Double = 11.0
|
||||
let dialDriveMin: Double = 1.0
|
||||
let dialDriveMax: Double = 30.0
|
||||
/// Fixed power-amp stage drive (gentler than the preamp).
|
||||
private let powerAmpDrive: Double = 1.5
|
||||
/// Power-amp grid bias at `bias = 0` (coldest) and `bias = 1` (hottest). Symmetric about `0`, so
|
||||
/// the neutral `bias = 0.5` maps to `0.0` — the old fixed power-amp bias — leaving every amp's
|
||||
/// default tone unchanged. Modest magnitude so the control colours the harmonics without
|
||||
/// drastically re-voicing the amp.
|
||||
private let coldPowerAmpBias: Double = -0.25
|
||||
private let hotPowerAmpBias: Double = 0.25
|
||||
/// Maximum push-pull bias imbalance at `biasX = 1` — the offset applied oppositely to the two
|
||||
/// power-amp half-stages. Modest so the control colours the harmonics without destabilising the amp.
|
||||
private let biasXMaxSpread: Double = 0.35
|
||||
/// Equal-weight blend of the two power-amp half-stages. `0.5·(hot + cold)` averages them, so at
|
||||
/// `biasX = 0` (identical halves) the result is bit-identical to a single stage.
|
||||
private let powerAmpHalfBlend: Double = 0.5
|
||||
/// Sag envelope-follower attack — moderately fast (the supply starts drooping under load).
|
||||
private let sagAttackSeconds: Double = 0.02
|
||||
/// Sag envelope-follower release — slow, so the sag lingers and blooms back (supply recovery).
|
||||
private let sagReleaseSeconds: Double = 0.30
|
||||
/// Lowest the sag gain can droop to (~-16 dB). Bounds sag depth and — crucially — keeps the gain
|
||||
/// strictly positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped
|
||||
/// `1 − sag·env` would go negative and phase-invert loud content instead of drooping.
|
||||
private let sagGainFloor: Double = 0.15
|
||||
private let cabinetMix: Double = 1.0
|
||||
/// Output soft-limit drive. `1.0` gives unit small-signal gain (clean playing untouched) with a
|
||||
/// hard `tanh` asymptote at ±1 — models output-transformer / speaker compression and keeps the
|
||||
/// amp from ever digital-clipping the DAC.
|
||||
private let outputStageDrive: Double = 1.0
|
||||
/// Symmetric output stage (no even-harmonic bias) — a pure `tanh` limiter, not a tube colour.
|
||||
private let outputStageBias: Double = 0.0
|
||||
/// 2× is enough: the cab low-pass already band-limits the signal feeding this stage.
|
||||
private let outputStageOversample: Int = 2
|
||||
/// Absolute digital ceiling. The `tanh` stage does the musical soft-limiting; this hard clamp
|
||||
/// only ever catches the sub-percent overshoot the oversampling filters and DC-blocker can leave
|
||||
/// just above ±1, guaranteeing the amp stage never emits a sample the DAC would clip.
|
||||
private let outputCeiling: Double = 1.0
|
||||
|
||||
let gainRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
let toneRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
/// Range for a signature control that maps [0, 1] (Bright / Presence / Cut amount).
|
||||
let signatureRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
/// Cab selector value for the "None (direct)" stop — no speaker convolution. Placed one past the
|
||||
/// last `CabinetVoice` index so every existing voice keeps its saved index (append-only).
|
||||
static let cabinetBypassValue: Double = Double(CabinetVoice.allCases.count)
|
||||
|
||||
private static let cabStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||
.enumerated()
|
||||
.map { (index: Int, voice: CabinetVoice) in
|
||||
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||
}
|
||||
+ [PedalSelectorKnob.Stop(title: "None (direct)", value: cabinetBypassValue)]
|
||||
|
||||
// MARK: - Chrome
|
||||
|
||||
/// The amp is fully wet (it replaces the dry signal); hide the Mix control.
|
||||
public override var showsMixControl: Bool { false }
|
||||
|
||||
/// Amps use a four-wide knob grid for their Gain/Bass/Mid/Treble + signature controls (the card
|
||||
/// width is sized to content — see `PedalView.enclosureWidth`).
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
public override var summary: String { summaryText }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates an amp voice pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - name: Display name (the amp voice, e.g. "California").
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
name: String,
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: name,
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: AmpVoicePedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Gain", node: $gain, range: gainRange),
|
||||
PedalKnob(label: "Bass", node: $bass, range: toneRange),
|
||||
PedalKnob(label: "Mid", node: $mid, range: toneRange),
|
||||
PedalKnob(label: "Treble", node: $treble, range: toneRange),
|
||||
] + signatureKnobs
|
||||
}
|
||||
|
||||
public override var effectSelectors: [PedalSelectorKnob] {
|
||||
[
|
||||
PedalSelectorKnob(
|
||||
label: "Cab", node: $cab, stops: AmpVoicePedal.cabStops, rebuildsOnChange: true),
|
||||
]
|
||||
}
|
||||
|
||||
/// Power-amp deep-cut controls, tucked behind the pedal card's advanced pop-over: **Sag**
|
||||
/// (power-supply droop/bloom), **Bias** (power-amp grid-bias operating point), and **Bias X**
|
||||
/// (power-amp bias balance). None is a topology control — all are live nodes that round-trip
|
||||
/// through the rig save format. Order is append-only (persisted positionally in `advancedValues`).
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sag", node: $sag, range: signatureRange),
|
||||
PedalKnob(label: "Bias", node: $bias, range: toneRange),
|
||||
PedalKnob(label: "Bias X", node: $biasX, range: signatureRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet (or None) → output
|
||||
/// soft-limit.
|
||||
///
|
||||
/// > Note: at most one `ConvolutionReverb` runs — only the voice named by the live `cab` selector
|
||||
/// > is instantiated, and the "None (direct)" stop instantiates none. The `cab` selector is
|
||||
/// > `rebuildsOnChange`, so switching cabs (or to/from None) rebuilds the board rather than
|
||||
/// > running every voice at once.
|
||||
///
|
||||
/// The output soft-limit (``outputLimit(_:)``) always runs, cabinet or not, so the ±1 ceiling
|
||||
/// holds even when the cabinet is bypassed for a separate downstream cab block.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The amped, (optionally) cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
cabinetAndLimit(preCabinetCore(dry))
|
||||
}
|
||||
|
||||
/// The mono pre-cabinet core: `inputShaping → preamp → tone stack → onboardEffects → power amp →
|
||||
/// shapeVoice`. Factored out of `effect(_:)` so a stereo (widener) amp can split into a stereo
|
||||
/// stage (e.g. a stereo chorus) between the core and a per-channel ``cabinetAndLimit(_:)``.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The post-power-amp, pre-cabinet mono signal.
|
||||
func preCabinetCore(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let preShaped: any ValidGeneratorInput = inputShaping(dry)
|
||||
let preamp: any ValidGeneratorInput = preampStage(preShaped)
|
||||
let toned: ToneStack = ToneStack(
|
||||
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
|
||||
let processed: any ValidGeneratorInput = onboardEffects(toned)
|
||||
let powerAmp: any ValidGeneratorInput = powerAmpStage(processed)
|
||||
return applySag(shapeVoice(powerAmp))
|
||||
}
|
||||
|
||||
/// True when the `Cab` selector is on the "None (direct)" stop — the amp emits its limited
|
||||
/// power-amp signal with **no** speaker convolution, so the player can place a separate cabinet
|
||||
/// block (the standalone `Cabinet` pedal, or a future IR loader) downstream. Read at board-build
|
||||
/// time; the selector is `rebuildsOnChange`, so toggling it rebuilds the graph.
|
||||
///
|
||||
/// > Warning: with no cabinet, the amp sounds raw and fizzy (the power-amp `tanh` with no speaker
|
||||
/// > low-pass) — expected; a cabinet is what tames the top end.
|
||||
var isCabinetBypassed: Bool {
|
||||
guard cab.isFinite else { return false }
|
||||
// Clamp in Double space before converting: a huge finite `cab` (from a corrupted/hand-edited
|
||||
// rig) would otherwise trap `Int(_:)` — same defense as `CabinetVoice.voice(atSelectorValue:)`.
|
||||
let bounded: Double = Swift.min(Swift.max(cab, 0.0), Double(CabinetVoice.allCases.count))
|
||||
return Int(bounded.rounded()) >= CabinetVoice.allCases.count
|
||||
}
|
||||
|
||||
/// The per-channel cabinet + output stage: cabinet convolver (or a straight pass at the "None"
|
||||
/// stop) → `tanh` soft-limit → `Clip(±1)` safety clamp. Applied once in mono, or once per channel
|
||||
/// by a widener amp.
|
||||
///
|
||||
/// - Parameter signal: The post-core signal for one channel.
|
||||
/// - Returns: The (optionally) cab-convolved, soft-limited, ceiling-clamped signal.
|
||||
func cabinetAndLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
outputLimit(cabinet(signal))
|
||||
}
|
||||
|
||||
/// The selected `CabinetVoice` speaker convolver, or `signal` unchanged when the `Cab` selector
|
||||
/// is on "None (direct)". Only the voice named by the live `cab` selector is instantiated, so at
|
||||
/// most one `ConvolutionReverb` runs.
|
||||
///
|
||||
/// - Parameter signal: The post-core signal for one channel.
|
||||
/// - Returns: The cab-convolved signal, or `signal` unchanged when the cabinet is bypassed.
|
||||
func cabinet(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
guard !isCabinetBypassed else { return signal }
|
||||
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cab)
|
||||
return ConvolutionReverb.Audio(
|
||||
input: signal,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate),
|
||||
mix: cabinetMix
|
||||
)
|
||||
}
|
||||
|
||||
/// The output soft-limit + hard `Clip(±1)` safety ceiling — **always** applied on the amp,
|
||||
/// cabinet or not, so the ±1 guarantee holds even at the "None (direct)" stop.
|
||||
///
|
||||
/// The `TriodeStage(bias: 0)` is a symmetric `tanh` output limiter: cab convolution and signature
|
||||
/// shelves can push peaks past ±1, which a real analog output soft-compresses rather than
|
||||
/// hard-clips. Unit small-signal gain keeps clean tones intact; peaks soft-limit toward ±1. The
|
||||
/// trailing `Clip(±1)` hard-clamps the sub-percent overshoot the `tanh`'s DC-blocker and the
|
||||
/// halfband filters can leave, so no sample can clip the DAC.
|
||||
///
|
||||
/// - Parameter signal: The (optionally cab-convolved) signal for one channel.
|
||||
/// - Returns: The soft-limited, ceiling-clamped signal.
|
||||
func outputLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let softLimited: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: outputStageDrive,
|
||||
bias: outputStageBias,
|
||||
oversample: outputStageOversample
|
||||
)
|
||||
return Clip.Audio(softLimited, lo: -outputCeiling, hi: outputCeiling)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// AnaheimAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American **hybrid combo** — the Anaheim voice (Music Man lineage): a solid-state-flavoured
|
||||
/// preamp into a tube power stage, with huge clean headroom, a **Bright** switch, a **Deep**
|
||||
/// low-end switch, and a built-in **Limiter**.
|
||||
///
|
||||
/// Distinct from the all-tube voices: the preamp stage runs symmetric (grid `bias 0`) — no
|
||||
/// even-harmonic tube warmth, for the cleaner/more clinical solid-state character — and a
|
||||
/// `LookAheadLimiter` (the amp's onboard limiter) can be switched into the output.
|
||||
///
|
||||
/// > Note: the aggressive hard-knee solid-state clipping when pushed is approximated here by the
|
||||
/// > symmetric preamp + high headroom; a true oversampled hard-clipper is a Lyrebird 1.7.x follow-up.
|
||||
public final class AnaheimAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Deep switch: `0` = flat, `1` = low-end resonance boost engaged.
|
||||
@UIParam public var deep: Double = 0.0
|
||||
/// Limiter footswitch: `1` = the built-in output limiter is engaged, `0` = bypassed.
|
||||
@UIParam public var limiter: Double = 1.0
|
||||
|
||||
/// Symmetric preamp bias (solid-state character — no even-harmonic tube warmth).
|
||||
private let ssPreampBias: Double = 0.0
|
||||
private let brightFreqHz: Double = 3200.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let brightSlope: Double = 1.0
|
||||
private let deepFreqHz: Double = 100.0
|
||||
private let deepMaxGainDb: Double = 6.0
|
||||
private let deepSlope: Double = 0.7
|
||||
/// Limiter ceiling when engaged — below full scale, so it actually tames peaks (a peak
|
||||
/// compressor, the amp's built-in limiter); when bypassed the ceiling is raised so it never acts.
|
||||
private let limiterOnCeiling: Double = 0.5
|
||||
private let limiterOffCeiling: Double = 10.0
|
||||
private let limiterLookAhead: Double = 0.005
|
||||
private let limiterRelease: Double = 0.050
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American hybrid combo — solid-state-flavoured clean, huge headroom, Bright / Deep / Limiter."
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Deep",
|
||||
node: $deep,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Limiter",
|
||||
node: $limiter,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates an Anaheim amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Anaheim", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.23 // huge clean headroom
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Symmetric (solid-state-flavoured) preamp stage — `bias 0`, no even-harmonic tube warmth.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: ssPreampBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// The built-in limiter, gated by the Limiter switch — placed *before* the power-amp stage (so
|
||||
/// it limits the driven preamp/tone-stack signal, which can exceed the ceiling, rather than a
|
||||
/// signal the power-amp `tanh` has already bounded). Off raises the ceiling so it never acts.
|
||||
///
|
||||
/// > Note: the `LookAheadLimiter` stays in the chain in both states (only its ceiling changes),
|
||||
/// > so the amp carries its ~5 ms look-ahead latency whether or not the Limiter is engaged —
|
||||
/// > a constant, not something the switch toggles.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let ceiling: LinLin.Audio = LinLin.Audio(
|
||||
$limiter, inLo: 0.0, inHi: 1.0, outLo: limiterOffCeiling, outHi: limiterOnCeiling)
|
||||
return LookAheadLimiter(
|
||||
in: signal,
|
||||
maxAmplitude: ceiling,
|
||||
lookAheadTime: limiterLookAhead,
|
||||
releaseTime: limiterRelease,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
}
|
||||
|
||||
/// Deep low-shelf (gated by the Deep switch), post power amp.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let deepGainDb: any ValidGeneratorInput = $deep * deepMaxGainDb
|
||||
return RBJLowShelf.Audio(input: signal, freq: deepFreqHz, gain: deepGainDb, slope: deepSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// BoutiqueAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Shared base for the boutique high-gain amps (Boutique Lead / Boutique OD) — a footswitchable
|
||||
/// Clean/Lead channel into a master-volume power section, with **Presence** (top-end) and **Depth**
|
||||
/// (low-end resonance) shaping.
|
||||
///
|
||||
/// The Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||||
/// `rebuildsOnChange` **Channel** switch, so only the selected channel is built. `Master` drives the
|
||||
/// power-amp stage via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``. Concrete voices override
|
||||
/// ``AmpVoicePedal/toneStackModel`` and gain defaults, and may extend the shaping (e.g. a mid boost).
|
||||
open class BoutiqueAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of top-end lift.
|
||||
@UIParam public var presence: Double = 0.4
|
||||
/// Depth amount in [0, 1] → 0…`depthMaxGainDb` of low-end resonance lift.
|
||||
@UIParam public var depth: Double = 0.3
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.77
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
private let presenceFreqHz: Double = 4500.0
|
||||
private let presenceMaxGainDb: Double = 8.0
|
||||
private let presenceSlope: Double = 0.7
|
||||
private let depthFreqHz: Double = 120.0
|
||||
private let depthMaxGainDb: Double = 6.0
|
||||
private let depthSlope: Double = 0.7
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||
PedalKnob(label: "Depth", node: $depth, range: signatureRange),
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Presence (top-end high-shelf) then Depth (low-end low-shelf), post power amp.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let presenceGainDb: LinLin.Audio = LinLin.Audio(
|
||||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||
let presenced: RBJHighShelf.Audio = RBJHighShelf.Audio(
|
||||
input: signal, freq: presenceFreqHz, gain: presenceGainDb, slope: presenceSlope)
|
||||
let depthGainDb: LinLin.Audio = LinLin.Audio(
|
||||
$depth, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: depthMaxGainDb)
|
||||
return RBJLowShelf.Audio(
|
||||
input: presenced, freq: depthFreqHz, gain: depthGainDb, slope: depthSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// BoutiqueLeadAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Boutique **super-lead** — the SLO-style high-gain singing lead: aggressive cascaded overdrive on
|
||||
/// the Lead channel, a Master volume, and Presence / Depth power-amp shaping.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` fixed to the Soldano tone stack, defaulting to a hot Lead drive.
|
||||
public final class BoutiqueLeadAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .soldano }
|
||||
public override var summaryText: String {
|
||||
"Boutique super-lead — aggressive cascaded high gain with Master, Presence, and Depth."
|
||||
}
|
||||
|
||||
/// Creates a Boutique Lead amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Boutique Lead", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
drive = 8.76 // hot singing lead
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// BoutiqueODAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Boutique **overdrive special** — the smooth D-style voice: a Fender-derived clean plus a fluid
|
||||
/// overdrive channel, a **Mid Boost** switch, a Master volume, and Presence / Depth shaping.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` on the smoother American tone stack. The Mid Boost adds a midrange peak
|
||||
/// (the D-style "PAB" character) on top of the base Presence/Depth shaping.
|
||||
public final class BoutiqueODAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
/// Mid Boost switch: `0` = flat, `1` = midrange peak engaged.
|
||||
@UIParam public var midBoost: Double = 0.0
|
||||
|
||||
private let midBoostFreqHz: Double = 650.0
|
||||
private let midBoostMaxGainDb: Double = 6.0
|
||||
private let midBoostQ: Double = 1.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"Boutique overdrive special — smooth D-style OD with a Mid Boost, Master, Presence, and Depth."
|
||||
}
|
||||
|
||||
/// Base Channel switch plus the Mid Boost switch (compose `super`).
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Mid Boost",
|
||||
node: $midBoost,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Boutique OD amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Boutique OD", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
drive = 7.77
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
/// The base Presence/Depth shaping, plus a Mid Boost peak when the switch is engaged (its gain
|
||||
/// scales by the switch value, so Off is a true identity, live, no rebuild).
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shaped: any ValidGeneratorInput = super.shapeVoice(signal)
|
||||
let midGainDb: any ValidGeneratorInput = $midBoost * midBoostMaxGainDb
|
||||
return RBJPeakingEQ.Audio(input: shaped, freq: midBoostFreqHz, gain: midGainDb, q: midBoostQ)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// BritishAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British-voiced amp (mid-forward crunch) with a **Presence** lift and a **Master** volume.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch. The
|
||||
/// Master control drives the power-amp stage (via ``AmpVoicePedal/powerAmpDriveInput``), so raising
|
||||
/// it adds power-amp saturation — turn `Gain` up for preamp grind and use `Master` to set how hard
|
||||
/// that hits the power amp, the classic master-volume interplay.
|
||||
public final class BritishAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
|
||||
@UIParam public var presence: Double = 0.4
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`]. The
|
||||
/// default maps to ≈1.5 drive — the amp's prior fixed power-amp drive — so the out-of-box tone
|
||||
/// is unchanged; turn it up for power-amp saturation.
|
||||
@UIParam public var master: Double = 0.22
|
||||
|
||||
private let presenceFreqHz: Double = 4500.0
|
||||
private let presenceMaxGainDb: Double = 8.0
|
||||
private let shelfSlope: Double = 0.7
|
||||
/// Power-amp drive at `master = 0` — barely driven (cleanest power stage).
|
||||
private let masterMinDrive: Double = 0.5
|
||||
/// Power-amp drive at `master = 1` — hard into power-amp saturation.
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var summaryText: String {
|
||||
"British crunch — forward mids and bite, with Presence and a Master volume."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage: `[0, 1]` → `[masterMinDrive, masterMaxDrive]`.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
|
||||
/// 4× oversampling on the power-amp stage — Master can drive it well past the fixed value used
|
||||
/// by the non-master amps, so the extra anti-alias headroom keeps the added harmonics clean.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Creates a British amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 7.77 // crunch-leaning default
|
||||
cab = 1.0 // default to the British 4×12 cab
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: shelfSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// BritishBluesbreakerAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British non-master **2×12 combo** with onboard **tremolo** — the bluesbreaker voice: lower-power
|
||||
/// Marshall crunch that cleans up with the guitar volume, plus a bias-tremolo.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) that overlays a tremolo in the onboard-effects
|
||||
/// slot, with Speed / Intensity knobs and a Tremolo footswitch.
|
||||
public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||
@UIParam public var speed: Double = 4.0
|
||||
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
|
||||
@UIParam public var intensity: Double = 0.0
|
||||
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||
@UIParam public var tremoloEnabled: Double = 1.0
|
||||
|
||||
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"British 2×12 combo — bluesbreaker crunch with tremolo, Presence, and a Bright switch."
|
||||
}
|
||||
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
/// The base Bright switch plus a Tremolo footswitch (compose `super` so Bright stays in sync).
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Tremolo",
|
||||
node: $tremoloEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a British Bluesbreaker amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Bluesbreaker", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
cab = 1.0 // British 4×12 voice (combo 2×12 tonally close enough among our cabs)
|
||||
}
|
||||
|
||||
/// Tremolo (gated by the Tremolo footswitch), inserted after the tone stack.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Identity when depth·enabled == 0.
|
||||
tremolo(signal, speed: $speed, depth: $intensity, enabled: $tremoloEnabled)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// BritishComboAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Shared base for the British (Marshall-voiced) amps — the `.marshall` tone stack plus a common
|
||||
/// **Presence** lift (post-power-amp high-shelf) and a **Bright** switch (pre-preamp high-shelf).
|
||||
///
|
||||
/// The non-master voices (Plexi / JTM / Bluesbreaker) run a fixed power-amp drive — loudness comes
|
||||
/// from cranking `Gain`; the Bluesbreaker additionally overlays tremolo. The master-volume voices
|
||||
/// (British Master / British Dual) subclass this too, adding a `Master` (via
|
||||
/// ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``) and a cascaded lead ``preampStage(_:)``.
|
||||
///
|
||||
/// Distinct from ``BritishAmpPedal``, the standalone master-volume crunch voice.
|
||||
open class BritishComboAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
|
||||
@UIParam public var presence: Double = 0.4
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
|
||||
private let presenceFreqHz: Double = 4500.0
|
||||
private let presenceMaxGainDb: Double = 8.0
|
||||
private let presenceSlope: Double = 0.7
|
||||
private let brightFreqHz: Double = 3500.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let brightSlope: Double = 0.7
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[PedalKnob(label: "Presence", node: $presence, range: signatureRange)]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Presence: a post-power-amp high-shelf lift, `[0, 1]` → `[0, presenceMaxGainDb]` dB.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: presenceSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// BritishDualAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **dual-channel master-volume** — the 900/DSL-era Marshall: a footswitchable Clean/Lead
|
||||
/// channel, a Master volume, spring reverb, Presence, and a Bright switch. The modern high-gain
|
||||
/// British workhorse.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) that adds a `rebuildsOnChange` **Channel** switch —
|
||||
/// the Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||||
/// `Master` (power-amp drive), and spring reverb in the onboard-effects slot.
|
||||
public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.2
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
/// Channel-select threshold: `>= this` selects the Lead channel.
|
||||
private let channelThreshold: Double = 0.5
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"British dual-channel master-volume — Clean/Lead switching, reverb, Presence, and Bright."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
super.signatureKnobs + [
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Creates a British Dual amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Dual", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// BritishJTMAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British non-master **JTM** — the earliest Marshall, Bassman-derived: warmer and lower-gain than
|
||||
/// the plexi Super Lead, a rounder blues-rock crunch.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` with lower gain and a slightly darker top end.
|
||||
public final class BritishJTMAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
public override var summaryText: String {
|
||||
"British non-master combo — warm, lower-gain JTM crunch with Presence and Bright."
|
||||
}
|
||||
|
||||
/// Creates a British JTM amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British JTM", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73 // warmer, lower-gain than the plexi
|
||||
treble = 0.5 // a shade rounder on top
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||