iOS milestone 3 groundwork: SizzleSession bridge, app shell with tabs, slot-backed editors, screen snapshots
SizzleSession owns the song, engine (192-frame chunks, try-lock on the audio thread), samples and audio output; AppModel/RootView give the four tabs; DeviceModel now works on toolbox slots too; make screen-snapshots renders the app's tabs on the Mac. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7bc54e6466
commit
29650b88d7
@@ -0,0 +1,36 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Foundation
|
||||
|
||||
extension DeviceModel {
|
||||
/// Backed by toolbox slot [slot] of the open song.
|
||||
convenience init(session: SizzleSession, slot: Int) {
|
||||
let type = session.type(ofSlot: slot)
|
||||
let specs = SizzleSession.paramSpecs(forType: type)
|
||||
let infos = specs.map { s in
|
||||
ParamInfo(key: s.key, label: s.label, min: s.minValue, max: s.maxValue, def: s.defaultValue,
|
||||
isInt: s.isInt, choices: s.choices)
|
||||
}
|
||||
func read() -> [String: Float] {
|
||||
var v: [String: Float] = [:]
|
||||
for s in specs {
|
||||
let text = session.value(ofSlot: slot, key: s.key)
|
||||
if s.choices.isEmpty { v[s.key] = Float(text) ?? s.defaultValue }
|
||||
else { v[s.key] = Float(s.choices.firstIndex(of: text) ?? Int(s.defaultValue)) }
|
||||
}
|
||||
return v
|
||||
}
|
||||
let byKey = Dictionary(uniqueKeysWithValues: specs.map { ($0.key, $0) })
|
||||
self.init(toolboxType: type, displayName: session.name(ofSlot: slot), infos: infos, values: read(),
|
||||
presetNames: session.factoryPresets(forType: type),
|
||||
write: { key, v in
|
||||
guard let s = byKey[key] else { return }
|
||||
if s.choices.isEmpty { session.setNumber(v, ofSlot: slot, key: key) }
|
||||
else { session.setValue(s.choices[max(0, min(s.choices.count - 1, Int(v.rounded())))], ofSlot: slot, key: key) }
|
||||
},
|
||||
applyPreset: { name in session.applyFactoryPreset(name, toSlot: slot) },
|
||||
reread: read)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user