Compare commits
13 Commits
284093c302
...
v1.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
| b6a9dbbb91 | |||
| ef20a0eb95 | |||
| aeab19236b | |||
| 8c4b2ab1e7 | |||
| 3322400b7c | |||
| 9e09eb284a | |||
| 657ecaf4f4 | |||
| 957a99d802 | |||
| e839447aa8 | |||
| a21121e120 | |||
| bc6e6286df | |||
| bc7157b7ee | |||
| 7d3bafe200 |
@@ -176,7 +176,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
MARKETING_VERSION = 1.1.1;
|
MARKETING_VERSION = 1.2.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
MARKETING_VERSION = 1.1.1;
|
MARKETING_VERSION = 1.2.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|||||||
@@ -154,6 +154,57 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Opens `.shoegaze` files handed to the app by Finder, AirDrop, "Open With", or a double-click.
|
||||||
|
///
|
||||||
|
/// Rig documents are imported into the library (they appear in the sidebar, ready to load);
|
||||||
|
/// board documents are surfaced with a note that boards are opened from a rig's board editor.
|
||||||
|
func application(_ application: NSApplication, open urls: [URL]) {
|
||||||
|
for url: URL in urls {
|
||||||
|
openShoeGazeDocument(at: url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads and imports a single `.shoegaze` document, reporting the outcome to the user.
|
||||||
|
private func openShoeGazeDocument(at url: URL) {
|
||||||
|
// A LaunchServices-supplied URL is security-scoped; start access to read it.
|
||||||
|
let scoped: Bool = url.startAccessingSecurityScopedResource()
|
||||||
|
defer { if scoped { url.stopAccessingSecurityScopedResource() } }
|
||||||
|
do {
|
||||||
|
let data: Data = try Data(contentsOf: url)
|
||||||
|
let document: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data)
|
||||||
|
if document.rigEntries?.isEmpty == false {
|
||||||
|
let added: Int = try library.importArchive(from: data)
|
||||||
|
presentOpenInfo(
|
||||||
|
title: added == 1 ? "Rig Imported" : "Rigs Imported",
|
||||||
|
message: added == 1
|
||||||
|
? "Added 1 rig to your library. Select it in the Rigs sidebar to load it."
|
||||||
|
: "Added \(added) rigs to your library. Select one in the Rigs sidebar to load it."
|
||||||
|
)
|
||||||
|
} else if document.boardVersion != nil {
|
||||||
|
presentOpenInfo(
|
||||||
|
title: "Board Document",
|
||||||
|
message: "This file is a single board. Open a rig, then load the board from the "
|
||||||
|
+ "board editor's Versions menu."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
presentOpenInfo(
|
||||||
|
title: "Couldn’t Open File",
|
||||||
|
message: "“\(url.lastPathComponent)” is not a readable ShoeGaze document."
|
||||||
|
)
|
||||||
|
print("[ShoeGazeBuilder] open document failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shows a one-button informational alert for a document-open outcome.
|
||||||
|
private func presentOpenInfo(title: String, message: String) {
|
||||||
|
let alert: NSAlert = NSAlert()
|
||||||
|
alert.messageText = title
|
||||||
|
alert.informativeText = message
|
||||||
|
alert.addButton(withTitle: "OK")
|
||||||
|
alert.runModal()
|
||||||
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ notification: Notification) {
|
func applicationWillTerminate(_ notification: Notification) {
|
||||||
RigStore.save(shoeGaze)
|
RigStore.save(shoeGaze)
|
||||||
// Ensure any in-flight background rig-library writes finish before exit.
|
// Ensure any in-flight background rig-library writes finish before exit.
|
||||||
@@ -267,20 +318,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
|
|
||||||
@objc private func exportArchiveAction(_ sender: Any?) {
|
@objc private func exportArchiveAction(_ sender: Any?) {
|
||||||
let panel: NSSavePanel = NSSavePanel()
|
let panel: NSSavePanel = NSSavePanel()
|
||||||
panel.allowedContentTypes = [.json]
|
panel.allowedContentTypes = [.shoeGaze]
|
||||||
panel.nameFieldStringValue = "\(AppDelegate.defaultArchiveFileName).json"
|
panel.nameFieldStringValue =
|
||||||
|
"\(AppDelegate.defaultArchiveFileName).\(ShoeGazeDocument.fileExtension)"
|
||||||
panel.canCreateDirectories = true
|
panel.canCreateDirectories = true
|
||||||
let rigLibrary: RigLibraryStore = library
|
let rigLibrary: RigLibraryStore = library
|
||||||
panel.begin { response in
|
panel.begin { response in
|
||||||
guard response == .OK, let url: URL = panel.url else { return }
|
guard response == .OK, let url: URL = panel.url else { return }
|
||||||
do { try rigLibrary.exportArchiveData().write(to: url, options: .atomic) }
|
do { try rigLibrary.exportDocumentData().write(to: url, options: .atomic) }
|
||||||
catch { print("[ShoeGazeBuilder] export archive failed: \(error)") }
|
catch { print("[ShoeGazeBuilder] export library failed: \(error)") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func importArchiveAction(_ sender: Any?) {
|
@objc private func importArchiveAction(_ sender: Any?) {
|
||||||
let panel: NSOpenPanel = NSOpenPanel()
|
let panel: NSOpenPanel = NSOpenPanel()
|
||||||
panel.allowedContentTypes = [.json]
|
// Accept the .shoegaze document plus legacy plain-JSON archives.
|
||||||
|
panel.allowedContentTypes = [.shoeGaze, .json]
|
||||||
panel.canChooseDirectories = false
|
panel.canChooseDirectories = false
|
||||||
panel.allowsMultipleSelection = false
|
panel.allowsMultipleSelection = false
|
||||||
let rigLibrary: RigLibraryStore = library
|
let rigLibrary: RigLibraryStore = library
|
||||||
@@ -290,7 +343,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
let data: Data = try Data(contentsOf: url)
|
let data: Data = try Data(contentsOf: url)
|
||||||
_ = try rigLibrary.importArchive(from: data)
|
_ = try rigLibrary.importArchive(from: data)
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilder] import archive failed: \(error)")
|
print("[ShoeGazeBuilder] import library failed: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.3.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
@@ -40,5 +40,44 @@
|
|||||||
<string>Any</string>
|
<string>Any</string>
|
||||||
</dict>
|
</dict>
|
||||||
</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>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>shoegaze</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<array>
|
||||||
|
<string>application/json</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.3.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
@@ -53,5 +53,44 @@
|
|||||||
<string>Any</string>
|
<string>Any</string>
|
||||||
</dict>
|
</dict>
|
||||||
</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>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>shoegaze</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<array>
|
||||||
|
<string>application/json</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ struct ShoeGazeBuilderiOSApp: App {
|
|||||||
.task { await model.startLibrary() }
|
.task { await model.startLibrary() }
|
||||||
}
|
}
|
||||||
.onDisappear { model.stop() }
|
.onDisappear { model.stop() }
|
||||||
|
.onOpenURL { url in model.importDocument(at: url) }
|
||||||
}
|
}
|
||||||
.onChange(of: scenePhase) { _, phase in
|
.onChange(of: scenePhase) { _, phase in
|
||||||
// Persist the rig whenever the app leaves the foreground.
|
// Persist the rig whenever the app leaves the foreground.
|
||||||
|
|||||||
@@ -93,6 +93,25 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
library.flushPendingWrites()
|
library.flushPendingWrites()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Document open
|
||||||
|
|
||||||
|
/// Imports a `.shoegaze` file opened from Files, AirDrop, or another app into the rig library.
|
||||||
|
/// Rig documents add their rigs (they appear in the sidebar, ready to load); board documents are
|
||||||
|
/// ignored here. Returns the number of rigs added.
|
||||||
|
@discardableResult
|
||||||
|
func importDocument(at url: URL) -> Int {
|
||||||
|
// A document opened from outside the sandbox is security-scoped; start access to read it.
|
||||||
|
let scoped: Bool = url.startAccessingSecurityScopedResource()
|
||||||
|
defer { if scoped { url.stopAccessingSecurityScopedResource() } }
|
||||||
|
do {
|
||||||
|
let data: Data = try Data(contentsOf: url)
|
||||||
|
return try library.importArchive(from: data)
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilderiOS] open document failed: \(error)")
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Audio session / engine construction
|
// MARK: - Audio session / engine construction
|
||||||
|
|
||||||
/// Activates the play-and-record audio session once. Idempotent; safe to call before each
|
/// Activates the play-and-record audio session once. Idempotent; safe to call before each
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ signal (no hardware needed) or on live guitar through an audio input.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **22 modeled pedals** across drive, dynamics, EQ/filter, modulation, delay/reverb, and
|
- **32 modeled pedals** across gain, dynamics, EQ/filter, modulation, pitch, delay, reverb, and
|
||||||
pitch — see the catalog below.
|
texture — see the catalog below.
|
||||||
- **Multi-board rigs** — build several boards and a board-mixer bar to **Solo** one (amp-channel
|
- **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.
|
||||||
- **Signal-flow editor** — drag pedals in from the palette; reorder, split into parallel or
|
- **Signal-flow editor** — drag pedals in from the palette; reorder, split into parallel or
|
||||||
stereo lanes, and merge back to mono.
|
stereo lanes, and merge back to mono.
|
||||||
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar; synced across
|
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar; synced across
|
||||||
your devices and both apps via iCloud, with JSON archive import/export for backup.
|
your devices and both apps via iCloud.
|
||||||
|
- **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.
|
- **Recording** — capture your output to timestamped files.
|
||||||
- **Test signal or live input** — a built-in arpeggiated test loop (shared across all boards so
|
- **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.
|
they stay phase-locked) or a hardware input channel.
|
||||||
@@ -29,11 +31,14 @@ signal (no hardware needed) or on live guitar through an audio input.
|
|||||||
|
|
||||||
| Category | Pedals |
|
| Category | Pedals |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Drive & dynamics | Overdrive, Fuzz, Compressor, Sustainer, Limiter, Noise Gate |
|
| Gain | Overdrive, Distortion, Fuzz |
|
||||||
| EQ & filter | Graphic EQ, Auto-Wah, Mutant, Phaser |
|
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate |
|
||||||
| Modulation | Tremolo, Modulation, Chorus, Ring Modulator, Diffuser |
|
| EQ & filter | Graphic EQ, Auto-Wah, Mutant |
|
||||||
| Delay & reverb | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverb |
|
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Rotary, Ring Modulator |
|
||||||
| Pitch & octave | Octave Splitter, Bass Octaver |
|
| 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 |
|
||||||
|
|
||||||
Every pedal exposes its parameters as knobs/switches and round-trips through the rig save format.
|
Every pedal exposes its parameters as knobs/switches and round-trips through the rig save format.
|
||||||
|
|
||||||
|
|||||||
+48
@@ -1,5 +1,53 @@
|
|||||||
# Releases
|
# Releases
|
||||||
|
|
||||||
|
## 1.3.0 — 2026-06-28
|
||||||
|
|
||||||
|
### Sharing — the `.shoegaze` document type
|
||||||
|
- New shareable file type **`.shoegaze`** (`net.realizedsound.shoegaze`, conforming to
|
||||||
|
`public.json`) registered by every app, so the system associates the file with ShoeGaze for
|
||||||
|
Open and Share.
|
||||||
|
- **Share a rig** from the library sidebar (per-rig) and **share a saved board** from the board
|
||||||
|
editor's Versions menu, via the OS share sheet — AirDrop, Mail, Messages, Files. Local only; no
|
||||||
|
account or backend.
|
||||||
|
- Library **export/import migrated** to `.shoegaze`. A document wraps either a whole rig (or many)
|
||||||
|
or a single board; legacy archive and single-rig JSON files still import.
|
||||||
|
- Internal per-rig and board-version files stay app-private JSON — only the share/export surface
|
||||||
|
uses `.shoegaze`.
|
||||||
|
|
||||||
|
## 1.2.0 — 2026-06-28
|
||||||
|
|
||||||
|
### New pedals (catalog now 32)
|
||||||
|
- **Distortion** — mid-gain saturation between Overdrive and Fuzz.
|
||||||
|
- **Flanger** — sweeping comb-filter jet with feedback.
|
||||||
|
- **Vibrato** — pure pitch wobble, fully wet.
|
||||||
|
- **Rotary** — Leslie rotary-speaker: Doppler wobble + volume throb, two-speed with accel ramp.
|
||||||
|
- **Harmonizer** — two pitch-shifted harmony voices at fixed musical intervals (stepped knob).
|
||||||
|
- **Reverse Delay** — backward-tape segments with feedback trails.
|
||||||
|
- **Shimmer Reverb** — regenerative reverb whose tail climbs an octave as it sustains.
|
||||||
|
- **Bitcrusher** — sample-rate decimation + bit-depth reduction + tone.
|
||||||
|
- **Granulator** — stereo grain cloud, scattered across the field by Spread.
|
||||||
|
- **Auto Granulator** — granulator whose grain size tracks your dynamics (Response switch).
|
||||||
|
|
||||||
|
### Rig library (iCloud)
|
||||||
|
- Rigs are a managed **library** in the sidebar (New, Save, Save As, Duplicate, Rename, Delete,
|
||||||
|
Erase All), each holding multiple boards.
|
||||||
|
- **iCloud sync** across devices and both apps via a shared container, with a local fallback.
|
||||||
|
- **Archive** import/export bundles the whole library as one hand-editable JSON file (replaced the
|
||||||
|
old single-rig save/load); legacy single-rig files still import.
|
||||||
|
- macOS File menu: New Rig (⌘N), Save Rig (⌘S), Export / Import Archive (⌘E / ⌘I). Saves/loads run
|
||||||
|
off the main thread.
|
||||||
|
|
||||||
|
### Builder UI
|
||||||
|
- Reworked top layout (scope + CPU beside a stacked board-mixer / pedal-picker); **colour-coded**
|
||||||
|
pedal cards with a **filter-by-type** menu; routing cards in their own row.
|
||||||
|
- Dark color scheme pinned (fixes black-on-dark system controls on iOS); input-source picker
|
||||||
|
reflects the In channel count immediately; failed edits surface as alerts.
|
||||||
|
|
||||||
|
### Fixes / under the hood
|
||||||
|
- Granulators are now latency-free; Shimmer Reverb DC-blocked. New RT-safe generators
|
||||||
|
(`ReverseDelay`, `SampleRateDecimate`, `BitReduce`, `ShimmerReverb`, `StereoGranulator`) and a
|
||||||
|
reusable `PedalSelectorKnob`. 271 tests; RT-safety reviewed.
|
||||||
|
|
||||||
## 1.1.1 — 2026-06-26
|
## 1.1.1 — 2026-06-26
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|||||||
@@ -10,30 +10,20 @@ import Foundation // `cos`/`sin` for the init-time Hann table and per-grain pa
|
|||||||
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
|
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
|
||||||
private let stereoGranulatorZeroBlock: [Double] = makeSampleBuffer()
|
private let stereoGranulatorZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
/// Stereo input granulator: records the mono input into a circular buffer and replays it as a
|
/// Stereo input granulator (straight-through): windows and pans the **live** input directly,
|
||||||
/// cloud of overlapping Hann-windowed grains, each randomly panned across the stereo field by
|
/// without a delay/look-back buffer, so there is no latency.
|
||||||
/// `spread`.
|
|
||||||
///
|
///
|
||||||
/// Each grain is a unity-speed windowed copy of the most recent `grainSize` of audio (so the cloud
|
/// A pool of overlapping grain voices each apply a Hann envelope to the incoming sample and pan it
|
||||||
/// thickens and smears the input without changing pitch). Grains are spawned every
|
/// to a fresh random position in `[-1, 1] × spread`; the windowed, panned copies sum to the stereo
|
||||||
/// `grainSize / overlap` samples from a fixed voice pool; each grain's pan is a fresh random value
|
/// output. Because every active grain reads the current input sample (not buffered history), the
|
||||||
/// in `[-1, 1] × spread` turned into equal-power L/R gains. `spread = 0` collapses every grain to
|
/// effect adds stereo width and a shimmering amplitude texture with **no time delay**. `spread = 0`
|
||||||
/// centre (mono); `spread = 1` scatters grains across the full field.
|
/// collapses every grain to centre (mono); `spread = 1` scatters grains across the full field.
|
||||||
|
/// Output is normalised by `overlap` so density doesn't change the level.
|
||||||
///
|
///
|
||||||
/// `grainSize`, `overlap`, and `spread` are read at control rate (once per block). Output is two
|
/// `grainSize`, `overlap`, and `spread` are read at control rate (once per block). Output is two
|
||||||
/// channels (`[0]` = left, `[1]` = right) — use the ``left`` / ``right`` accessors.
|
/// channels (`[0]` = left, `[1]` = right) — use the ``left`` / ``right`` accessors.
|
||||||
///
|
///
|
||||||
/// - Important: All buffers and the grain voice pool are pre-allocated at `init` for `maxGrainSize`
|
/// - Important: The grain voice pool is pre-allocated at `init` — the RT path never allocates.
|
||||||
/// seconds — the RT path never allocates or resizes.
|
|
||||||
///
|
|
||||||
/// - Parameters:
|
|
||||||
/// - input: Audio-rate mono signal to granulate.
|
|
||||||
/// - maxGrainSize: Largest grain length in seconds; sizes the pre-allocated buffer.
|
|
||||||
/// - grainSize: Grain length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
|
|
||||||
/// - overlap: Number of overlapping grains (spawn density). Control rate; clamped to `[1, 24]`.
|
|
||||||
/// - spread: Stereo spread `[0, 1]` — scales each grain's random pan. Control rate.
|
|
||||||
/// - sampleRate: Sample rate used to size the buffer and convert seconds → frames.
|
|
||||||
/// - seed: Optional PRNG seed for deterministic grain panning (tests). Defaults to time-based.
|
|
||||||
public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
// MARK: - Inputs
|
// MARK: - Inputs
|
||||||
@@ -44,23 +34,18 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
let _overlap: any ValidGeneratorInput
|
let _overlap: any ValidGeneratorInput
|
||||||
let _spread: any ValidGeneratorInput
|
let _spread: any ValidGeneratorInput
|
||||||
|
|
||||||
// MARK: - Buffers + state
|
// MARK: - State
|
||||||
|
|
||||||
private var _buffer: [Double]
|
|
||||||
private let _mask: Int
|
|
||||||
private var _writeHead: Int = 0
|
|
||||||
|
|
||||||
private let _maxGrainFrames: Int
|
|
||||||
private let _minGrainFrames: Int
|
|
||||||
|
|
||||||
/// Precomputed unit Hann window, indexed by `phase · hannSize / grainLen`.
|
/// Precomputed unit Hann window, indexed by `phase · hannSize / grainLen`.
|
||||||
private var _hann: [Double]
|
private var _hann: [Double]
|
||||||
private let _hannSize: Int = 2048
|
private let _hannSize: Int = 2048
|
||||||
|
|
||||||
|
private let _maxGrainFrames: Int
|
||||||
|
private let _minGrainFrames: Int
|
||||||
|
|
||||||
// Grain voice pool (fixed size; a grain that can't find a free voice is skipped).
|
// Grain voice pool (fixed size; a grain that can't find a free voice is skipped).
|
||||||
private static let maxVoices: Int = 24
|
private static let maxVoices: Int = 24
|
||||||
private var _vActive: [Bool]
|
private var _vActive: [Bool]
|
||||||
private var _vReadHead: [Int]
|
|
||||||
private var _vPhase: [Int]
|
private var _vPhase: [Int]
|
||||||
private var _vLen: [Int]
|
private var _vLen: [Int]
|
||||||
private var _vGainL: [Double]
|
private var _vGainL: [Double]
|
||||||
@@ -85,11 +70,12 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - input: Audio-rate mono signal to granulate.
|
/// - input: Audio-rate mono signal to granulate.
|
||||||
/// - maxGrainSize: Largest grain length in seconds; sizes the pre-allocated buffer.
|
/// - maxGrainSize: Largest grain length in seconds; bounds the grain-length clamp.
|
||||||
/// - grainSize: Grain length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
|
/// - grainSize: Grain (window) length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
|
||||||
/// - overlap: Number of overlapping grains (spawn density). Control rate; clamped to `[1, 24]`.
|
/// - overlap: Number of overlapping grains (density); also the level normaliser. Control rate;
|
||||||
|
/// clamped to `[1, 24]`.
|
||||||
/// - spread: Stereo spread `[0, 1]` — scales each grain's random pan. Control rate.
|
/// - spread: Stereo spread `[0, 1]` — scales each grain's random pan. Control rate.
|
||||||
/// - sampleRate: Sample rate used to size the buffer and convert seconds → frames.
|
/// - sampleRate: Sample rate used to convert grain seconds → frames.
|
||||||
/// - seed: Optional PRNG seed for deterministic grain panning (tests). Defaults to a constant.
|
/// - seed: Optional PRNG seed for deterministic grain panning (tests). Defaults to a constant.
|
||||||
public init(
|
public init(
|
||||||
input: any ValidGeneratorInput,
|
input: any ValidGeneratorInput,
|
||||||
@@ -107,21 +93,10 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
_overlap = overlap._resolvedInput()
|
_overlap = overlap._resolvedInput()
|
||||||
_spread = spread._resolvedInput()
|
_spread = spread._resolvedInput()
|
||||||
|
|
||||||
let maxFrames: Int = max(1, Int((maxGrainSize * sampleRate).rounded()))
|
_maxGrainFrames = max(1, Int((maxGrainSize * sampleRate).rounded()))
|
||||||
_maxGrainFrames = maxFrames
|
|
||||||
_minGrainFrames = max(1, Int((minGrainSeconds * sampleRate).rounded()))
|
_minGrainFrames = max(1, Int((minGrainSeconds * sampleRate).rounded()))
|
||||||
|
|
||||||
// A grain reads the `grainLen` samples behind the write head while the head writes
|
|
||||||
// `grainLen` ahead during the grain's life — disjoint spans needing ≥ 2·maxGrainFrames.
|
|
||||||
// Round up to a power of two for branchless `& _mask` wrapping.
|
|
||||||
let needed: Int = 2 * maxFrames + 2
|
|
||||||
var size: Int = 1
|
|
||||||
while size < needed { size <<= 1 }
|
|
||||||
_buffer = [Double](repeating: 0.0, count: size)
|
|
||||||
_mask = size - 1
|
|
||||||
|
|
||||||
_vActive = [Bool](repeating: false, count: StereoGranulator.maxVoices)
|
_vActive = [Bool](repeating: false, count: StereoGranulator.maxVoices)
|
||||||
_vReadHead = [Int](repeating: 0, count: StereoGranulator.maxVoices)
|
|
||||||
_vPhase = [Int](repeating: 0, count: StereoGranulator.maxVoices)
|
_vPhase = [Int](repeating: 0, count: StereoGranulator.maxVoices)
|
||||||
_vLen = [Int](repeating: 1, count: StereoGranulator.maxVoices)
|
_vLen = [Int](repeating: 1, count: StereoGranulator.maxVoices)
|
||||||
_vGainL = [Double](repeating: 0.0, count: StereoGranulator.maxVoices)
|
_vGainL = [Double](repeating: 0.0, count: StereoGranulator.maxVoices)
|
||||||
@@ -166,6 +141,8 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
let spread: Double = rawSpread.isFinite ? min(max(rawSpread, 0.0), 1.0) : 0.0
|
let spread: Double = rawSpread.isFinite ? min(max(rawSpread, 0.0), 1.0) : 0.0
|
||||||
|
|
||||||
let spawnPeriod: Int = max(1, grainLen / overlap)
|
let spawnPeriod: Int = max(1, grainLen / overlap)
|
||||||
|
// Normalise so denser overlap doesn't raise the level (≈ sum of overlapping Hann windows).
|
||||||
|
let norm: Double = 1.0 / Double(overlap)
|
||||||
|
|
||||||
let inputSamples: [Double] = _inputIsGenerator
|
let inputSamples: [Double] = _inputIsGenerator
|
||||||
? (_input.calculatedSamples(graph: graph, count: count).first ?? stereoGranulatorZeroBlock)
|
? (_input.calculatedSamples(graph: graph, count: count).first ?? stereoGranulatorZeroBlock)
|
||||||
@@ -173,7 +150,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
let inputCount: Int = inputSamples.count
|
let inputCount: Int = inputSamples.count
|
||||||
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
||||||
|
|
||||||
var writeHead: Int = _writeHead
|
|
||||||
var spawnCountdown: Int = _spawnCountdown
|
var spawnCountdown: Int = _spawnCountdown
|
||||||
var rng: UInt64 = _rng
|
var rng: UInt64 = _rng
|
||||||
|
|
||||||
@@ -181,7 +157,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
let x: Double = _inputIsGenerator
|
let x: Double = _inputIsGenerator
|
||||||
? (i < inputCount ? inputSamples[i] : 0.0)
|
? (i < inputCount ? inputSamples[i] : 0.0)
|
||||||
: inputScalar
|
: inputScalar
|
||||||
_buffer[writeHead & _mask] = x
|
|
||||||
|
|
||||||
var left: Double = 0.0
|
var left: Double = 0.0
|
||||||
var right: Double = 0.0
|
var right: Double = 0.0
|
||||||
@@ -189,10 +164,10 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
let phase: Int = _vPhase[v]
|
let phase: Int = _vPhase[v]
|
||||||
let len: Int = _vLen[v]
|
let len: Int = _vLen[v]
|
||||||
let windowIndex: Int = phase * _hannSize / len
|
let windowIndex: Int = phase * _hannSize / len
|
||||||
let windowed: Double = _buffer[_vReadHead[v] & _mask] * _hann[windowIndex]
|
// Straight-through: window + pan the LIVE sample (no delay buffer).
|
||||||
|
let windowed: Double = x * _hann[windowIndex]
|
||||||
left += windowed * _vGainL[v]
|
left += windowed * _vGainL[v]
|
||||||
right += windowed * _vGainR[v]
|
right += windowed * _vGainR[v]
|
||||||
_vReadHead[v] = _vReadHead[v] + 1
|
|
||||||
let nextPhase: Int = phase + 1
|
let nextPhase: Int = phase + 1
|
||||||
if nextPhase >= len {
|
if nextPhase >= len {
|
||||||
_vActive[v] = false
|
_vActive[v] = false
|
||||||
@@ -204,15 +179,13 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
spawnCountdown -= 1
|
spawnCountdown -= 1
|
||||||
if spawnCountdown <= 0 {
|
if spawnCountdown <= 0 {
|
||||||
spawnCountdown = spawnPeriod
|
spawnCountdown = spawnPeriod
|
||||||
spawnGrain(grainLen: grainLen, spread: spread, writeHead: writeHead, rng: &rng)
|
spawnGrain(grainLen: grainLen, spread: spread, rng: &rng)
|
||||||
}
|
}
|
||||||
|
|
||||||
writeHead = writeHead + 1
|
_result[0][i] = left * norm
|
||||||
_result[0][i] = left
|
_result[1][i] = right * norm
|
||||||
_result[1][i] = right
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_writeHead = writeHead
|
|
||||||
_spawnCountdown = spawnCountdown
|
_spawnCountdown = spawnCountdown
|
||||||
_rng = rng
|
_rng = rng
|
||||||
return _result
|
return _result
|
||||||
@@ -222,7 +195,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
private func spawnGrain(
|
private func spawnGrain(
|
||||||
grainLen: Int,
|
grainLen: Int,
|
||||||
spread: Double,
|
spread: Double,
|
||||||
writeHead: Int,
|
|
||||||
rng: inout UInt64
|
rng: inout UInt64
|
||||||
) {
|
) {
|
||||||
var voice: Int = -1
|
var voice: Int = -1
|
||||||
@@ -235,8 +207,6 @@ public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
|||||||
_vActive[voice] = true
|
_vActive[voice] = true
|
||||||
_vPhase[voice] = 0
|
_vPhase[voice] = 0
|
||||||
_vLen[voice] = grainLen
|
_vLen[voice] = grainLen
|
||||||
// Read the grainLen samples just before the write head.
|
|
||||||
_vReadHead[voice] = writeHead - grainLen
|
|
||||||
let pan: Double = xorshift64Next(&rng) * spread // shared RT-safe PRNG, [-1, 1) × spread
|
let pan: Double = xorshift64Next(&rng) * spread // shared RT-safe PRNG, [-1, 1) × spread
|
||||||
let angle: Double = (pan + 1.0) * panAngleScale
|
let angle: Double = (pan + 1.0) * panAngleScale
|
||||||
_vGainL[voice] = cos(angle)
|
_vGainL[voice] = cos(angle)
|
||||||
|
|||||||
@@ -278,22 +278,39 @@ public final class RigLibraryStore {
|
|||||||
|
|
||||||
// MARK: - Archive import / export
|
// MARK: - Archive import / export
|
||||||
|
|
||||||
/// Encodes the entire library as a single ``RigArchive`` JSON document for export.
|
/// Encodes the entire library as a single ``RigArchive`` JSON document.
|
||||||
///
|
///
|
||||||
/// - Returns: Pretty-printed archive bytes suitable for a `fileExporter` / `NSSavePanel`.
|
/// Retained for callers and tests that want the bare archive bytes. The user-facing
|
||||||
|
/// export/share path uses ``exportDocumentData()``, which wraps the same rigs in a
|
||||||
|
/// ``ShoeGazeDocument`` envelope (the `.shoegaze` file type).
|
||||||
|
///
|
||||||
|
/// - Returns: Pretty-printed archive bytes.
|
||||||
/// - Throws: `JSONEncoder` errors.
|
/// - Throws: `JSONEncoder` errors.
|
||||||
public func exportArchiveData() throws -> Data {
|
public func exportArchiveData() throws -> Data {
|
||||||
let archive: RigArchive = RigArchive(rigs: entries)
|
let archive: RigArchive = RigArchive(rigs: entries)
|
||||||
return try RigLibraryStore.makeEncoder().encode(archive)
|
return try RigLibraryStore.makeEncoder().encode(archive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Encodes the entire library as a ``ShoeGazeDocument`` for export to a `.shoegaze` file.
|
||||||
|
///
|
||||||
|
/// This is the format written by the library's **Export** action and shared via the system
|
||||||
|
/// share sheet. ``importArchive(from:)`` reads it back, and also still accepts the bare
|
||||||
|
/// ``RigArchive`` and legacy single-rig shapes.
|
||||||
|
///
|
||||||
|
/// - Returns: Pretty-printed `.shoegaze` document bytes.
|
||||||
|
/// - Throws: `JSONEncoder` errors.
|
||||||
|
public func exportDocumentData() throws -> Data {
|
||||||
|
try ShoeGazeDocument(rigs: entries).data()
|
||||||
|
}
|
||||||
|
|
||||||
/// Imports rigs from archive `data`, saving each into the library, and returns how many were
|
/// Imports rigs from archive `data`, saving each into the library, and returns how many were
|
||||||
/// added.
|
/// added.
|
||||||
///
|
///
|
||||||
/// Accepts either a ``RigArchive`` (the multi-rig export format) or a legacy single-rig file
|
/// Accepts a ``ShoeGazeDocument`` (the `.shoegaze` file type), a bare ``RigArchive`` (the prior
|
||||||
/// (a bare ``ShoeGazeState``), which is imported as one entry named `legacyRigName`. Imported
|
/// multi-rig export), or a legacy single-rig file (a bare ``ShoeGazeState``), which is imported
|
||||||
/// entries whose `id` already exists in the library are given a fresh `id` so an import never
|
/// as one entry named `legacyRigName`. A document carrying a board rather than rigs contributes
|
||||||
/// silently overwrites an existing rig.
|
/// no entries. Imported entries whose `id` already exists in the library are given a fresh `id`
|
||||||
|
/// so an import never silently overwrites an existing rig.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - data: Archive or legacy-rig JSON bytes.
|
/// - data: Archive or legacy-rig JSON bytes.
|
||||||
@@ -512,19 +529,15 @@ public final class RigLibraryStore {
|
|||||||
return decoder
|
return decoder
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decodes import bytes as a ``RigArchive`` first, falling back to a legacy single-rig
|
/// Decodes import bytes into rig entries, accepting the `.shoegaze` ``ShoeGazeDocument``
|
||||||
/// ``ShoeGazeState``.
|
/// envelope plus the bare ``RigArchive`` and legacy ``ShoeGazeState`` shapes (see
|
||||||
|
/// ``ShoeGazeDocument/decoded(from:legacyRigName:)``). A board-carrying document yields no rigs.
|
||||||
private func decodeImportable(
|
private func decodeImportable(
|
||||||
_ data: Data,
|
_ data: Data,
|
||||||
legacyRigName: String
|
legacyRigName: String
|
||||||
) throws -> [RigEntry] {
|
) throws -> [RigEntry] {
|
||||||
let decoder: JSONDecoder = RigLibraryStore.makeDecoder()
|
let document: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data, legacyRigName: legacyRigName)
|
||||||
if let archive: RigArchive = try? decoder.decode(RigArchive.self, from: data) {
|
return document.rigEntries ?? []
|
||||||
return archive.rigs
|
|
||||||
}
|
|
||||||
// A legacy single-rig file is a bare ShoeGazeState (no `rigs` array). Decode and wrap.
|
|
||||||
let state: ShoeGazeState = try decoder.decode(ShoeGazeState.self, from: data)
|
|
||||||
return [RigEntry(name: legacyRigName, state: state)]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - In-memory helpers
|
// MARK: - In-memory helpers
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
// ShoeGazeDocument.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// Format version written into every `.shoegaze` document.
|
||||||
|
///
|
||||||
|
/// Increment when the `ShoeGazeDocument` envelope schema changes in a way that requires
|
||||||
|
/// migration on load. The payload types (``RigArchive`` / ``BoardVersion``) carry their own
|
||||||
|
/// independent version fields.
|
||||||
|
public let shoeGazeDocumentFormatVersion: Int = 1
|
||||||
|
|
||||||
|
/// The portable `.shoegaze` document — the single file type ShoeGaze writes when a user shares
|
||||||
|
/// or exports their work, and reads when opening a shared file.
|
||||||
|
///
|
||||||
|
/// A document is a small versioned envelope around one of two payloads:
|
||||||
|
///
|
||||||
|
/// - ``Payload/rigs(_:)`` — one or more rigs, carried as a ``RigArchive`` (a single shared rig is
|
||||||
|
/// a one-rig archive; the whole-library export is a many-rig archive).
|
||||||
|
/// - ``Payload/board(_:)`` — a single named board snapshot (``BoardVersion``).
|
||||||
|
///
|
||||||
|
/// Files are written pretty-printed with sorted keys and `secondsSince1970` dates, so they stay
|
||||||
|
/// hand-readable and round-trip losslessly.
|
||||||
|
///
|
||||||
|
/// ## Backward compatibility
|
||||||
|
///
|
||||||
|
/// ``decoded(from:)`` accepts three on-disk shapes so older files keep opening:
|
||||||
|
/// 1. A `ShoeGazeDocument` envelope (the current format).
|
||||||
|
/// 2. A bare ``RigArchive`` (the previous multi-rig export).
|
||||||
|
/// 3. A bare ``ShoeGazeState`` (the original single-rig save).
|
||||||
|
///
|
||||||
|
/// Shapes 2 and 3 are normalised into a ``Payload/rigs(_:)`` document on load.
|
||||||
|
public struct ShoeGazeDocument: Codable, Equatable {
|
||||||
|
|
||||||
|
/// The two things a `.shoegaze` file can carry.
|
||||||
|
public enum Payload: Equatable {
|
||||||
|
|
||||||
|
/// One or more rigs, as a portable archive.
|
||||||
|
case rigs(RigArchive)
|
||||||
|
|
||||||
|
/// A single named board snapshot.
|
||||||
|
case board(BoardVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Filename extension and the basis for the document's UTType (`net.realizedsound.shoegaze`).
|
||||||
|
public static let fileExtension: String = "shoegaze"
|
||||||
|
|
||||||
|
/// Document envelope version. Written as `shoeGazeDocumentFormatVersion` at save time.
|
||||||
|
public let version: Int
|
||||||
|
|
||||||
|
/// What this document carries.
|
||||||
|
public let payload: Payload
|
||||||
|
|
||||||
|
/// Creates a document with an explicit payload.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - version: Envelope version. Defaults to `shoeGazeDocumentFormatVersion`.
|
||||||
|
/// - payload: The rigs or board this document carries.
|
||||||
|
public init(
|
||||||
|
version: Int = shoeGazeDocumentFormatVersion,
|
||||||
|
payload: Payload
|
||||||
|
) {
|
||||||
|
self.version = version
|
||||||
|
self.payload = payload
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Convenience constructors
|
||||||
|
|
||||||
|
/// Creates a single-rig document by wrapping one ``RigEntry`` in a one-rig ``RigArchive``.
|
||||||
|
///
|
||||||
|
/// - Parameter entry: The rig to share.
|
||||||
|
public init(rig entry: RigEntry) {
|
||||||
|
self.init(payload: .rigs(RigArchive(rigs: [entry])))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a multi-rig document from a list of entries.
|
||||||
|
///
|
||||||
|
/// - Parameter entries: The rigs to bundle, in listing order.
|
||||||
|
public init(rigs entries: [RigEntry]) {
|
||||||
|
self.init(payload: .rigs(RigArchive(rigs: entries)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a single-board document.
|
||||||
|
///
|
||||||
|
/// - Parameter version: The board snapshot to share.
|
||||||
|
public init(board version: BoardVersion) {
|
||||||
|
self.init(payload: .board(version))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Payload accessors
|
||||||
|
|
||||||
|
/// The rigs this document carries, or `nil` when it carries a board.
|
||||||
|
public var rigEntries: [RigEntry]? {
|
||||||
|
if case .rigs(let archive) = payload { return archive.rigs }
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The board this document carries, or `nil` when it carries rigs.
|
||||||
|
public var boardVersion: BoardVersion? {
|
||||||
|
if case .board(let version) = payload { return version }
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Encoding
|
||||||
|
|
||||||
|
/// Encodes this document to pretty-printed, hand-editable `.shoegaze` JSON.
|
||||||
|
///
|
||||||
|
/// - Returns: The encoded document bytes.
|
||||||
|
/// - Throws: Any error from `JSONEncoder`.
|
||||||
|
public func data() throws -> Data {
|
||||||
|
try ShoeGazeDocument.makeEncoder().encode(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes a `.shoegaze` document, tolerating the two legacy on-disk shapes.
|
||||||
|
///
|
||||||
|
/// Tries the `ShoeGazeDocument` envelope first, then a bare ``RigArchive``, then a bare
|
||||||
|
/// ``ShoeGazeState`` — normalising the latter two into a rigs document. A bare state with no
|
||||||
|
/// name becomes a one-rig archive named `legacyRigName`.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - data: The document bytes.
|
||||||
|
/// - legacyRigName: Name applied when normalising a bare ``ShoeGazeState``. Defaults to
|
||||||
|
/// `"Imported Rig"`.
|
||||||
|
/// - Returns: A normalised document.
|
||||||
|
/// - Throws: `JSONDecoder` errors when `data` matches none of the three shapes.
|
||||||
|
public static func decoded(
|
||||||
|
from data: Data,
|
||||||
|
legacyRigName: String = "Imported Rig"
|
||||||
|
) throws -> ShoeGazeDocument {
|
||||||
|
let decoder: JSONDecoder = makeDecoder()
|
||||||
|
if let document: ShoeGazeDocument = try? decoder.decode(ShoeGazeDocument.self, from: data) {
|
||||||
|
return document
|
||||||
|
}
|
||||||
|
if let archive: RigArchive = try? decoder.decode(RigArchive.self, from: data) {
|
||||||
|
return ShoeGazeDocument(payload: .rigs(archive))
|
||||||
|
}
|
||||||
|
// Original single-rig save: a bare ShoeGazeState. Let a genuine decode failure surface here.
|
||||||
|
let state: ShoeGazeState = try decoder.decode(ShoeGazeState.self, from: data)
|
||||||
|
return ShoeGazeDocument(rig: RigEntry(name: legacyRigName, state: state))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A JSON encoder configured for human-readable, round-trip-stable document files.
|
||||||
|
static func makeEncoder() -> JSONEncoder {
|
||||||
|
let encoder: JSONEncoder = JSONEncoder()
|
||||||
|
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
|
||||||
|
encoder.dateEncodingStrategy = .secondsSince1970
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A JSON decoder matching ``makeEncoder()``.
|
||||||
|
static func makeDecoder() -> JSONDecoder {
|
||||||
|
let decoder: JSONDecoder = JSONDecoder()
|
||||||
|
decoder.dateDecodingStrategy = .secondsSince1970
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Codable
|
||||||
|
|
||||||
|
/// Discriminator written into the JSON so a payload reads back unambiguously.
|
||||||
|
private enum Kind: String, Codable {
|
||||||
|
case rigs
|
||||||
|
case board
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case version
|
||||||
|
case kind
|
||||||
|
case rigs
|
||||||
|
case board
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Encodes the envelope with an explicit `kind` discriminator and the matching payload key.
|
||||||
|
public func encode(to encoder: any Encoder) throws {
|
||||||
|
var container: KeyedEncodingContainer<CodingKeys> = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(version, forKey: .version)
|
||||||
|
switch payload {
|
||||||
|
case .rigs(let archive):
|
||||||
|
try container.encode(Kind.rigs, forKey: .kind)
|
||||||
|
try container.encode(archive, forKey: .rigs)
|
||||||
|
case .board(let boardVersion):
|
||||||
|
try container.encode(Kind.board, forKey: .kind)
|
||||||
|
try container.encode(boardVersion, forKey: .board)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes the envelope, reading the payload named by the `kind` discriminator.
|
||||||
|
public init(from decoder: any Decoder) throws {
|
||||||
|
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.version = try container.decode(Int.self, forKey: .version)
|
||||||
|
let kind: Kind = try container.decode(Kind.self, forKey: .kind)
|
||||||
|
switch kind {
|
||||||
|
case .rigs:
|
||||||
|
self.payload = .rigs(try container.decode(RigArchive.self, forKey: .rigs))
|
||||||
|
case .board:
|
||||||
|
self.payload = .board(try container.decode(BoardVersion.self, forKey: .board))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -218,6 +218,16 @@ public struct BoardEditorView: View {
|
|||||||
Button("Load") {
|
Button("Load") {
|
||||||
loadVersion(version)
|
loadVersion(version)
|
||||||
}
|
}
|
||||||
|
// Encoding a fully-concrete BoardVersion to JSON does not fail in practice; on the
|
||||||
|
// unreachable failure path the Share item is simply omitted.
|
||||||
|
if let shareItem: BoardShareItem = try? BoardShareItem(board: version) {
|
||||||
|
ShareLink(
|
||||||
|
item: shareItem,
|
||||||
|
preview: SharePreview(version.name)
|
||||||
|
) {
|
||||||
|
Label("Share…", systemImage: "square.and.arrow.up")
|
||||||
|
}
|
||||||
|
}
|
||||||
Button("Delete", role: .destructive) {
|
Button("Delete", role: .destructive) {
|
||||||
versionStore.remove(version)
|
versionStore.remove(version)
|
||||||
try? versionStore.deleteFromDisk(version, in: BoardVersionStore.defaultDirectory())
|
try? versionStore.deleteFromDisk(version, in: BoardVersionStore.defaultDirectory())
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// BoardShareItem.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import CoreTransferable
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
/// A `Transferable` wrapper that lets a `ShareLink` send a single board as a `.shoegaze` document.
|
||||||
|
///
|
||||||
|
/// Mirrors ``RigShareItem`` for a board snapshot: it holds the already-encoded document bytes and,
|
||||||
|
/// via `FileRepresentation`, writes them to a temporary `<board>.shoegaze` file when a share
|
||||||
|
/// destination is picked — giving the share sheet a real file so AirDrop, Messages, Mail, Notes,
|
||||||
|
/// and Files all appear (raw data collapses the macOS menu to Copy / Edit Extensions).
|
||||||
|
struct BoardShareItem: Transferable, Sendable {
|
||||||
|
|
||||||
|
/// Filesystem-safe base name for the shared file (no extension).
|
||||||
|
let filenameBase: String
|
||||||
|
|
||||||
|
/// Encoded `.shoegaze` document bytes.
|
||||||
|
let data: Data
|
||||||
|
|
||||||
|
/// Encodes `version` as a single-board `.shoegaze` document.
|
||||||
|
///
|
||||||
|
/// - Parameter version: The board snapshot to share.
|
||||||
|
/// - Throws: Any `JSONEncoder` error from ``ShoeGazeDocument/data()``.
|
||||||
|
init(board version: BoardVersion) throws {
|
||||||
|
self.filenameBase = shareFilenameBase(version.name)
|
||||||
|
self.data = try ShoeGazeDocument(board: version).data()
|
||||||
|
}
|
||||||
|
|
||||||
|
static var transferRepresentation: some TransferRepresentation {
|
||||||
|
FileRepresentation(exportedContentType: .shoeGaze) { item in
|
||||||
|
SentTransferredFile(try writeShoeGazeShareFile(item.data, base: item.filenameBase))
|
||||||
|
}
|
||||||
|
.suggestedFileName { item in
|
||||||
|
"\(item.filenameBase).\(ShoeGazeDocument.fileExtension)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,32 @@ public struct EngineConfigView: View {
|
|||||||
pendingInputs = shoeGaze.engine.numInputChannels
|
pendingInputs = shoeGaze.engine.numInputChannels
|
||||||
pendingOutputs = shoeGaze.engine.numOutputChannels
|
pendingOutputs = shoeGaze.engine.numOutputChannels
|
||||||
}
|
}
|
||||||
|
// Apply config edits to the (stopped) engine immediately so dependent UI — notably the
|
||||||
|
// input-source picker, which lists `0..<engine.numInputChannels` — reflects the new channel
|
||||||
|
// counts before Start. While running, the controls are disabled, so these never fire then.
|
||||||
|
.onChange(of: pendingInputs) { applyConfigWhileStopped() }
|
||||||
|
.onChange(of: pendingOutputs) { applyConfigWhileStopped() }
|
||||||
|
.onChange(of: pendingSampleRate) { applyConfigWhileStopped() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reconfigures the stopped engine with the pending values and notifies the host so views that
|
||||||
|
/// read non-observable engine state refresh. No-op while the engine is running.
|
||||||
|
private func applyConfigWhileStopped() {
|
||||||
|
guard !shoeGaze.engine.isRunning else { return }
|
||||||
|
do {
|
||||||
|
if let applyConfig: (Double, Int, Int) throws -> Void = applyConfig {
|
||||||
|
try applyConfig(pendingSampleRate, pendingInputs, pendingOutputs)
|
||||||
|
} else {
|
||||||
|
try shoeGaze.reconfigureEngine(
|
||||||
|
sampleRate: pendingSampleRate,
|
||||||
|
inputChannels: pendingInputs,
|
||||||
|
outputChannels: pendingOutputs
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onConfigApplied()
|
||||||
|
} catch {
|
||||||
|
print("[EngineConfigView] live reconfigure failed: \(error)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func label(_ text: String) -> some View {
|
private func label(_ text: String) -> some View {
|
||||||
|
|||||||
@@ -155,21 +155,24 @@ public struct PedalPaletteView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fixed-width-card row for a horizontal scroller: leading filter + PEDALS group, a divider,
|
/// Horizontal scroller: a PEDALS row (leading filter + colour-coded cards) with the ROUTING
|
||||||
/// then the ROUTING group.
|
/// row stacked beneath it.
|
||||||
private var horizontalBody: some View {
|
private var horizontalBody: some View {
|
||||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
VStack(alignment: .leading, spacing: PedalPaletteView.sectionSpacing) {
|
||||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||||
sectionTitle("PEDALS")
|
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||||
filterMenu
|
sectionTitle("PEDALS")
|
||||||
|
filterMenu
|
||||||
|
}
|
||||||
|
ForEach(visiblePedalNames, id: \.self) { name in
|
||||||
|
pedalRow(name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ForEach(visiblePedalNames, id: \.self) { name in
|
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||||
pedalRow(name)
|
sectionTitle("ROUTING")
|
||||||
}
|
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
|
||||||
Divider().overlay(Color.white.opacity(PedalPaletteView.cardBorderOpacity))
|
routingCard(title: option.title, caption: option.caption, action: option.action)
|
||||||
sectionTitle("ROUTING")
|
}
|
||||||
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
|
|
||||||
routingCard(title: option.title, caption: option.caption, action: option.action)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,18 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import UniformTypeIdentifiers
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
/// A minimal JSON `FileDocument` wrapping a ShoeGaze rig's encoded bytes.
|
/// A minimal `FileDocument` wrapping a ShoeGaze document's encoded bytes.
|
||||||
///
|
///
|
||||||
/// Used by ``ShoeGazeBuilderView``'s iOS `.fileExporter` to write the result of
|
/// Used by ``ShoeGazeBuilderView``'s `.fileExporter` to write the result of
|
||||||
/// `ShoeGaze.rigData()` to a user-chosen location. macOS uses an `NSSavePanel` directly and does
|
/// `RigLibraryStore.exportDocumentData()` (a `.shoegaze` ``ShoeGazeDocument``) to a user-chosen
|
||||||
/// not need this type.
|
/// location.
|
||||||
struct RigFileDocument: FileDocument {
|
struct RigFileDocument: FileDocument {
|
||||||
|
|
||||||
/// The rig presets are plain JSON.
|
/// Writes the `.shoegaze` document type.
|
||||||
static var readableContentTypes: [UTType] { [.json] }
|
static var writableContentTypes: [UTType] { [.shoeGaze] }
|
||||||
|
|
||||||
|
/// Reads `.shoegaze` documents and the legacy plain-JSON exports.
|
||||||
|
static var readableContentTypes: [UTType] { [.shoeGaze, .json] }
|
||||||
|
|
||||||
/// Encoded rig JSON.
|
/// Encoded rig JSON.
|
||||||
let data: Data
|
let data: Data
|
||||||
|
|||||||
@@ -132,6 +132,16 @@ struct RigLibrarySidebarView: View {
|
|||||||
.contextMenu {
|
.contextMenu {
|
||||||
Button("Rename…") { onRename(entry) }
|
Button("Rename…") { onRename(entry) }
|
||||||
Button("Duplicate…") { onDuplicate(entry) }
|
Button("Duplicate…") { onDuplicate(entry) }
|
||||||
|
// Encoding a fully-concrete RigEntry to JSON does not fail in practice; on the
|
||||||
|
// unreachable failure path the Share item is simply omitted.
|
||||||
|
if let shareItem: RigShareItem = try? RigShareItem(rig: entry) {
|
||||||
|
ShareLink(
|
||||||
|
item: shareItem,
|
||||||
|
preview: SharePreview(entry.name)
|
||||||
|
) {
|
||||||
|
Label("Share…", systemImage: "square.and.arrow.up")
|
||||||
|
}
|
||||||
|
}
|
||||||
Divider()
|
Divider()
|
||||||
Button("Delete", role: .destructive) { onDelete(entry) }
|
Button("Delete", role: .destructive) { onDelete(entry) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// RigShareItem.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import CoreTransferable
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
/// A `Transferable` wrapper that lets a `ShareLink` send a single rig as a `.shoegaze` document.
|
||||||
|
///
|
||||||
|
/// Holds the already-encoded document bytes (a value type, so the wrapper is `Sendable` as
|
||||||
|
/// `Transferable` requires). The encode happens when the share menu is built for the focused row —
|
||||||
|
/// cheap, one rig — via the throwing ``init(rig:)``.
|
||||||
|
///
|
||||||
|
/// Uses `FileRepresentation` (not `DataRepresentation`): the share sheet — AirDrop, Messages,
|
||||||
|
/// Mail, Notes, Files — only offers its full service list when handed a real file on disk. The
|
||||||
|
/// bytes are written to a temporary `<rig>.shoegaze` when a destination is picked. Sharing raw
|
||||||
|
/// data instead collapses the macOS menu to just Copy / Edit Extensions.
|
||||||
|
struct RigShareItem: Transferable, Sendable {
|
||||||
|
|
||||||
|
/// Filesystem-safe base name for the shared file (no extension).
|
||||||
|
let filenameBase: String
|
||||||
|
|
||||||
|
/// Encoded `.shoegaze` document bytes.
|
||||||
|
let data: Data
|
||||||
|
|
||||||
|
/// Encodes `entry` as a single-rig `.shoegaze` document.
|
||||||
|
///
|
||||||
|
/// - Parameter entry: The library entry to share.
|
||||||
|
/// - Throws: Any `JSONEncoder` error from ``ShoeGazeDocument/data()``.
|
||||||
|
init(rig entry: RigEntry) throws {
|
||||||
|
self.filenameBase = shareFilenameBase(entry.name)
|
||||||
|
self.data = try ShoeGazeDocument(rig: entry).data()
|
||||||
|
}
|
||||||
|
|
||||||
|
static var transferRepresentation: some TransferRepresentation {
|
||||||
|
FileRepresentation(exportedContentType: .shoeGaze) { item in
|
||||||
|
SentTransferredFile(try writeShoeGazeShareFile(item.data, base: item.filenameBase))
|
||||||
|
}
|
||||||
|
.suggestedFileName { item in
|
||||||
|
"\(item.filenameBase).\(ShoeGazeDocument.fileExtension)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reduces a user-supplied name to a filesystem-safe base for a shared file, mirroring the preset
|
||||||
|
/// stores' sanitisation at the UI boundary (the core sanitiser is module-internal to
|
||||||
|
/// `LyrebirdShoeGaze`). Path separators and whitespace become underscores; an empty result falls
|
||||||
|
/// back to a generic name. Shared by ``RigShareItem`` and ``BoardShareItem``.
|
||||||
|
func shareFilenameBase(_ name: String) -> String {
|
||||||
|
let forbidden: Set<Character> = ["/", "\\", ":", "\0"]
|
||||||
|
let mapped: String = String(name.map { character -> Character in
|
||||||
|
(character.isWhitespace || forbidden.contains(character)) ? "_" : character
|
||||||
|
})
|
||||||
|
let trimmed: String = mapped.trimmingCharacters(in: CharacterSet(charactersIn: "_"))
|
||||||
|
return trimmed.isEmpty ? "ShoeGaze" : trimmed
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes `data` to a uniquely-named temporary `<base>.shoegaze` file and returns its URL, for a
|
||||||
|
/// `FileRepresentation` to hand the share sheet a real file. A fresh per-share subdirectory avoids
|
||||||
|
/// collisions when the same name is shared twice. Shared by ``RigShareItem`` and ``BoardShareItem``.
|
||||||
|
func writeShoeGazeShareFile(_ data: Data, base: String) throws -> URL {
|
||||||
|
let directory: URL = FileManager.default.temporaryDirectory
|
||||||
|
.appendingPathComponent("ShoeGazeShare-\(UUID().uuidString)", isDirectory: true)
|
||||||
|
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
|
||||||
|
let url: URL = directory
|
||||||
|
.appendingPathComponent(base)
|
||||||
|
.appendingPathExtension(ShoeGazeDocument.fileExtension)
|
||||||
|
try data.write(to: url, options: .atomic)
|
||||||
|
return url
|
||||||
|
}
|
||||||
@@ -118,6 +118,16 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
@State private var pendingSwitchEntry: RigEntry?
|
@State private var pendingSwitchEntry: RigEntry?
|
||||||
@State private var showSwitchSaveDialog: Bool = false
|
@State private var showSwitchSaveDialog: Bool = false
|
||||||
|
|
||||||
|
/// A failed edit (add pedal / routing / board) to surface as an alert. `nil` = no alert.
|
||||||
|
@State private var actionError: ActionError?
|
||||||
|
|
||||||
|
/// A user-facing failure message for the action-error alert.
|
||||||
|
private struct ActionError: Identifiable {
|
||||||
|
let id: UUID = UUID()
|
||||||
|
let title: String
|
||||||
|
let message: String
|
||||||
|
}
|
||||||
|
|
||||||
/// Archive export state. Cross-platform: backs the sidebar's Export Archive and the
|
/// Archive export state. Cross-platform: backs the sidebar's Export Archive and the
|
||||||
/// "Save & Clear" flow is separate (it saves to the library, not a file).
|
/// "Save & Clear" flow is separate (it saves to the library, not a file).
|
||||||
@State private var showExporter: Bool = false
|
@State private var showExporter: Bool = false
|
||||||
@@ -193,6 +203,7 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
.background(boardsSheetAnchor)
|
.background(boardsSheetAnchor)
|
||||||
.background(rigExportAnchor)
|
.background(rigExportAnchor)
|
||||||
.background(rigImportAnchor)
|
.background(rigImportAnchor)
|
||||||
|
.background(actionErrorAnchor)
|
||||||
.rigNamePrompt($namePrompt)
|
.rigNamePrompt($namePrompt)
|
||||||
.confirmationDialog(
|
.confirmationDialog(
|
||||||
"Erase all rigs?",
|
"Erase all rigs?",
|
||||||
@@ -349,31 +360,69 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hosts the archive-export (`.json`) exporter on its own node. Writes the whole library as one
|
/// Hosts the library-export (`.shoegaze`) exporter on its own node. Writes the whole library as
|
||||||
/// ``RigArchive`` file for backup or transfer.
|
/// one ``ShoeGazeDocument`` file for backup or transfer.
|
||||||
private var rigExportAnchor: some View {
|
private var rigExportAnchor: some View {
|
||||||
Color.clear
|
Color.clear
|
||||||
.fileExporter(
|
.fileExporter(
|
||||||
isPresented: $showExporter,
|
isPresented: $showExporter,
|
||||||
document: exportDocument,
|
document: exportDocument,
|
||||||
contentType: .json,
|
contentType: .shoeGaze,
|
||||||
defaultFilename: ShoeGazeBuilderView.defaultArchiveFileName
|
defaultFilename: ShoeGazeBuilderView.defaultArchiveFileName
|
||||||
) { result in
|
) { result in
|
||||||
if case .failure(let error) = result {
|
if case .failure(let error) = result {
|
||||||
print("[ShoeGazeBuilderView] archive export failed: \(error)")
|
print("[ShoeGazeBuilderView] library export failed: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hosts the archive-import (`.json`) importer on its own node (cross-platform). Accepts a
|
/// Hosts the library-import (`.shoegaze`) importer on its own node (cross-platform). Accepts a
|
||||||
/// ``RigArchive`` or a legacy single-rig file; imported rigs are added to the library.
|
/// ``ShoeGazeDocument`` or a legacy archive / single-rig file; imported rigs are added to the
|
||||||
|
/// library.
|
||||||
private var rigImportAnchor: some View {
|
private var rigImportAnchor: some View {
|
||||||
Color.clear
|
Color.clear
|
||||||
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in
|
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.shoeGaze, .json]) { result in
|
||||||
handleArchiveImport(result)
|
handleArchiveImport(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hosts the action-failure alert on its own node (one presentation per node).
|
||||||
|
private var actionErrorAnchor: some View {
|
||||||
|
Color.clear
|
||||||
|
.alert(
|
||||||
|
actionError?.title ?? "",
|
||||||
|
isPresented: Binding(
|
||||||
|
get: { actionError != nil },
|
||||||
|
set: { presented in if !presented { actionError = nil } }
|
||||||
|
),
|
||||||
|
presenting: actionError
|
||||||
|
) { _ in
|
||||||
|
Button("OK", role: .cancel) { }
|
||||||
|
} message: { error in
|
||||||
|
Text(error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Surfaces a failed edit as an alert (and logs it). Maps the common stereo-width / merge errors
|
||||||
|
/// to player-facing wording (no API names); otherwise uses the error's `LocalizedError` text.
|
||||||
|
private func reportError(_ title: String, _ error: Error) {
|
||||||
|
actionError = ActionError(title: title, message: friendlyMessage(for: error))
|
||||||
|
}
|
||||||
|
|
||||||
|
private func friendlyMessage(for error: Error) -> String {
|
||||||
|
switch error as? ShoeGazeError {
|
||||||
|
case .stereoWidthExceeded, .cannotSplitStereoChain:
|
||||||
|
return "This board is already in stereo. Add a “Merge to Mono” before another stereo "
|
||||||
|
+ "(widening) pedal such as Chorus, Rotary, or a Granulator."
|
||||||
|
case .cannotMergeMonoChain:
|
||||||
|
return "This board is already mono — there’s no stereo signal to merge."
|
||||||
|
case .cannotUnzipMonoChain:
|
||||||
|
return "This board is mono — there’s no stereo signal to split into left/right lanes."
|
||||||
|
default:
|
||||||
|
return (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
/// Hosts the recording-folder importer on its own node.
|
/// Hosts the recording-folder importer on its own node.
|
||||||
private var recordingFolderImportAnchor: some View {
|
private var recordingFolderImportAnchor: some View {
|
||||||
@@ -472,6 +521,7 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderView] routing \(action) failed: \(error)")
|
print("[ShoeGazeBuilderView] routing \(action) failed: \(error)")
|
||||||
|
reportError("Couldn’t add routing", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,6 +566,7 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
autosave()
|
autosave()
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
|
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
|
||||||
|
reportError("Couldn’t add \(type)", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,6 +581,7 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
} catch {
|
} catch {
|
||||||
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||||
print("[ShoeGazeBuilderView] addBoard failed: \(error)")
|
print("[ShoeGazeBuilderView] addBoard failed: \(error)")
|
||||||
|
reportError("Couldn’t add board", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -866,13 +918,13 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Captures the current session into the whole-library archive exporter.
|
/// Captures the whole library into the `.shoegaze` document exporter.
|
||||||
private func exportArchiveAction() {
|
private func exportArchiveAction() {
|
||||||
do {
|
do {
|
||||||
exportDocument = RigFileDocument(data: try library.exportArchiveData())
|
exportDocument = RigFileDocument(data: try library.exportDocumentData())
|
||||||
showExporter = true
|
showExporter = true
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderView] exportArchiveData failed: \(error)")
|
print("[ShoeGazeBuilderView] exportDocumentData failed: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// UTType+ShoeGaze.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
|
public extension UTType {
|
||||||
|
|
||||||
|
/// The `.shoegaze` document type — a versioned JSON envelope carrying a shared rig or board.
|
||||||
|
///
|
||||||
|
/// Identifier `net.realizedsound.shoegaze`, conforming to `public.json` so the file stays
|
||||||
|
/// text-readable and is recognised by tools that understand JSON. The hosting app must also
|
||||||
|
/// declare this type in its `Info.plist` (`UTExportedTypeDeclarations` + `CFBundleDocumentTypes`)
|
||||||
|
/// for the system to associate the `.shoegaze` extension with the app and offer it in Share /
|
||||||
|
/// Open dialogs; this property mirrors that declaration so SwiftUI `fileExporter` / `fileImporter`
|
||||||
|
/// and `ShareLink` can reference it in code.
|
||||||
|
static let shoeGaze: UTType = UTType(exportedAs: "net.realizedsound.shoegaze", conformingTo: .json)
|
||||||
|
}
|
||||||
@@ -52,9 +52,6 @@ struct AutoGranulatorPedalTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Small min/max grains so audible output (which trails the write head by one grain) fills the
|
|
||||||
// reader's 4096-frame window.
|
|
||||||
|
|
||||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||||
let samples: [Float] = try render { pedal in pedal.minGrain = 0.01; pedal.maxGrain = 0.03 }
|
let samples: [Float] = try render { pedal in pedal.minGrain = 0.01; pedal.maxGrain = 0.03 }
|
||||||
#expect(!samples.isEmpty)
|
#expect(!samples.isEmpty)
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ struct GranulatorPedalTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Small grains so audible output (which trails the write head by one grain) fills the reader's
|
|
||||||
// 4096-frame window rather than starting after a long grain's worth of silence.
|
|
||||||
|
|
||||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||||
let samples: [Float] = try render { pedal in pedal.grain = 0.02 }
|
let samples: [Float] = try render { pedal in pedal.grain = 0.02 }
|
||||||
#expect(!samples.isEmpty)
|
#expect(!samples.isEmpty)
|
||||||
|
|||||||
@@ -149,8 +149,9 @@ struct RigLibraryStoreTests {
|
|||||||
try store.save(entry)
|
try store.save(entry)
|
||||||
|
|
||||||
// An archive carrying the SAME id must not overwrite the existing rig on import.
|
// An archive carrying the SAME id must not overwrite the existing rig on import.
|
||||||
|
// Encode with the on-disk strategy (.secondsSince1970) so dates survive the import decoder.
|
||||||
let archive: RigArchive = RigArchive(rigs: [entry])
|
let archive: RigArchive = RigArchive(rigs: [entry])
|
||||||
let data: Data = try JSONEncoder().encode(archive)
|
let data: Data = try ShoeGazeDocument.makeEncoder().encode(archive)
|
||||||
let added: Int = try store.importArchive(from: data)
|
let added: Int = try store.importArchive(from: data)
|
||||||
#expect(added == 1)
|
#expect(added == 1)
|
||||||
#expect(store.entries.count == 2, "colliding id should be imported as a new entry")
|
#expect(store.entries.count == 2, "colliding id should be imported as a new entry")
|
||||||
@@ -163,10 +164,42 @@ struct RigLibraryStoreTests {
|
|||||||
|
|
||||||
// A legacy file is a bare ShoeGazeState (no `rigs` array).
|
// A legacy file is a bare ShoeGazeState (no `rigs` array).
|
||||||
let legacyState: ShoeGazeState = ShoeGazeState(boards: [BoardState(label: "Legacy", segments: [])])
|
let legacyState: ShoeGazeState = ShoeGazeState(boards: [BoardState(label: "Legacy", segments: [])])
|
||||||
let data: Data = try JSONEncoder().encode(legacyState)
|
let data: Data = try ShoeGazeDocument.makeEncoder().encode(legacyState)
|
||||||
let added: Int = try store.importArchive(from: data, legacyRigName: "Recovered")
|
let added: Int = try store.importArchive(from: data, legacyRigName: "Recovered")
|
||||||
#expect(added == 1)
|
#expect(added == 1)
|
||||||
#expect(store.entries.first?.name == "Recovered")
|
#expect(store.entries.first?.name == "Recovered")
|
||||||
store.flushPendingWrites()
|
store.flushPendingWrites()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func exportDocumentThenImportRoundTrips() async throws {
|
||||||
|
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||||
|
defer { try? FileManager.default.removeItem(at: dir) }
|
||||||
|
|
||||||
|
try store.save(makeEntry("One"))
|
||||||
|
try store.save(makeEntry("Two"))
|
||||||
|
// The user-facing export is a `.shoegaze` ShoeGazeDocument envelope.
|
||||||
|
let documentData: Data = try store.exportDocumentData()
|
||||||
|
#expect(try ShoeGazeDocument.decoded(from: documentData).rigEntries?.count == 2)
|
||||||
|
|
||||||
|
let (other, otherDir): (RigLibraryStore, URL) = await makeStore()
|
||||||
|
defer { try? FileManager.default.removeItem(at: otherDir) }
|
||||||
|
let added: Int = try other.importArchive(from: documentData)
|
||||||
|
#expect(added == 2)
|
||||||
|
#expect(other.entries.map(\.name) == ["One", "Two"])
|
||||||
|
store.flushPendingWrites()
|
||||||
|
other.flushPendingWrites()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func importBoardDocumentAddsNoRigs() async throws {
|
||||||
|
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||||
|
defer { try? FileManager.default.removeItem(at: dir) }
|
||||||
|
|
||||||
|
// A board-carrying `.shoegaze` document is valid but contributes no library rigs.
|
||||||
|
let boardDocument: ShoeGazeDocument =
|
||||||
|
ShoeGazeDocument(board: BoardVersion(name: "Lead", state: BoardState(label: "Lead", segments: [])))
|
||||||
|
let added: Int = try store.importArchive(from: try boardDocument.data())
|
||||||
|
#expect(added == 0)
|
||||||
|
#expect(store.entries.isEmpty)
|
||||||
|
store.flushPendingWrites()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
// ShoeGazeDocumentTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@Suite("ShoeGazeDocument — share/export envelope")
|
||||||
|
struct ShoeGazeDocumentTests {
|
||||||
|
|
||||||
|
/// A minimal two-board rig state for snapshotting without an engine.
|
||||||
|
private func makeState(lead: String = "Lead") -> ShoeGazeState {
|
||||||
|
let board: BoardState = BoardState(label: lead, segments: [])
|
||||||
|
let other: BoardState = BoardState(label: "Clean", segments: [])
|
||||||
|
return ShoeGazeState(boards: [board, other])
|
||||||
|
}
|
||||||
|
|
||||||
|
private func makeEntry(name: String = "Ambient Wash") -> RigEntry {
|
||||||
|
RigEntry(name: name, state: makeState())
|
||||||
|
}
|
||||||
|
|
||||||
|
private func makeBoardVersion(name: String = "Lead Crunch") -> BoardVersion {
|
||||||
|
BoardVersion(name: name, state: BoardState(label: "Lead", segments: []))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Round trips
|
||||||
|
|
||||||
|
@Test func singleRigRoundTripIsLossless() throws {
|
||||||
|
let entry: RigEntry = makeEntry()
|
||||||
|
let document: ShoeGazeDocument = ShoeGazeDocument(rig: entry)
|
||||||
|
|
||||||
|
let data: Data = try document.data()
|
||||||
|
let decoded: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data)
|
||||||
|
|
||||||
|
#expect(decoded == document)
|
||||||
|
#expect(decoded.rigEntries == [entry])
|
||||||
|
#expect(decoded.boardVersion == nil)
|
||||||
|
#expect(decoded.version == shoeGazeDocumentFormatVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func multiRigRoundTripIsLossless() throws {
|
||||||
|
let entries: [RigEntry] = [makeEntry(name: "A"), makeEntry(name: "B")]
|
||||||
|
let document: ShoeGazeDocument = ShoeGazeDocument(rigs: entries)
|
||||||
|
|
||||||
|
let data: Data = try document.data()
|
||||||
|
let decoded: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data)
|
||||||
|
|
||||||
|
#expect(decoded == document)
|
||||||
|
#expect(decoded.rigEntries == entries)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func boardRoundTripIsLossless() throws {
|
||||||
|
let boardVersion: BoardVersion = makeBoardVersion()
|
||||||
|
let document: ShoeGazeDocument = ShoeGazeDocument(board: boardVersion)
|
||||||
|
|
||||||
|
let data: Data = try document.data()
|
||||||
|
let decoded: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data)
|
||||||
|
|
||||||
|
#expect(decoded == document)
|
||||||
|
#expect(decoded.boardVersion == boardVersion)
|
||||||
|
#expect(decoded.rigEntries == nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Backward compatibility
|
||||||
|
|
||||||
|
@Test func decodesLegacyRigArchive() throws {
|
||||||
|
let entries: [RigEntry] = [makeEntry(name: "Old A"), makeEntry(name: "Old B")]
|
||||||
|
let archive: RigArchive = RigArchive(rigs: entries)
|
||||||
|
|
||||||
|
let encoder: JSONEncoder = ShoeGazeDocument.makeEncoder()
|
||||||
|
let data: Data = try encoder.encode(archive)
|
||||||
|
|
||||||
|
let decoded: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data)
|
||||||
|
#expect(decoded.rigEntries == entries)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func decodesLegacyBareState() throws {
|
||||||
|
let state: ShoeGazeState = makeState()
|
||||||
|
|
||||||
|
let encoder: JSONEncoder = ShoeGazeDocument.makeEncoder()
|
||||||
|
let data: Data = try encoder.encode(state)
|
||||||
|
|
||||||
|
let decoded: ShoeGazeDocument = try ShoeGazeDocument.decoded(from: data, legacyRigName: "Recovered")
|
||||||
|
#expect(decoded.rigEntries?.count == 1)
|
||||||
|
#expect(decoded.rigEntries?.first?.name == "Recovered")
|
||||||
|
#expect(decoded.rigEntries?.first?.state == state)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func rejectsGarbage() {
|
||||||
|
let data: Data = Data("not a shoegaze document".utf8)
|
||||||
|
#expect(throws: (any Error).self) {
|
||||||
|
_ = try ShoeGazeDocument.decoded(from: data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - On-disk shape
|
||||||
|
|
||||||
|
@Test func envelopeCarriesKindDiscriminator() throws {
|
||||||
|
let rigData: Data = try ShoeGazeDocument(rig: makeEntry()).data()
|
||||||
|
let boardData: Data = try ShoeGazeDocument(board: makeBoardVersion()).data()
|
||||||
|
|
||||||
|
let rigJSON: String = String(decoding: rigData, as: UTF8.self)
|
||||||
|
let boardJSON: String = String(decoding: boardData, as: UTF8.self)
|
||||||
|
|
||||||
|
#expect(rigJSON.contains("\"kind\" : \"rigs\""))
|
||||||
|
#expect(boardJSON.contains("\"kind\" : \"board\""))
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 884 KiB After Width: | Height: | Size: 401 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 559 KiB |
@@ -0,0 +1,48 @@
|
|||||||
|
# 1.3 — Rig sharing & the `.shoegaze` document type
|
||||||
|
|
||||||
|
Goal: a single registered file type for sharing rigs and boards, migrate export/import onto it, and
|
||||||
|
add an OS share sheet to the rig library and board-version menu. Local only — no backend, no accounts.
|
||||||
|
|
||||||
|
## File type
|
||||||
|
|
||||||
|
- **Extension:** `.shoegaze`. **UTType:** `net.realizedsound.shoegaze`, conforms to `public.json`
|
||||||
|
(stays text-readable). `UTType.shoeGaze` lives in `LyrebirdShoeGazeUI`.
|
||||||
|
- Declared by all four demo apps and both CLI scaffolder templates
|
||||||
|
(`CFBundleDocumentTypes` Editor/Owner + `UTExportedTypeDeclarations`) so the system associates the
|
||||||
|
type with the app for Open and Share.
|
||||||
|
|
||||||
|
## Document model — `LyrebirdShoeGaze`
|
||||||
|
|
||||||
|
`ShoeGazeDocument` — versioned envelope (`shoeGazeDocumentFormatVersion = 1`) around one payload:
|
||||||
|
|
||||||
|
- `.rigs(RigArchive)` — one or many rigs (a single shared rig is a one-rig archive).
|
||||||
|
- `.board(BoardVersion)` — a single board snapshot.
|
||||||
|
|
||||||
|
`data()` encodes pretty-printed JSON (`secondsSince1970` dates). `decoded(from:legacyRigName:)` is
|
||||||
|
tolerant: tries the envelope, then a bare `RigArchive`, then a bare `ShoeGazeState` (normalised to a
|
||||||
|
one-rig document). On-disk JSON carries an explicit `kind` discriminator.
|
||||||
|
|
||||||
|
## Migration
|
||||||
|
|
||||||
|
- `RigLibraryStore.exportDocumentData()` writes the library as a `.shoegaze` document; the prior
|
||||||
|
`exportArchiveData()` (bare `RigArchive`) is retained for callers/tests.
|
||||||
|
- `importArchive(from:)` now decodes via `ShoeGazeDocument.decoded` — accepts `.shoegaze`, bare
|
||||||
|
archive, and legacy single-rig files. A board document contributes no rigs.
|
||||||
|
- `RigFileDocument` writes `.shoeGaze`, reads `[.shoeGaze, .json]`. The Builder's `fileExporter`
|
||||||
|
uses `.shoeGaze`; the `fileImporter` accepts `[.shoeGaze, .json]`.
|
||||||
|
- **Internal** per-rig library files and board-version files stay plain `.json` (app-private; no
|
||||||
|
churn). `.shoegaze` is the share/export surface only.
|
||||||
|
|
||||||
|
## Share UI — `LyrebirdShoeGazeUI`
|
||||||
|
|
||||||
|
- `RigShareItem` / `BoardShareItem` — `Transferable` wrappers holding pre-encoded `.shoegaze` bytes
|
||||||
|
(value-type payload keeps them `Sendable`). Suggested filename `<name>.shoegaze`.
|
||||||
|
- Rig library sidebar: `Share…` per rig (context menu). Board editor Versions menu: `Share…` per
|
||||||
|
version. Both via SwiftUI `ShareLink` → AirDrop / Mail / Messages / Files.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
- `ShoeGazeDocumentTests` — rig/board round-trip, legacy archive + bare-state decode, garbage
|
||||||
|
rejection, `kind` discriminator on disk.
|
||||||
|
- `RigLibraryStoreTests` — `.shoegaze` export→import round-trip; board document imports zero rigs.
|
||||||
|
- Lyrebird `ProjectScaffolderTests` — generated macOS/iOS `Info.plist` registers the document type.
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
# ShoeGaze 1.2.0
|
||||||
|
|
||||||
|
Ten new pedals, an iCloud-synced rig library, and a reworked builder layout.
|
||||||
|
|
||||||
|
## New pedals
|
||||||
|
|
||||||
|
Ten additions bring the built-in catalog to 32:
|
||||||
|
|
||||||
|
**Gain**
|
||||||
|
- **Distortion** — mid-gain saturation between Overdrive and Fuzz (Drive / Tone).
|
||||||
|
|
||||||
|
**Modulation**
|
||||||
|
- **Flanger** — sweeping comb-filter jet with feedback (Rate / Depth / Feedback).
|
||||||
|
- **Vibrato** — pure pitch wobble, fully wet (Rate / Depth).
|
||||||
|
- **Rotary** — Leslie rotary-speaker: Doppler pitch wobble + volume throb, two-speed
|
||||||
|
(Chorale / Tremolo) with an acceleration ramp (Depth / Accel + Speed switch).
|
||||||
|
|
||||||
|
**Pitch**
|
||||||
|
- **Harmonizer** — two pitch-shifted harmony voices at fixed musical intervals, picked with a new
|
||||||
|
stepped knob (octave / 5th / 4th / major & minor 3rd & 6th, above and below) with per-voice and
|
||||||
|
direct levels.
|
||||||
|
|
||||||
|
**Delay / Reverb**
|
||||||
|
- **Reverse Delay** — backward-tape segments with feedback trails (Time / Feedback).
|
||||||
|
- **Shimmer Reverb** — regenerative ambient reverb whose tail climbs an octave as it sustains
|
||||||
|
(Size / Decay / Shimmer / Damp).
|
||||||
|
|
||||||
|
**Texture**
|
||||||
|
- **Bitcrusher** — sample-rate decimation + bit-depth reduction + tone (Crush / Bits / Tone).
|
||||||
|
- **Granulator** — stereo grain cloud; grains scattered across the stereo field by Spread
|
||||||
|
(Grain / Overlap / Spread).
|
||||||
|
- **Auto Granulator** — granulator whose grain size tracks your dynamics, with a Response switch to
|
||||||
|
flip the loud↔short / loud↔long relationship (Min Grain / Max Grain / Overlap / Spread + Response).
|
||||||
|
|
||||||
|
## Rig library (iCloud)
|
||||||
|
|
||||||
|
- Rigs are now a managed **library** in the left sidebar instead of one hand-saved file. New, Save,
|
||||||
|
Save As, Duplicate, Rename, Delete, and Erase All — each rig holds multiple boards.
|
||||||
|
- **iCloud sync** across your devices and both apps (macOS + iPad) via a shared container, with a
|
||||||
|
local fallback when iCloud is unavailable. The library loads on launch and shows a loading state.
|
||||||
|
- Selecting a rig prompts to save unsaved changes first (macOS + iOS).
|
||||||
|
- **Archive** import/export bundles the whole library as one hand-editable JSON file (replaces the
|
||||||
|
old single-rig save/load); legacy single-rig files still import.
|
||||||
|
- macOS **File menu**: New Rig (⌘N), Save Rig (⌘S), Export / Import Archive (⌘E / ⌘I).
|
||||||
|
- Saves and loads run off the main thread, so the UI never stalls on disk or iCloud.
|
||||||
|
|
||||||
|
## Builder UI
|
||||||
|
|
||||||
|
- Reworked top layout: scope + CPU meters beside a stacked board-mixer / horizontal pedal-picker,
|
||||||
|
giving the board canvas the full width below.
|
||||||
|
- **Pedal picker** cards are now **colour-coded by type**, with a **filter-by-type** menu
|
||||||
|
(Gain / Dynamics / EQ & Filter / Modulation / Pitch / Delay / Reverb / Texture; defaults to All).
|
||||||
|
- The builder is pinned to a dark color scheme, fixing black-on-dark system controls (nav title,
|
||||||
|
steppers, Record button) on iOS in light mode.
|
||||||
|
- The input-source picker reflects the **In** channel count as soon as you change it (the stopped
|
||||||
|
engine reconfigures immediately), so you can choose the input before Start.
|
||||||
|
- Failed edits now surface as an **alert** instead of a console log — e.g. adding a second stereo
|
||||||
|
(widening) pedal explains that the board is already stereo and to add a Merge to Mono first.
|
||||||
|
- The routing cards sit in their own row beneath the pedal picker.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- The granulators are now **latency-free** — grains window and pan the live input directly
|
||||||
|
(straight-through), instead of replaying buffered history.
|
||||||
|
- Shimmer Reverb no longer accumulates a DC offset at high shimmer (DC-blocked feedback path).
|
||||||
|
|
||||||
|
## Under the hood
|
||||||
|
|
||||||
|
- New RT-safe generators: `ReverseDelay`, `SampleRateDecimate`, `BitReduce`, `ShimmerReverb`,
|
||||||
|
`StereoGranulator`; a reusable `PedalSelectorKnob` control with preset round-trip.
|
||||||
|
- All new generators sanitise control inputs (finite + clamped) and pre-allocate buffers.
|
||||||
|
- 271 tests; RT-safety reviewed.
|
||||||
|
|
||||||
|
## Setup notes
|
||||||
|
|
||||||
|
- **iCloud:** enable the `iCloud.net.realizedsound.ShoeGazeData` container on both builder App IDs
|
||||||
|
(iCloud Documents) and sign with the same team for cross-device sync.
|
||||||
|
- Shimmer Reverb and the granulators reward a tuning pass to taste.
|
||||||
Reference in New Issue
Block a user