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:
co-authored by
Claude Opus 5.5
parent
435305e42a
commit
64e21e0bcc
@@ -7,9 +7,9 @@ import SwiftUI
|
||||
/// components/Widgets.kt (RetroButton, RepeatButton, RetroDropdown, SectionLabel).
|
||||
/// Namespaced so they can't clash with the other screens' own.
|
||||
enum MixKit {
|
||||
/// Android palette colours the shared Theme doesn't carry.
|
||||
static let playhead = Color(red: 0x7C / 255, green: 0xFC / 255, blue: 0x9A / 255)
|
||||
static let danger = Color(red: 0xE0 / 255, green: 0x5A / 255, blue: 0x4B / 255)
|
||||
/// The theme's playhead and danger colours.
|
||||
static var playhead: Color { Theme.playhead }
|
||||
static var danger: Color { Theme.danger }
|
||||
|
||||
/// Pitch.name: 60 -> "C-4", 61 -> "C#4".
|
||||
static func pitchName(_ midi: Int) -> String {
|
||||
|
||||
@@ -28,18 +28,53 @@ private struct MixBody: View {
|
||||
if inst { instruments.append(i) } else { effects.append(i) }
|
||||
}
|
||||
let names = (0..<16).map { session.name(ofSlot: $0) }
|
||||
return GeometryReader { geo in
|
||||
let landscape = geo.size.width > geo.size.height
|
||||
HStack(spacing: 6) {
|
||||
ForEach(0..<4, id: \.self) { ch in
|
||||
ChannelStrip(ch: ch, landscape: landscape, instruments: instruments, effects: effects, names: names,
|
||||
open: { ToolboxNav.open($0, app: app, returnTab: .mix) })
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
return VStack(spacing: 0) {
|
||||
RecordToolbar(session: session)
|
||||
GeometryReader { geo in
|
||||
let landscape = geo.size.width > geo.size.height
|
||||
HStack(spacing: 6) {
|
||||
ForEach(0..<4, id: \.self) { ch in
|
||||
ChannelStrip(ch: ch, landscape: landscape, instruments: instruments, effects: effects, names: names,
|
||||
open: { ToolboxNav.open($0, app: app, returnTab: .mix) })
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
.padding(6)
|
||||
}
|
||||
}
|
||||
.background(Theme.background)
|
||||
}
|
||||
}
|
||||
|
||||
/// Android's RecordToolbar: arm the master recording (it starts on Play or an
|
||||
/// external MIDI clock Start), the FX tail after the stop, and the last take. Takes
|
||||
/// are saved in Sizzle's Recordings folder (Files app); SHARE sends the last one.
|
||||
private struct RecordToolbar: View {
|
||||
let session: SizzleSession
|
||||
|
||||
var body: some View {
|
||||
let recording = session.masterRecording
|
||||
let last = session.lastRecordingURL
|
||||
let status: String = recording ? "recording…"
|
||||
: session.recordArmed ? "armed — starts on play or MIDI clock start"
|
||||
: last.map { "saved \($0.lastPathComponent)" } ?? "master → WAV (Files › Sizzle › Recordings)"
|
||||
MixKit.HScroll {
|
||||
HStack(spacing: 6) {
|
||||
MixKit.Button(label: recording ? "● REC" : "● ARM", active: session.recordArmed && !recording, danger: recording) {
|
||||
session.recordArmed = !session.recordArmed
|
||||
}
|
||||
MixKit.Dropdown(label: "TAIL", options: [0, 1, 2, 3, 4], selected: session.recordTailBars,
|
||||
optionLabel: { "\($0) bar" + ($0 == 1 ? "" : "s") },
|
||||
onSelect: { session.recordTailBars = $0; AppSettings.shared.recordTailBars = $0 })
|
||||
if let url = last, !recording {
|
||||
MixKit.Button(label: "SHARE") { ShareSheet.present(url) }
|
||||
}
|
||||
Text(status).font(Theme.mono(11)).foregroundColor(Theme.dim).lineLimit(1)
|
||||
}
|
||||
.padding(6)
|
||||
}
|
||||
.background(Theme.background)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(Theme.surface)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +168,7 @@ private struct VolumeFader: View {
|
||||
ZStack(alignment: .top) {
|
||||
Theme.background
|
||||
Rectangle().fill(Theme.accent.opacity(0.30)).frame(height: vol * h).offset(y: top)
|
||||
MeterLayer(ch: ch, volume: vol)
|
||||
if AppSettings.shared.vuMeters { MeterLayer(ch: ch, volume: vol) }
|
||||
Rectangle().fill(Theme.accent).frame(height: 3).offset(y: min(max(top - 1.5, 0), max(h - 3, 0)))
|
||||
}
|
||||
.frame(width: g.size.width, height: h, alignment: .top)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// One device kind's bindings (Android's binding sections and BindingRow): each
|
||||
/// action with its current control, LEARN (then press the key / combo or move the
|
||||
/// MIDI control) and ✕ to unbind.
|
||||
struct BindingsSheet: View {
|
||||
let source: InputSource
|
||||
@ObservedObject private var bindings = InputBindings.shared
|
||||
@ObservedObject private var input = InputController.shared
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
private struct Group { let title: String; let actions: [(id: String, label: String)] }
|
||||
|
||||
private var groups: [Group] {
|
||||
var g = [
|
||||
Group(title: "Transport", actions: [("playPause", "Play / Pause"), ("stop", "Stop"), ("loop", "Toggle Loop")]),
|
||||
Group(title: "Navigation", actions: [("up", "Cursor Up"), ("down", "Cursor Down"), ("left", "Cursor Left"), ("right", "Cursor Right")]),
|
||||
Group(title: "Editing", actions: [("increment", "Value +"), ("decrement", "Value -"), ("clear", "Clear Cell")]
|
||||
+ (source == .keyboard ? [("noteOff", "Note Off")] : [])),
|
||||
]
|
||||
if source == .keyboard {
|
||||
g.append(Group(title: "Columns", actions: [("nextColumn", "Next Column"), ("prevColumn", "Prev Column")]))
|
||||
g.append(Group(title: "Octave", actions: [("octaveDown", "Octave Down"), ("octaveUp", "Octave Up")]))
|
||||
}
|
||||
g.append(Group(title: "Tabs", actions: [("nextTab", "Next Tab"), ("prevTab", "Prev Tab")]))
|
||||
return g
|
||||
}
|
||||
|
||||
private var title: String {
|
||||
switch source {
|
||||
case .gamepad: return "Gamepad Bindings"
|
||||
case .keyboard: return "Keyboard Hotkeys"
|
||||
default: return "MIDI Bindings"
|
||||
}
|
||||
}
|
||||
|
||||
private var hint: String {
|
||||
switch source {
|
||||
case .gamepad: return "LEARN, then press a button, D-pad direction or stick direction — or hold one and press another for a combo."
|
||||
case .keyboard: return "LEARN, then press a key. Unbound letter keys play the tracker piano (Z…M, Q…U)."
|
||||
default: return "LEARN, then press a pad or move a control on your MIDI controller (CC)."
|
||||
}
|
||||
}
|
||||
|
||||
private func label(_ id: String) -> String? {
|
||||
switch source {
|
||||
case .gamepad: return bindings.chordFor(id).map(InputBindings.chordLabel)
|
||||
case .keyboard: return bindings.keyFor(id).map(InputBindings.keyLabel)
|
||||
default: return bindings.ccFor(id).map { "CC \($0)" }
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack {
|
||||
Text(title).font(.system(size: 19, weight: .semibold)).foregroundColor(Theme.accent)
|
||||
Spacer()
|
||||
SetupButton(title: "Defaults") { bindings.resetDefaults(source) }
|
||||
SetupButton(title: "Done", kind: .filled) { dismiss() }
|
||||
}
|
||||
Text(hint).font(.system(size: 12)).foregroundColor(Theme.dim)
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
ForEach(groups, id: \.title) { group in
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(group.title.uppercased()).font(.system(size: 11, weight: .semibold)).foregroundColor(Theme.dim)
|
||||
ForEach(group.actions, id: \.id) { a in row(a.id, a.label) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.background(Theme.surface.ignoresSafeArea())
|
||||
.preferredColorScheme(.dark)
|
||||
.onDisappear { input.cancelLearn() }
|
||||
}
|
||||
|
||||
private func row(_ id: String, _ text: String) -> some View {
|
||||
let listening = input.learnTarget == id
|
||||
let bound = label(id)
|
||||
return HStack(spacing: 10) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(text).font(.system(size: 15)).foregroundColor(Theme.text)
|
||||
Text(bound ?? "unbound").font(.system(size: 12, design: .monospaced)).foregroundColor(bound == nil ? Theme.dim : Theme.accent)
|
||||
}
|
||||
Spacer()
|
||||
SetupButton(title: listening ? "Listening…" : "Learn", kind: listening ? .filled : .outlined) {
|
||||
if listening { input.cancelLearn() } else { input.beginLearn(id, source: source) }
|
||||
}
|
||||
if bound != nil {
|
||||
Button { bindings.clear(id, source: source) } label: {
|
||||
Image(systemName: "xmark").foregroundColor(Theme.dim).frame(width: 36, height: 36)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// A labelled switch (Android's ToggleRow).
|
||||
struct SetupToggle: View {
|
||||
let title: String
|
||||
let detail: String
|
||||
let isOn: Bool
|
||||
let onChange: (Bool) -> Void
|
||||
|
||||
var body: some View {
|
||||
Toggle(isOn: Binding(get: { isOn }, set: onChange)) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(title).font(.system(size: 15, weight: .medium)).foregroundColor(Theme.text)
|
||||
Text(detail).font(.system(size: 12)).foregroundColor(Theme.dim).fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
.tint(Theme.accent)
|
||||
}
|
||||
}
|
||||
|
||||
/// Audio Devices: iOS picks the route; this shows it and offers the system picker.
|
||||
struct AudioDevicesCard: View {
|
||||
var body: some View {
|
||||
SetupCard(title: "Audio Devices", subtitle: "Playback and recording go where iOS routes audio") {
|
||||
AudioRouteView()
|
||||
SetupNote("Plug in an audio interface or headphones, or pick AirPlay / Bluetooth with the route button. " +
|
||||
"The sample recorder records from the current input.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Recording: where master takes go and the FX tail (the ARM button is on Mix).
|
||||
struct RecordingCard: View {
|
||||
@ObservedObject var settings = AppSettings.shared
|
||||
|
||||
var body: some View {
|
||||
SetupCard(title: "Recording", subtitle: "Record the master bus to WAV files") {
|
||||
HStack(spacing: 8) {
|
||||
Text("FX tail after stop").font(.system(size: 15)).foregroundColor(Theme.text)
|
||||
Spacer()
|
||||
ForEach(0..<5, id: \.self) { n in
|
||||
SetupButton(title: "\(n)", kind: settings.recordTailBars == n ? .filled : .outlined) {
|
||||
settings.recordTailBars = n
|
||||
SizzleSession.shared.recordTailBars = n
|
||||
}
|
||||
}
|
||||
}
|
||||
SetupNote("Arm with ● ARM on the Mix tab; the take starts on Play (or an external MIDI clock Start) and " +
|
||||
"ends this many bars after the stop. Takes are in Files › On My iPad › Sizzle › Recordings.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface: the mixer meters (Android's InterfaceCard).
|
||||
struct InterfaceCard: View {
|
||||
@ObservedObject var settings = AppSettings.shared
|
||||
|
||||
var body: some View {
|
||||
SetupCard(title: "Interface", subtitle: "On-screen display options") {
|
||||
SetupToggle(title: "Mixer VU meters", detail: "Show live level meters inside the mixer volume faders.",
|
||||
isOn: settings.vuMeters) { settings.vuMeters = $0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Color Theme: pick, import, export or delete (Android's ThemeCard).
|
||||
struct ThemeCard: View {
|
||||
@ObservedObject var library = ThemeLibrary.shared
|
||||
let onImport: () -> Void
|
||||
let onDelete: (String) -> Void
|
||||
let onError: (String) -> Void
|
||||
|
||||
var body: some View {
|
||||
let current = Theme.current.name
|
||||
SetupCard(title: "Color Theme", subtitle: "Pick, import, export or delete a palette") {
|
||||
HStack(spacing: 8) {
|
||||
Menu {
|
||||
ForEach(library.names, id: \.self) { name in
|
||||
Button(name + (library.isStock(name) ? " (stock)" : "")) { library.select(name) }
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 6) {
|
||||
Text(current).font(.system(size: 15, weight: .medium)).lineLimit(1)
|
||||
Image(systemName: "chevron.down").font(.system(size: 12))
|
||||
}
|
||||
.foregroundColor(Theme.text)
|
||||
.padding(.horizontal, 14).frame(minHeight: 38)
|
||||
.overlay(Capsule().stroke(Theme.grid, lineWidth: 1))
|
||||
}
|
||||
if !library.isStock(current) {
|
||||
SetupButton(title: "Delete", kind: .danger) { onDelete(current) }
|
||||
}
|
||||
}
|
||||
SetupDivider()
|
||||
HStack(spacing: 8) {
|
||||
SetupButton(title: "Export .szt", icon: "square.and.arrow.up") {
|
||||
do { ShareSheet.present(try library.exportFile()) } catch { onError(error.localizedDescription) }
|
||||
}
|
||||
SetupButton(title: "Import .szt", icon: "square.and.arrow.down.on.square", action: onImport)
|
||||
}
|
||||
SetupNote("Stock themes can't be deleted; imported .szt themes appear in the list.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// MIDI Sync: clock out / in, sound-module mode and the MIDI sources (Android's
|
||||
/// MidiSyncCard + MidiInputsList).
|
||||
struct MidiSyncCard: View {
|
||||
@ObservedObject var settings = AppSettings.shared
|
||||
@ObservedObject var midi = MidiSources.shared
|
||||
|
||||
var body: some View {
|
||||
SetupCard(title: "MIDI Sync", subtitle: "MIDI clock and notes over USB, Bluetooth, network and other apps") {
|
||||
SetupToggle(title: "Send MIDI clock",
|
||||
detail: "Send clock, start/stop and the tracks' notes to MIDI devices and apps, so Sizzle drives them.",
|
||||
isOn: settings.sendMidiClock) { settings.sendMidiClock = $0; SizzleMidi.shared.sendClock = $0 }
|
||||
SetupDivider()
|
||||
SetupToggle(title: "Receive MIDI clock",
|
||||
detail: "Follow an external clock's tempo, and start/stop Sizzle's own song with it " +
|
||||
"(tempo only while Sizzle runs as a MIDI sound module).",
|
||||
isOn: settings.receiveMidiClock) { settings.receiveMidiClock = $0; SizzleMidi.shared.receiveClock = $0 }
|
||||
SetupDivider()
|
||||
SetupToggle(title: "Keep running as MIDI sound module",
|
||||
detail: "Keep playing incoming MIDI with Sizzle in the background (another app can use it as its synth). " +
|
||||
"Sizzle's own song doesn't start from the other app's clock meanwhile.",
|
||||
isOn: settings.soundModule) { settings.soundModule = $0; SizzleMidi.shared.soundModule = $0 }
|
||||
SetupDivider()
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("MIDI inputs").font(.system(size: 15, weight: .medium)).foregroundColor(Theme.text)
|
||||
Text("Sources Sizzle listens to. Each mixer track plays the notes on its MIDI channel. " +
|
||||
"Other apps can also send to the \"Sizzle\" MIDI destination.")
|
||||
.font(.system(size: 12)).foregroundColor(Theme.dim).fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Spacer()
|
||||
SetupButton(title: "Reconnect") { SizzleMidi.shared.reconnect() }
|
||||
}
|
||||
if midi.sources.isEmpty {
|
||||
SetupNote("No MIDI sources found.")
|
||||
}
|
||||
ForEach(midi.sources, id: \.key) { src in
|
||||
SetupToggle(title: src.name, detail: !src.enabled ? "Off" : src.connected ? "Listening" : "Not connected (tap Reconnect)",
|
||||
isOn: src.enabled) { on in
|
||||
if on { settings.midiSourcesOff.remove(src.key) } else { settings.midiSourcesOff.insert(src.key) }
|
||||
SizzleMidi.shared.setSourceKey(src.key, enabled: on)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// SizzleMidi's source list as an observable (refreshed on its change callback).
|
||||
@MainActor
|
||||
final class MidiSources: ObservableObject {
|
||||
static let shared = MidiSources()
|
||||
@Published private(set) var sources: [SizzleMidiSource] = []
|
||||
|
||||
private init() {
|
||||
sources = SizzleMidi.shared.sources
|
||||
SizzleMidi.shared.onSourcesChanged = { [weak self] in self?.sources = SizzleMidi.shared.sources }
|
||||
}
|
||||
}
|
||||
|
||||
/// The three binding editors (Android's Gamepad Bindings / Keyboard Hotkeys / MIDI Bindings).
|
||||
struct BindingsCard: View {
|
||||
let open: (InputSource) -> Void
|
||||
|
||||
var body: some View {
|
||||
SetupCard(title: "Controls", subtitle: "Hardware keyboard, gamepad and MIDI controller bindings") {
|
||||
SetupRow(title: "Gamepad Bindings", detail: "Rebind buttons, sticks and combos", icon: "gamecontroller") { open(.gamepad) }
|
||||
SetupDivider()
|
||||
SetupRow(title: "Keyboard Hotkeys", detail: "Rebind keys; Z…M and Q…U play notes", icon: "keyboard") { open(.keyboard) }
|
||||
SetupDivider()
|
||||
SetupRow(title: "MIDI Bindings", detail: "MIDI-learn controls for transport and editing", icon: "pianokeys") { open(.midi) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Backup & Restore (Android's BackupCard).
|
||||
struct BackupCard: View {
|
||||
let onBackup: () -> Void
|
||||
let onRestore: () -> Void
|
||||
|
||||
var body: some View {
|
||||
SetupCard(title: "Backup & Restore", subtitle: "Save or restore all songs, presets, themes & settings") {
|
||||
HStack(spacing: 8) {
|
||||
SetupButton(title: "Back up", icon: "externaldrive", kind: .filled, action: onBackup)
|
||||
SetupButton(title: "Restore", icon: "arrow.counterclockwise", action: onRestore)
|
||||
}
|
||||
SetupNote("A backup is one .zip with every saved song, preset, theme, sample, the open song and the settings. " +
|
||||
"Restoring replaces all of them.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import SwiftUI
|
||||
/// buttons, link rows, rows for sections still to come, and the modal dialog.
|
||||
/// SwiftUI only (the Mac snapshot tool renders them).
|
||||
enum SetupStyle {
|
||||
static let danger = Color(red: 0.86, green: 0.27, blue: 0.27)
|
||||
static var danger: Color { Theme.danger }
|
||||
static let corner: CGFloat = 10
|
||||
}
|
||||
|
||||
@@ -145,6 +145,8 @@ enum SetupDialog: Identifiable {
|
||||
case save
|
||||
case confirmNew
|
||||
case confirmDelete(String)
|
||||
case confirmDeleteTheme(String)
|
||||
case confirmRestore
|
||||
case message(title: String, text: String)
|
||||
|
||||
var id: String {
|
||||
@@ -152,6 +154,8 @@ enum SetupDialog: Identifiable {
|
||||
case .save: return "save"
|
||||
case .confirmNew: return "new"
|
||||
case .confirmDelete(let n): return "delete:" + n
|
||||
case .confirmDeleteTheme(let n): return "theme:" + n
|
||||
case .confirmRestore: return "restore"
|
||||
case .message(let t, let m): return "msg:" + t + m
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,28 @@ enum SetupFiles {
|
||||
return url
|
||||
}
|
||||
|
||||
/// Writes [data] to a fresh temporary folder as "<name>.<ext>".
|
||||
static func export(_ data: Data, name: String, ext: String) throws -> URL {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent("Exports", isDirectory: true)
|
||||
try? FileManager.default.removeItem(at: root)
|
||||
let dir = root.appendingPathComponent(UUID().uuidString, isDirectory: true)
|
||||
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
let url = dir.appendingPathComponent(name).appendingPathExtension(ext)
|
||||
try data.write(to: url)
|
||||
return url
|
||||
}
|
||||
|
||||
/// Reads a picked file (security-scoped), refusing anything over [limit] bytes.
|
||||
static func readData(_ url: URL, limit: Int) throws -> Data {
|
||||
let scoped = url.startAccessingSecurityScopedResource()
|
||||
defer { if scoped { url.stopAccessingSecurityScopedResource() } }
|
||||
let size = (try? url.resourceValues(forKeys: [.fileSizeKey]).fileSize) ?? 0
|
||||
guard size <= limit else { throw SetupFileError.tooLarge }
|
||||
let data = try Data(contentsOf: url)
|
||||
guard data.count <= limit else { throw SetupFileError.tooLarge }
|
||||
return data
|
||||
}
|
||||
|
||||
/// The song name as a file name: path separators replaced, blank → "untitled".
|
||||
static func fileStem(_ name: String) -> String {
|
||||
let trimmed = name.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
@@ -42,7 +64,7 @@ enum SetupFileError: LocalizedError {
|
||||
case tooLarge, notText
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .tooLarge: return "The file is too large to be a Sizzle song."
|
||||
case .tooLarge: return "The file is too large for Sizzle."
|
||||
case .notText: return "Couldn't read the selected file."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,9 @@ final class SetupModel: ObservableObject {
|
||||
|
||||
// MARK: Export / import
|
||||
|
||||
/// What a picked file is for.
|
||||
enum Format {
|
||||
case sng, project
|
||||
case sng, project, theme, backup
|
||||
var ext: String { self == .sng ? "sng" : "szg" }
|
||||
}
|
||||
|
||||
@@ -77,11 +78,47 @@ final class SetupModel: ObservableObject {
|
||||
/// Imports a picked file: a .sng into the open song (notes, blocks,
|
||||
/// arrangement), or a project replacing it.
|
||||
func importFile(_ url: URL, as format: Format) throws {
|
||||
if format == .project {
|
||||
// A bundle (.szgz, a ZIP) or a plain project (.szg).
|
||||
let data = try SetupFiles.readData(url, limit: 64 << 20)
|
||||
if SizzleSession.isZip(data) { try session.importProjectBundleData(data) }
|
||||
else if let text = String(data: data, encoding: .utf8) { try session.importProjectText(text) }
|
||||
else { throw SetupFileError.notText }
|
||||
refresh()
|
||||
return
|
||||
}
|
||||
let text = try SetupFiles.readText(url)
|
||||
switch format {
|
||||
case .sng: try session.importSngText(text)
|
||||
case .project: try session.importProjectText(text)
|
||||
default: try session.importProjectText(text)
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
/// The open song as a bundle, "<song>.szgz" in a temporary folder.
|
||||
func exportBundle() throws -> URL {
|
||||
guard let data = session.projectBundleData() else { throw SetupFileError.notText }
|
||||
return try SetupFiles.export(data, name: SetupFiles.fileStem(songName), ext: "szgz")
|
||||
}
|
||||
|
||||
/// Everything as "sizzle-backup-yyyyMMdd-HHmm.zip" (Android names it the same way).
|
||||
func backupFile() throws -> URL {
|
||||
guard let data = session.backupData(withSettings: AppSettings.shared.exportText()) else { throw SetupFileError.notText }
|
||||
let f = DateFormatter()
|
||||
f.locale = Locale(identifier: "en_US_POSIX")
|
||||
f.dateFormat = "yyyyMMdd-HHmm"
|
||||
return try SetupFiles.export(data, name: "sizzle-backup-" + f.string(from: Date()), ext: "zip")
|
||||
}
|
||||
|
||||
/// Restore a backup, then apply its settings, bindings and theme.
|
||||
func restoreBackup(_ url: URL) throws {
|
||||
let data = try SetupFiles.readData(url, limit: 1 << 30)
|
||||
let settings = try session.restoreBackupData(data)
|
||||
if !settings.isEmpty { AppSettings.shared.importText(settings) }
|
||||
InputBindings.shared.reload()
|
||||
ThemeLibrary.shared.refresh()
|
||||
ThemeLibrary.shared.select(AppSettings.shared.paletteName)
|
||||
session.recordTailBars = AppSettings.shared.recordTailBars
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import SwiftUI
|
||||
// DeviceLabView / PluginCheck), so there they are no-ops.
|
||||
|
||||
#if canImport(UIKit)
|
||||
import AVKit
|
||||
import UIKit
|
||||
|
||||
enum ShareSheet {
|
||||
@@ -79,8 +80,53 @@ private struct PluginCheckSheet: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// The system's audio route picker (AirPlay, Bluetooth, an interface) and the
|
||||
/// current route's names (Android's audio device rows; iOS chooses the route).
|
||||
struct AudioRouteView: View {
|
||||
@State private var output = AudioRouteView.names(\.outputs)
|
||||
@State private var input = AudioRouteView.names(\.inputs)
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(spacing: 10) {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text("Output: " + output).font(.system(size: 14)).foregroundColor(Theme.text)
|
||||
Text("Input: " + input).font(.system(size: 14)).foregroundColor(Theme.text)
|
||||
}
|
||||
Spacer()
|
||||
RoutePicker().frame(width: 44, height: 44)
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: AVAudioSession.routeChangeNotification).receive(on: RunLoop.main)) { _ in
|
||||
output = Self.names(\.outputs)
|
||||
input = Self.names(\.inputs)
|
||||
}
|
||||
}
|
||||
|
||||
static func names(_ kp: KeyPath<AVAudioSessionRouteDescription, [AVAudioSessionPortDescription]>) -> String {
|
||||
let ports = AVAudioSession.sharedInstance().currentRoute[keyPath: kp].map(\.portName)
|
||||
return ports.isEmpty ? "—" : ports.joined(separator: ", ")
|
||||
}
|
||||
|
||||
private struct RoutePicker: UIViewRepresentable {
|
||||
func makeUIView(context: Context) -> AVRoutePickerView {
|
||||
let v = AVRoutePickerView()
|
||||
v.tintColor = UIColor(Theme.accent)
|
||||
v.activeTintColor = UIColor(Theme.accent)
|
||||
return v
|
||||
}
|
||||
func updateUIView(_ v: AVRoutePickerView, context: Context) {}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct AudioRouteView: View {
|
||||
var body: some View {
|
||||
Text("Output: Speaker\nInput: Microphone").font(.system(size: 14)).foregroundColor(Theme.text)
|
||||
}
|
||||
}
|
||||
|
||||
enum ShareSheet {
|
||||
@MainActor static func present(_ url: URL, done: @escaping () -> Void = {}) { done() }
|
||||
}
|
||||
|
||||
@@ -5,10 +5,9 @@ import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
/// The fourth tab, after Android's SettingsScreen: MIDI panic, the project
|
||||
/// browser (save / load / new / delete, export and import of projects and .sng),
|
||||
/// help and about, and the device lab. Android's other sections (audio devices,
|
||||
/// recording, interface, themes, MIDI sync, bindings, backup) keep their places
|
||||
/// as greyed-out cards until they're ported.
|
||||
/// browser (save / load / new / delete, project bundles and .sng), audio route,
|
||||
/// recording, interface, colour themes, MIDI sync, control bindings, backup and
|
||||
/// restore, help and about, and the device lab.
|
||||
struct SetupScreen: View {
|
||||
@EnvironmentObject var app: AppModel
|
||||
// SetupContent doesn't observe AppModel, so it isn't redrawn at the transport's rate.
|
||||
@@ -27,6 +26,8 @@ private struct SetupContent: View {
|
||||
@State private var importFormat = SetupModel.Format.sng
|
||||
@State private var showDeviceLab = false
|
||||
@State private var showPluginCheck = false
|
||||
@State private var bindingSource: BindingKind?
|
||||
@State private var confirmTheme: String?
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
@@ -37,13 +38,19 @@ private struct SetupContent: View {
|
||||
panicButton
|
||||
if wide {
|
||||
HStack(alignment: .top, spacing: 14) {
|
||||
VStack(spacing: 14) { projectCard; helpCard }
|
||||
VStack(spacing: 14) { comingLater; diagnosticsCard }
|
||||
VStack(spacing: 14) { projectCard; AudioDevicesCard(); RecordingCard(); backupCard; helpCard }
|
||||
VStack(spacing: 14) { midiCard; BindingsCard { bindingSource = BindingKind($0) }; InterfaceCard(); themeCard; diagnosticsCard }
|
||||
}
|
||||
} else {
|
||||
projectCard
|
||||
AudioDevicesCard()
|
||||
RecordingCard()
|
||||
midiCard
|
||||
BindingsCard { bindingSource = BindingKind($0) }
|
||||
InterfaceCard()
|
||||
themeCard
|
||||
backupCard
|
||||
helpCard
|
||||
comingLater
|
||||
diagnosticsCard
|
||||
}
|
||||
}
|
||||
@@ -62,6 +69,28 @@ private struct SetupContent: View {
|
||||
}
|
||||
.deviceLab(isPresented: $showDeviceLab)
|
||||
.pluginCheck(isPresented: $showPluginCheck)
|
||||
.sheet(item: $bindingSource) { BindingsSheet(source: $0.source) }
|
||||
}
|
||||
|
||||
/// Identifiable wrapper for the bindings sheet.
|
||||
struct BindingKind: Identifiable {
|
||||
let source: InputSource
|
||||
init(_ s: InputSource) { source = s }
|
||||
var id: String { "\(source)" }
|
||||
}
|
||||
|
||||
// MARK: Cards with dialogs
|
||||
|
||||
/// The MIDI card isn't built in the Mac snapshots before MIDI starts; it lists nothing then.
|
||||
private var midiCard: some View { MidiSyncCard() }
|
||||
|
||||
private var themeCard: some View {
|
||||
ThemeCard(onImport: { pick(.theme) }, onDelete: { present(.confirmDeleteTheme($0)) },
|
||||
onError: { show("Export failed", $0) })
|
||||
}
|
||||
|
||||
private var backupCard: some View {
|
||||
BackupCard(onBackup: backup, onRestore: { present(.confirmRestore) })
|
||||
}
|
||||
|
||||
// MARK: Panic
|
||||
@@ -96,11 +125,11 @@ private struct SetupContent: View {
|
||||
|
||||
SetupDivider()
|
||||
HStack(spacing: 8) {
|
||||
SetupButton(title: "Export project", icon: "square.and.arrow.up") { export(.project) }
|
||||
SetupButton(title: "Export project", icon: "square.and.arrow.up") { exportBundle() }
|
||||
SetupButton(title: "Import project", icon: "square.and.arrow.down.on.square") { pick(.project) }
|
||||
}
|
||||
SetupNote("A project file (.szg) carries patterns, mixer, FX and instruments, so it opens " +
|
||||
"complete on another device (samples aren't included yet). Import replaces the current project.")
|
||||
SetupNote("A bundle (.szgz) carries everything — patterns, mixer, FX, instruments and samples — so it opens " +
|
||||
"complete on another device, Android too. Import takes a bundle or a .szg and replaces the current project.")
|
||||
|
||||
SetupDivider()
|
||||
HStack(spacing: 8) {
|
||||
@@ -178,29 +207,6 @@ private struct SetupContent: View {
|
||||
return "\(name) v\(v)" + (build.map { " (\($0))" } ?? "")
|
||||
}
|
||||
|
||||
// MARK: Sections still to come
|
||||
|
||||
private static let later: [(String, String, String)] = [
|
||||
("Audio Devices", "Route playback / recording to USB or built-in", "hifispeaker"),
|
||||
("Recording", "Record the master bus to WAV files", "record.circle"),
|
||||
("Interface", "On-screen display options", "rectangle.on.rectangle"),
|
||||
("Color Theme", "Pick, import, export or delete a palette", "paintpalette"),
|
||||
("MIDI Sync", "MIDI clock in and out, sources, sound module", "metronome"),
|
||||
("Gamepad Bindings", "Rebind buttons & combos", "gamecontroller"),
|
||||
("Keyboard Hotkeys", "Rebind keyboard keys", "keyboard"),
|
||||
("MIDI Bindings", "MIDI-learn controls", "pianokeys"),
|
||||
("Backup & Restore", "Save or restore all songs, presets, themes & settings", "externaldrive"),
|
||||
]
|
||||
|
||||
private var comingLater: some View {
|
||||
SetupCard(title: "More settings", subtitle: "Coming in a later version", enabled: false) {
|
||||
ForEach(Array(Self.later.enumerated()), id: \.offset) { i, s in
|
||||
if i > 0 { SetupDivider() }
|
||||
ComingLaterRow(title: s.0, subtitle: s.1, icon: s.2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Diagnostics
|
||||
|
||||
private var diagnosticsCard: some View {
|
||||
@@ -247,6 +253,15 @@ private struct SetupContent: View {
|
||||
confirm: "Delete", destructive: true, field: { EmptyView() },
|
||||
onConfirm: { dismiss(); attempt("Delete failed") { try model.delete(name) } },
|
||||
onCancel: dismiss)
|
||||
case .confirmDeleteTheme(let name):
|
||||
SetupDialogView(title: "Delete theme", message: "Delete \"\(name)\"? This cannot be undone.",
|
||||
confirm: "Delete", destructive: true, field: { EmptyView() },
|
||||
onConfirm: { dismiss(); ThemeLibrary.shared.delete(name) }, onCancel: dismiss)
|
||||
case .confirmRestore:
|
||||
SetupDialogView(title: "Restore backup",
|
||||
message: "Replace every saved song, preset, theme, sample, the open song and the settings with a backup's?",
|
||||
confirm: "Choose backup", destructive: true, field: { EmptyView() },
|
||||
onConfirm: { dismiss(); pick(.backup) }, onCancel: dismiss)
|
||||
case .message(let title, let text):
|
||||
SetupDialogView(title: title, message: text, confirm: "OK", cancel: nil, field: { EmptyView() },
|
||||
onConfirm: dismiss, onCancel: dismiss)
|
||||
@@ -279,6 +294,20 @@ private struct SetupContent: View {
|
||||
resetCursor()
|
||||
}
|
||||
|
||||
private func exportBundle() {
|
||||
attempt("Export failed") {
|
||||
let url = try model.exportBundle()
|
||||
ShareSheet.present(url) { try? FileManager.default.removeItem(at: url.deletingLastPathComponent()) }
|
||||
}
|
||||
}
|
||||
|
||||
private func backup() {
|
||||
attempt("Backup failed") {
|
||||
let url = try model.backupFile()
|
||||
ShareSheet.present(url) { try? FileManager.default.removeItem(at: url.deletingLastPathComponent()) }
|
||||
}
|
||||
}
|
||||
|
||||
private func export(_ format: SetupModel.Format) {
|
||||
attempt("Export failed") {
|
||||
let url = try model.exportFile(format)
|
||||
@@ -293,16 +322,31 @@ private struct SetupContent: View {
|
||||
|
||||
private func runImport(_ url: URL) {
|
||||
do {
|
||||
try model.importFile(url, as: importFormat)
|
||||
switch importFormat {
|
||||
case .theme:
|
||||
guard ThemeLibrary.shared.importText(try SetupFiles.readText(url)) != nil else {
|
||||
show("Import failed", "Couldn't import this file. It doesn't look like a valid .szt theme.")
|
||||
return
|
||||
}
|
||||
return
|
||||
case .backup:
|
||||
try model.restoreBackup(url)
|
||||
show("Backup restored", "Songs, presets, themes, samples and settings are back.")
|
||||
default:
|
||||
try model.importFile(url, as: importFormat)
|
||||
}
|
||||
resetCursor()
|
||||
} catch let e as SetupFileError {
|
||||
show("Import failed", e.localizedDescription)
|
||||
} catch is CocoaError {
|
||||
show("Import failed", "Couldn't read the selected file.")
|
||||
} catch {
|
||||
show("Import failed", importFormat == .sng
|
||||
? "Couldn't import this file. It doesn't look like a valid .sng song."
|
||||
: "Couldn't import this file. It doesn't look like a Sizzle project (.szg).")
|
||||
switch importFormat {
|
||||
case .sng: show("Import failed", "Couldn't import this file. It doesn't look like a valid .sng song.")
|
||||
case .backup: show("Restore failed", error.localizedDescription)
|
||||
default: show("Import failed", (error as NSError).domain == "Sizzle" ? error.localizedDescription
|
||||
: "Couldn't import this file. It doesn't look like a Sizzle project (.szgz or .szg).")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// Android's MidiLearnPopup: every parameter of the slot with its MIDI CC. LEARN,
|
||||
/// then move a knob or fader on a MIDI controller; ✕ removes the binding. The
|
||||
/// bindings are saved in the song (`midicc@<key>` slot values), as on Android.
|
||||
struct MidiLearnSheet: View {
|
||||
let slot: Int
|
||||
let type: String
|
||||
@ObservedObject private var input = InputController.shared
|
||||
@ObservedObject private var watch = MixSongWatch.shared
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
var body: some View {
|
||||
let session = SizzleSession.shared
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack {
|
||||
Text("MIDI LEARN — \(session.name(ofSlot: slot))").font(Theme.mono(14)).foregroundColor(Theme.accent)
|
||||
Spacer()
|
||||
Text("DONE").font(Theme.mono(13)).foregroundColor(Theme.dim)
|
||||
.contentShape(Rectangle()).onTapGesture { dismiss() }
|
||||
}
|
||||
Text("Tap LEARN, then move a knob/fader on your MIDI controller.").font(Theme.mono(10)).foregroundColor(Theme.dim)
|
||||
SnapScroll {
|
||||
VStack(spacing: 6) {
|
||||
ForEach(SizzleSession.paramSpecs(forType: type), id: \.key) { spec in
|
||||
let arming = input.paramLearnSlot == slot && input.paramLearnKey == spec.key
|
||||
let cc = input.paramCc(slot: slot, key: spec.key)
|
||||
HStack(spacing: 8) {
|
||||
Text(spec.label).font(Theme.mono(12)).foregroundColor(Theme.text)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(arming ? "waiting…" : cc.map { "CC \($0)" } ?? "—").font(Theme.mono(11))
|
||||
.foregroundColor(arming ? Theme.accent : Theme.dim).frame(width: 72, alignment: .leading)
|
||||
MixKit.Button(label: arming ? "ARMING" : "LEARN", active: arming, width: 78) {
|
||||
if arming { input.cancelParamLearn() } else { input.beginParamLearn(slot: slot, key: spec.key) }
|
||||
}
|
||||
MixKit.Button(label: "✕") { input.clearParamCc(slot: slot, key: spec.key) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(16)
|
||||
.background(Theme.surface.ignoresSafeArea())
|
||||
.preferredColorScheme(.dark)
|
||||
.onDisappear { input.cancelParamLearn() }
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ struct SamplerDetail: View {
|
||||
let onSelectPad: (Int) -> Void
|
||||
let onImport: () -> Void
|
||||
@State private var page = 0
|
||||
@ObservedObject private var recorder = SampleRecorder.shared
|
||||
|
||||
var body: some View {
|
||||
let session = SizzleSession.shared
|
||||
@@ -28,6 +29,15 @@ struct SamplerDetail: View {
|
||||
MixKit.HScroll {
|
||||
HStack(spacing: 8) {
|
||||
MixKit.Button(label: "IMPORT WAV", action: onImport)
|
||||
if recorder.isRecording {
|
||||
MixKit.Button(label: "■ STOP REC", active: true) {
|
||||
recorder.stopInto(slot: slot, pad: pad)
|
||||
session.setNumber(0, ofSlot: slot, key: "pad\(pad)S")
|
||||
session.setNumber(1, ofSlot: slot, key: "pad\(pad)E")
|
||||
}
|
||||
} else {
|
||||
MixKit.Button(label: "● RECORD") { recorder.start() }
|
||||
}
|
||||
if assigned {
|
||||
MixKit.Button(label: "✂ CLIP") { _ = session.trimPad(pad, ofSlot: slot) }
|
||||
MixKit.Button(label: "NORMALIZE") { _ = session.normalizePad(pad, ofSlot: slot) }
|
||||
|
||||
@@ -20,6 +20,7 @@ struct SlotEditor: View {
|
||||
|
||||
@StateObject private var model: DeviceModel
|
||||
@ObservedObject private var watch = MixSongWatch.shared
|
||||
@ObservedObject private var recorder = SampleRecorder.shared
|
||||
@State private var pad = 0
|
||||
/// What the file picker is for; kept after it closes, because SwiftUI resets
|
||||
/// the presentation binding before calling the completion handler.
|
||||
@@ -27,6 +28,7 @@ struct SlotEditor: View {
|
||||
@State private var pickerShown = false
|
||||
@State private var deviceCallback: ((URL) -> Void)?
|
||||
@State private var importError: String?
|
||||
@State private var showMidiLearn = false
|
||||
|
||||
enum ImportKind: Identifiable {
|
||||
case preset, padSample, soundFont, device // device: a bespoke view's own load (deviceFilePicker)
|
||||
@@ -71,6 +73,11 @@ struct SlotEditor: View {
|
||||
}
|
||||
.alert("Import failed", isPresented: Binding(get: { importError != nil }, set: { if !$0 { importError = nil } }),
|
||||
actions: { Button("OK") { importError = nil } }, message: { Text(importError ?? "") })
|
||||
.background(Color.clear.alert("Recording", isPresented: Binding(get: { recorder.error != nil }, set: { if !$0 { recorder.error = nil } }),
|
||||
actions: { Button("OK") { recorder.error = nil } }, message: { Text(recorder.error ?? "") }))
|
||||
.onDisappear { if recorder.isRecording { _ = recorder.stop() } }
|
||||
.onChange(of: watch.revision) { _ in model.refresh() } // MIDI CCs move parameters too
|
||||
.sheet(isPresented: $showMidiLearn) { MidiLearnSheet(slot: slot, type: type) }
|
||||
}
|
||||
|
||||
@ViewBuilder private var pinnedPart: some View {
|
||||
@@ -87,6 +94,9 @@ struct SlotEditor: View {
|
||||
HStack {
|
||||
Text(session.name(ofSlot: slot)).font(Theme.mono(15)).foregroundColor(Theme.accent).lineLimit(1)
|
||||
Spacer()
|
||||
Text("⇄ MIDI").font(Theme.mono(13)).foregroundColor(Theme.accent)
|
||||
.contentShape(Rectangle()).onTapGesture { showMidiLearn = true }
|
||||
.padding(.trailing, 14)
|
||||
Text("CLOSE ✕").font(Theme.mono(13)).foregroundColor(Theme.dim)
|
||||
.contentShape(Rectangle()).onTapGesture(perform: onClose)
|
||||
}
|
||||
@@ -104,6 +114,9 @@ struct SlotEditor: View {
|
||||
importing = .device
|
||||
pickerShown = true
|
||||
}
|
||||
.environment(\.deviceRecorder, DeviceRecordControl(isRecording: recorder.isRecording) {
|
||||
if recorder.isRecording { recorder.stopIntoGrain(slot: slot) } else { recorder.start() }
|
||||
})
|
||||
.frame(minHeight: 0, maxHeight: .infinity, alignment: .top).clipped()
|
||||
if type == "LFO" { LfoTargetPicker(lfo: slot) }
|
||||
}
|
||||
|
||||
@@ -63,9 +63,11 @@ final class TrackerState: ObservableObject {
|
||||
|
||||
// MARK: edits (Android: punchNote / noteOffFocused / deleteAndAdvance / …)
|
||||
|
||||
func punchNote(_ app: AppModel, _ midi: Int) {
|
||||
let cell = SizzleCell(note: Int32(min(max(midi, 0), 127)), velocity: Int32(min(max(app.kbdVelocity, 0), 127)),
|
||||
channel: Int32(app.kbdChannel))
|
||||
/// Velocity and channel default to the on-screen keyboard's; MIDI punch-in
|
||||
/// passes the incoming note's own, so the cell plays back as it was played.
|
||||
func punchNote(_ app: AppModel, _ midi: Int, velocity: Int? = nil, channel: Int? = nil) {
|
||||
let cell = SizzleCell(note: Int32(min(max(midi, 0), 127)), velocity: Int32(min(max(velocity ?? app.kbdVelocity, 0), 127)),
|
||||
channel: Int32(channel ?? app.kbdChannel))
|
||||
session.setCell(cell, inPattern: session.activePattern, track: app.cursorTrack, line: app.cursorLine)
|
||||
moveCursorWrap(app, skipStep)
|
||||
}
|
||||
@@ -254,6 +256,14 @@ final class TrackerHeldNotes: ObservableObject {
|
||||
SizzleSession.shared.noteOff(midi, midiChannel: channels[midi] ?? app.kbdChannel)
|
||||
}
|
||||
|
||||
/// Light or unlight a key without sounding it (hardware keys, MIDI in: the
|
||||
/// input layer plays those itself).
|
||||
func mark(_ midi: Int, on: Bool) {
|
||||
if on { counts[midi, default: 0] += 1; return }
|
||||
let n = (counts[midi] ?? 0) - 1
|
||||
if n <= 0 { counts[midi] = nil } else { counts[midi] = n }
|
||||
}
|
||||
|
||||
/// Release everything (the keyboard went away mid-press).
|
||||
func releaseAll() {
|
||||
for (midi, ch) in channels where (counts[midi] ?? 0) > 0 { SizzleSession.shared.noteOff(midi, midiChannel: ch) }
|
||||
|
||||
@@ -6,16 +6,16 @@ import SwiftUI
|
||||
/// The Android "Amber CRT" palette slots the shared Theme doesn't have (beat/bar
|
||||
/// row tints, the playhead green, the danger red), plus Theme's own for brevity.
|
||||
enum TK {
|
||||
static let background = Theme.background
|
||||
static let surface = Theme.surface
|
||||
static let grid = Theme.grid
|
||||
static let text = Theme.text
|
||||
static let dim = Theme.dim
|
||||
static let accent = Theme.accent
|
||||
static let beat = Color(red: 0x14 / 255, green: 0x1C / 255, blue: 0x1A / 255)
|
||||
static let bar = Color(red: 0x1E / 255, green: 0x2A / 255, blue: 0x20 / 255)
|
||||
static let playhead = Color(red: 0x7C / 255, green: 0xFC / 255, blue: 0x9A / 255)
|
||||
static let danger = Color(red: 0xE0 / 255, green: 0x5A / 255, blue: 0x4B / 255)
|
||||
static var background: Color { Theme.background }
|
||||
static var surface: Color { Theme.surface }
|
||||
static var grid: Color { Theme.grid }
|
||||
static var text: Color { Theme.text }
|
||||
static var dim: Color { Theme.dim }
|
||||
static var accent: Color { Theme.accent }
|
||||
static var beat: Color { Theme.beat }
|
||||
static var bar: Color { Theme.bar }
|
||||
static var playhead: Color { Theme.playhead }
|
||||
static var danger: Color { Theme.danger }
|
||||
|
||||
/// Pitch.name: 60 → "C-4", 61 → "C#4" (MIDI 12 == C0).
|
||||
static let noteNames: [String] = (0..<128).map { m in
|
||||
|
||||
Reference in New Issue
Block a user