diff --git a/ios/Makefile b/ios/Makefile index 6258d1e..5d2461a 100644 --- a/ios/Makefile +++ b/ios/Makefile @@ -98,7 +98,7 @@ au-test: build/core/au_test # Mac snapshots of the SwiftUI device editors (AUAudioUnit and SwiftUI exist on # macOS too): the AU classes + core as a dylib, the editor Swift on top. -EDITOR_SWIFT := $(wildcard app/FX/Editor/*.swift) +EDITOR_SWIFT := $(shell find app/FX/Editor -name '*.swift') build/snapshots/libsizzlesnap.dylib: $(AU_SRC) app/tests/SnapshotComponents.mm $(CORE_SRC) $(CORE_HDR) mkdir -p build/snapshots $(CXX) $(CXXFLAGS) -Wno-deprecated-declarations -fobjc-arc -Iapp/FX -dynamiclib -install_name @rpath/libsizzlesnap.dylib \ @@ -116,7 +116,8 @@ SNAPDIR ?= build/screens # Mac snapshots of the app's tabs with the demo song (SizzleSession runs on macOS # too, without audio). Screens must stay SwiftUI-only (no UIKit) to render here. SCREEN_SWIFT := $(EDITOR_SWIFT) app/Host/AppModel.swift app/Host/RootView.swift app/Host/SlotDeviceModel.swift \ - app/Host/KeyboardView.swift $(shell find app/Host/Screens -name '*.swift') + app/Host/KeyboardView.swift app/Host/SlotDataSource.swift \ + $(shell find app/Host/Screens app/Host/Bespoke -name '*.swift') $(SNAPDIR)/libsizzlescreens.dylib: $(AU_SRC) $(wildcard app/Host/SizzleSession*.mm app/Host/SizzleSession*.h) app/tests/SnapshotComponents.mm $(CORE_SRC) $(CORE_HDR) mkdir -p $(SNAPDIR) $(CXX) $(CXXFLAGS) -Wno-deprecated-declarations -fobjc-arc -Iapp/FX -Iapp/Host -dynamiclib -install_name @rpath/libsizzlescreens.dylib \ diff --git a/ios/app/FX/Editor/AUDataSource.swift b/ios/app/FX/Editor/AUDataSource.swift new file mode 100644 index 0000000..4e8c80a --- /dev/null +++ b/ios/app/FX/Editor/AUDataSource.swift @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import Foundation + +/// DeviceDataSource for an AUv3 (the plugin extension, the device lab). Each +/// device's Bespoke file adds what it supports in an extension of this class. +@MainActor +final class AUDataSource: DeviceDataSource { + let au: SizzleDeviceAU + init(au: SizzleDeviceAU) { self.au = au } +} diff --git a/ios/app/FX/Editor/Bespoke/Bespoke.swift b/ios/app/FX/Editor/Bespoke/Bespoke.swift new file mode 100644 index 0000000..e0944f6 --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/Bespoke.swift @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// What a device editor needs beyond its parameters: drawings of data the DSP +/// owns (wavetable frames, sample waveforms, an effect's live scope), loading +/// files into the device, and settings that aren't AU parameters (the Mix +/// Tightener's hidden stage trims). Two backends: SlotDataSource (a toolbox slot +/// of the app's song, Host/) and AUDataSource (an AUv3, the plugin extension and +/// the device lab). Every requirement has a default here; each device's file +/// implements what it needs in extensions of those classes. +@MainActor +protocol DeviceDataSource: AnyObject { + /// Oscillator [osc]'s current table, level 0 (frames × size samples), or nil. + func wavetableFrames(osc: Int) -> (frames: Int, size: Int, data: [Float])? + /// Peak envelope (0..1, [buckets] values) of the sample the setting [key] names. + func samplePeaks(key: String, buckets: Int) -> [Float]? + /// Load a user file into the device ([kind]: "wavetable", "grainSource", …). + /// Returns an error message, or nil on success. + func loadFile(_ url: URL, kind: String) -> String? + /// The effect's live scope (oldest → newest samples) and read-head position + /// (0..1), or nil while it has none (not on a channel, no signal). + func effectScope(capacity: Int) -> (samples: [Float], playhead: Float)? + /// A setting that isn't a parameter (text, as stored), or nil. + func hiddenValue(_ key: String) -> String? + func setHiddenValue(_ value: String, key: String) +} + +extension DeviceDataSource { + func wavetableFrames(osc: Int) -> (frames: Int, size: Int, data: [Float])? { nil } + func samplePeaks(key: String, buckets: Int) -> [Float]? { nil } + func loadFile(_ url: URL, kind: String) -> String? { "Not available here yet." } + func effectScope(capacity: Int) -> (samples: [Float], playhead: Float)? { nil } + func hiddenValue(_ key: String) -> String? { nil } + func setHiddenValue(_ value: String, key: String) {} +} + +/// Hand-built pieces of device editors (the Android app's bespoke editors), by +/// device. DeviceEditor asks here first and falls back to the card layout. Each +/// device's views live in their own file in this folder. +@MainActor +enum BespokeEditors { + /// Shown above the tabs (e.g. the Grain Cloud's source strip). + static func header(_ model: DeviceModel) -> AnyView? { + switch model.toolboxType { + case "GRAIN_CLOUD": return GrainCloudBespoke.header(model) + default: return nil + } + } + + /// Replaces the card pages entirely (devices whose Android editor is hand-built). + static func body(_ model: DeviceModel) -> AnyView? { + switch model.toolboxType { + case "DELAY": return DelayBespoke.body(model) + case "TAPE_ENGINE": return TapeEngineBespoke.body(model) + case "MIX_TIGHTENER": return MixTightenerBespoke.body(model) + case "GRANULAR": return GranularBespoke.body(model) + default: return nil + } + } + + /// A card drawing the generic VizView doesn't know (kind "wavetable"). + static func viz(_ viz: LayoutPanel.Viz, tone: Color, model: DeviceModel) -> AnyView? { + switch viz.kind { + case "wavetable": return WavetableBespoke.preview(osc: viz.osc ?? 1, tone: tone, model: model) + default: return nil + } + } + + /// A card's title-row action (LayoutPanel.action, e.g. "loadTable"). + static func action(_ action: String, tone: Color, model: DeviceModel) -> AnyView? { + switch action { + case "loadTable": return WavetableBespoke.loadTableAction(tone: tone, model: model) + default: return nil + } + } +} diff --git a/ios/app/FX/Editor/Bespoke/DelayBespoke.swift b/ios/app/FX/Editor/Bespoke/DelayBespoke.swift new file mode 100644 index 0000000..17d3655 --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/DelayBespoke.swift @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// The Delay's hand-built editor parts (stub: card layout until ported). +@MainActor +enum DelayBespoke { + static func body(_ model: DeviceModel) -> AnyView? { nil } +} diff --git a/ios/app/FX/Editor/Bespoke/GrainCloudBespoke.swift b/ios/app/FX/Editor/Bespoke/GrainCloudBespoke.swift new file mode 100644 index 0000000..dbeebe7 --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/GrainCloudBespoke.swift @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// The GrainCloud's hand-built editor parts (stub: card layout until ported). +@MainActor +enum GrainCloudBespoke { + static func header(_ model: DeviceModel) -> AnyView? { nil } +} diff --git a/ios/app/FX/Editor/Bespoke/GranularBespoke.swift b/ios/app/FX/Editor/Bespoke/GranularBespoke.swift new file mode 100644 index 0000000..bd15d6e --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/GranularBespoke.swift @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// The Granular's hand-built editor parts (stub: card layout until ported). +@MainActor +enum GranularBespoke { + static func body(_ model: DeviceModel) -> AnyView? { nil } +} diff --git a/ios/app/FX/Editor/Bespoke/MixTightenerBespoke.swift b/ios/app/FX/Editor/Bespoke/MixTightenerBespoke.swift new file mode 100644 index 0000000..c379ee5 --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/MixTightenerBespoke.swift @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// The MixTightener's hand-built editor parts (stub: card layout until ported). +@MainActor +enum MixTightenerBespoke { + static func body(_ model: DeviceModel) -> AnyView? { nil } +} diff --git a/ios/app/FX/Editor/Bespoke/TapeEngineBespoke.swift b/ios/app/FX/Editor/Bespoke/TapeEngineBespoke.swift new file mode 100644 index 0000000..72ea1ca --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/TapeEngineBespoke.swift @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// The TapeEngine's hand-built editor parts (stub: card layout until ported). +@MainActor +enum TapeEngineBespoke { + static func body(_ model: DeviceModel) -> AnyView? { nil } +} diff --git a/ios/app/FX/Editor/Bespoke/WavetableBespoke.swift b/ios/app/FX/Editor/Bespoke/WavetableBespoke.swift new file mode 100644 index 0000000..6e1f748 --- /dev/null +++ b/ios/app/FX/Editor/Bespoke/WavetableBespoke.swift @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +/// The Wavetable's table drawing and LOAD TABLE (stub until ported). +@MainActor +enum WavetableBespoke { + static func preview(osc: Int, tone: Color, model: DeviceModel) -> AnyView? { nil } + static func loadTableAction(tone: Color, model: DeviceModel) -> AnyView? { nil } +} diff --git a/ios/app/FX/Editor/DeviceEditor.swift b/ios/app/FX/Editor/DeviceEditor.swift index 85274e4..6f3a8e0 100644 --- a/ios/app/FX/Editor/DeviceEditor.swift +++ b/ios/app/FX/Editor/DeviceEditor.swift @@ -33,6 +33,10 @@ struct DeviceEditor: View { } } } + if let h = BespokeEditors.header(model) { h } + if let b = BespokeEditors.body(model) { + SnapScroll { b } + } else { if pages.count > 1 { HStack(spacing: 4) { ForEach(pages.indices, id: \.self) { i in @@ -55,6 +59,7 @@ struct DeviceEditor: View { } } SnapScroll { cards } + } } .padding(10) .background(Theme.background) @@ -79,9 +84,12 @@ struct CardView: View { HStack(spacing: 6) { Rectangle().fill(tone).frame(width: 8, height: 8) Text(panel.title.uppercased()).font(Theme.mono(11)).foregroundColor(tone) + Spacer(minLength: 0) + if let a = panel.action, let v = BespokeEditors.action(a, tone: tone, model: model) { v } } - if let viz = panel.viz, viz.kind != "wavetable" { - VizView(viz: viz, tone: tone, model: model) + if let viz = panel.viz { + if let v = BespokeEditors.viz(viz, tone: tone, model: model) { v } + else if viz.kind != "wavetable" { VizView(viz: viz, tone: tone, model: model) } } if let captions = panel.faders { FaderBank(infos: infos, captions: captions, scale: panel.faderScale ?? 1, tone: tone, model: model) diff --git a/ios/app/FX/Editor/DeviceModel.swift b/ios/app/FX/Editor/DeviceModel.swift index 44aacea..f8b6679 100644 --- a/ios/app/FX/Editor/DeviceModel.swift +++ b/ios/app/FX/Editor/DeviceModel.swift @@ -30,6 +30,8 @@ final class DeviceModel: ObservableObject { let presetNames: [String] @Published private(set) var values: [String: Float] = [:] @Published var presetName: String? + /// Data the DSP owns and non-parameter settings (see Bespoke/Bespoke.swift). + var data: DeviceDataSource? private let write: (String, Float) -> Void private let applyPresetNamed: (String) -> Void @@ -70,6 +72,7 @@ final class DeviceModel: ObservableObject { applyPreset: { name in if let p = presets.first(where: { $0.name == name }) { au.currentPreset = p } }, reread: { Dictionary(uniqueKeysWithValues: all.map { ($0.identifier, $0.value) }) }) presetName = au.currentPreset?.name + data = AUDataSource(au: au) token = au.parameterTree?.token(byAddingParameterObserver: { [weak self] address, value in DispatchQueue.main.async { guard let self = self, let p = all.first(where: { $0.address == address }) else { return } diff --git a/ios/app/FX/SizzleDeviceAU.h b/ios/app/FX/SizzleDeviceAU.h index 4f92840..c47b8fa 100644 --- a/ios/app/FX/SizzleDeviceAU.h +++ b/ios/app/FX/SizzleDeviceAU.h @@ -35,6 +35,10 @@ NS_ASSUME_NONNULL_BEGIN - (AUValue)defaultValueForParameter:(AUParameter *)param; /// Whether the parameter takes whole numbers only. - (BOOL)isIntegerParameter:(AUParameter *)param; +/// A setting that isn't an AU parameter (e.g. the Mix Tightener's stage trims), +/// as stored text, or nil; saved with the AU's state. Main thread. +- (nullable NSString *)hiddenValueForKey:(NSString *)key; +- (void)setHiddenValue:(NSString *)value forKey:(NSString *)key; /// Its label in Sizzle's spec, e.g. "Osc1 Level", "Wet (dB)" (displayName is the same). - (NSString *)specLabelForParameter:(AUParameter *)param; diff --git a/ios/app/FX/SizzleDeviceAU.mm b/ios/app/FX/SizzleDeviceAU.mm index d57244f..c9914ac 100644 --- a/ios/app/FX/SizzleDeviceAU.mm +++ b/ios/app/FX/SizzleDeviceAU.mm @@ -160,6 +160,17 @@ static NSString *const kStateKey = @"sizzleValues"; return @(_k->spec->params[param.address].label); } +- (NSString *)hiddenValueForKey:(NSString *)key { + [self pullBase]; + return _base.has(key.UTF8String) ? @(_base.s(key.UTF8String)) : nil; +} + +- (void)setHiddenValue:(NSString *)value forKey:(NSString *)key { + [self pullBase]; + _base.set(key.UTF8String, value.UTF8String); + _k->publish(_base); +} + #pragma mark - presets and state - (void)buildFactoryPresets { diff --git a/ios/app/Host/Bridging.h b/ios/app/Host/Bridging.h index 31156b5..f0dcc48 100644 --- a/ios/app/Host/Bridging.h +++ b/ios/app/Host/Bridging.h @@ -5,3 +5,5 @@ #import "SizzleSession+Tracker.h" #import "SizzleSession+Mix.h" #import "SizzleSession+Setup.h" +#import "SizzleSession+Sources.h" +#import "SizzleSession+Viz.h" diff --git a/ios/app/Host/SizzleSession+Sources.h b/ios/app/Host/SizzleSession+Sources.h new file mode 100644 index 0000000..a151210 --- /dev/null +++ b/ios/app/Host/SizzleSession+Sources.h @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import "SizzleSession.h" + +NS_ASSUME_NONNULL_BEGIN + +/// API for the device editors' Sources views beyond SizzleSession.h. +@interface SizzleSession (Sources) +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/app/Host/SizzleSession+Sources.mm b/ios/app/Host/SizzleSession+Sources.mm new file mode 100644 index 0000000..58f69a9 --- /dev/null +++ b/ios/app/Host/SizzleSession+Sources.mm @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import "SizzleSession+Sources.h" +#import "SizzleSession+Internal.h" + +using namespace sizzle; + +@implementation SizzleSession (Sources) +@end diff --git a/ios/app/Host/SizzleSession+Viz.h b/ios/app/Host/SizzleSession+Viz.h new file mode 100644 index 0000000..1763365 --- /dev/null +++ b/ios/app/Host/SizzleSession+Viz.h @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import "SizzleSession.h" + +NS_ASSUME_NONNULL_BEGIN + +/// API for the device editors' Viz views beyond SizzleSession.h. +@interface SizzleSession (Viz) +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/app/Host/SizzleSession+Viz.mm b/ios/app/Host/SizzleSession+Viz.mm new file mode 100644 index 0000000..23962c0 --- /dev/null +++ b/ios/app/Host/SizzleSession+Viz.mm @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +#import "SizzleSession+Viz.h" +#import "SizzleSession+Internal.h" + +using namespace sizzle; + +@implementation SizzleSession (Viz) +@end diff --git a/ios/app/Host/SlotDataSource.swift b/ios/app/Host/SlotDataSource.swift new file mode 100644 index 0000000..baec9bb --- /dev/null +++ b/ios/app/Host/SlotDataSource.swift @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import Foundation + +/// DeviceDataSource for toolbox slot [slot] of the app's song. Each device's +/// support lives in an extension in Host/Bespoke/. +@MainActor +final class SlotDataSource: DeviceDataSource { + let session: SizzleSession + let slot: Int + init(session: SizzleSession, slot: Int) { self.session = session; self.slot = slot } + + // Hidden settings are plain slot values here. + func hiddenValue(_ key: String) -> String? { + let v = session.value(ofSlot: slot, key: key) + return v.isEmpty ? nil : v + } + func setHiddenValue(_ value: String, key: String) { session.setValue(value, ofSlot: slot, key: key) } +} diff --git a/ios/app/Host/SlotDeviceModel.swift b/ios/app/Host/SlotDeviceModel.swift index 845b636..4e827da 100644 --- a/ios/app/Host/SlotDeviceModel.swift +++ b/ios/app/Host/SlotDeviceModel.swift @@ -31,6 +31,7 @@ extension DeviceModel { }, applyPreset: { name in session.applyFactoryPreset(name, toSlot: slot) }, reread: read) + data = SlotDataSource(session: session, slot: slot) } } diff --git a/ios/app/tests/ScreenBridging.h b/ios/app/tests/ScreenBridging.h index f5d628d..6c640d3 100644 --- a/ios/app/tests/ScreenBridging.h +++ b/ios/app/tests/ScreenBridging.h @@ -4,3 +4,5 @@ #import "SizzleSession+Tracker.h" #import "SizzleSession+Mix.h" #import "SizzleSession+Setup.h" +#import "SizzleSession+Sources.h" +#import "SizzleSession+Viz.h"