Files
sizzletracker-android/ios/app/Host/Screens/Toolbox/MidiLearnSheet.swift
T
ReactorcoremeltdownandClaude Opus 5.5 64e21e0bcc 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>
2026-11-16 14:26:01 +01:00

51 lines
2.5 KiB
Swift

// 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() }
}
}