iOS 0.6.0: milestone 5 (recording, MIDI, input bindings, themes, bundles, backups)

- Master recording (MasterSink ring + writer thread) and the sample recorder
- CoreMIDI in/out: sound module, clock send/follow, virtual "Sizzle" ports;
  platform-free parser/module/clock in core (midi_test)
- Hardware keyboard and gamepads via GameController; rebindable keyboard,
  gamepad and MIDI CC actions; per-parameter MIDI learn
- Colour themes (.szt), project bundles (.szgz), backup & restore;
  ZIP in core with zlib (zip_test against jar and unzip)
- Persistent app settings; audio pauses in the background unless sound module

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 14:26:01 +01:00
co-authored by Claude Opus 5.5
parent 435305e42a
commit 64e21e0bcc
54 changed files with 3303 additions and 97 deletions
+16
View File
@@ -50,6 +50,22 @@ extension EnvironmentValues {
}
}
/// The app's microphone recorder for editors that take a recording (the Grain
/// Cloud's RECORD); nil in the plugin, which shows no RECORD button.
struct DeviceRecordControl {
let isRecording: Bool
let toggle: () -> Void
}
private struct DeviceRecorderKey: EnvironmentKey {
static let defaultValue: DeviceRecordControl? = nil
}
extension EnvironmentValues {
var deviceRecorder: DeviceRecordControl? {
get { self[DeviceRecorderKey.self] }
set { self[DeviceRecorderKey.self] = newValue }
}
}
/// 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.
+1 -1
View File
@@ -18,7 +18,7 @@ enum DelayBespoke {
"1/4T", "1/8", "1/16.", "1/8T", "1/16", "1/16T"]
static var divisions: [String] { Layouts.file?.delayDivisions ?? fallbackDivisions }
/// Android's default theme's playhead green (the selected-step band).
static let band = Color(red: 0x7C / 255.0, green: 0xFC / 255.0, blue: 0x9A / 255.0)
static var band: Color { Theme.playhead }
}
private struct DelayEditorView: View {
@@ -14,7 +14,8 @@ protocol SampleLengthSource: AnyObject {
/// The Grain Cloud's source strip (Android's GrainCloudEditor.kt): load a WAV (or
/// SF2/XI) as the cloud's own source, and see the source with its START..END region
/// lit. The settings themselves are the card pages below it. (RECORD isn't ported.)
/// lit. The settings themselves are the card pages below it. RECORD (the app only)
/// makes a microphone take the source.
@MainActor
enum GrainCloudBespoke {
static func header(_ model: DeviceModel) -> AnyView? { AnyView(GrainSourceStrip(model: model)) }
@@ -39,6 +40,7 @@ struct GrainSourceStrip: View {
@ObservedObject var model: DeviceModel
@State private var pickerShown = false
@Environment(\.deviceFilePicker) private var hostPicker
@Environment(\.deviceRecorder) private var recorder
@State private var importError: String?
/// Bumped while a built-in source is still being rendered, to look again.
@State private var retry = 0
@@ -63,6 +65,15 @@ struct GrainSourceStrip: View {
.overlay(Rectangle().stroke(Theme.accent.opacity(0.6), lineWidth: 1))
.contentShape(Rectangle())
.onTapGesture { if let pick = hostPicker { pick { url in load(url) } } else { pickerShown = true } }
if let rec = recorder {
Text(rec.isRecording ? "■ STOP REC" : "● RECORD").font(Theme.mono(12))
.foregroundColor(rec.isRecording ? Theme.background : Theme.accent)
.padding(.horizontal, 10).padding(.vertical, 6)
.background(rec.isRecording ? Theme.accent : Theme.surface)
.overlay(Rectangle().stroke(Theme.accent.opacity(0.6), lineWidth: 1))
.contentShape(Rectangle())
.onTapGesture(perform: rec.toggle)
}
Spacer(minLength: 0)
}
Text(caption).font(Theme.mono(10)).foregroundColor(Theme.dim)
+31 -7
View File
@@ -18,14 +18,38 @@ struct SnapScroll<Content: View>: View {
}
}
/// Sizzle's dark retro palette (Android's default theme) and the card tones.
/// A colour theme (Android's RetroPalette), colours as 0xRRGGBB.
struct Palette: Equatable {
var name: String
var background, surface, grid, text, textDim, accent, beat, bar, playhead, danger: UInt32
static let amber = Palette(name: "Amber CRT", background: 0x0B0D0E, surface: 0x15181A, grid: 0x23282B,
text: 0xCFE8D8, textDim: 0x6E7C74, accent: 0xF2C14E, beat: 0x141C1A, bar: 0x1E2A20,
playhead: 0x7CFC9A, danger: 0xE05A4B)
static let ice = Palette(name: "Ice Terminal", background: 0x07090F, surface: 0x10151F, grid: 0x1E2633,
text: 0xCFE0FF, textDim: 0x63708A, accent: 0x62B6FF, beat: 0x121A26, bar: 0x1B2740,
playhead: 0x8AF0FF, danger: 0xE05A7A)
static let stock = [amber, ice]
static func color(_ rgb: UInt32) -> Color {
Color(red: Double((rgb >> 16) & 0xFF) / 255, green: Double((rgb >> 8) & 0xFF) / 255, blue: Double(rgb & 0xFF) / 255)
}
}
/// Sizzle's retro palette (the current theme; the plugins always use the default)
/// and the card tones. The app redraws everything when the theme changes.
enum Theme {
static let background = Color(red: 0.07, green: 0.08, blue: 0.09)
static let surface = Color(red: 0.11, green: 0.12, blue: 0.14)
static let grid = Color(white: 0.24)
static let text = Color(white: 0.92)
static let dim = Color(white: 0.58)
static let accent = Color(red: 0.96, green: 0.76, blue: 0.29)
static var current = Palette.amber
static var background: Color { Palette.color(current.background) }
static var surface: Color { Palette.color(current.surface) }
static var grid: Color { Palette.color(current.grid) }
static var text: Color { Palette.color(current.text) }
static var dim: Color { Palette.color(current.textDim) }
static var accent: Color { Palette.color(current.accent) }
static var beat: Color { Palette.color(current.beat) }
static var bar: Color { Palette.color(current.bar) }
static var playhead: Color { Palette.color(current.playhead) }
static var danger: Color { Palette.color(current.danger) }
static func tone(_ t: LayoutPanel.Tone) -> Color {
switch t {
+1 -1
View File
@@ -152,7 +152,7 @@ struct CardView: View {
public final class SizzleEditorFactory: NSObject {
@objc public static func makeEditor(for au: SizzleDeviceAU) -> UIViewController {
let vc = UIHostingController(rootView: DeviceEditor(model: DeviceModel(au: au)))
vc.view.backgroundColor = UIColor(red: 0.07, green: 0.08, blue: 0.09, alpha: 1)
vc.view.backgroundColor = UIColor(Theme.background)
return vc
}
}
+6
View File
@@ -101,6 +101,12 @@ final class DeviceModel: ObservableObject {
return info.choices[Swift.max(0, Swift.min(info.choices.count - 1, i))]
}
/// Read the values again (changed elsewhere: a MIDI CC bound to a parameter).
func refresh() {
let v = reread()
if v != values { values = v }
}
func applyPreset(named name: String) {
applyPresetNamed(name)
presetName = name