iOS 0.5.0: hand-built editors (Tape Delay, Tape Engine, Mix Tightener, Granular scope, Wavetable tables, Grain Cloud source)
Effect visualisation through the C++ effect, engine and AU; custom wavetables and grain sources load and persist with the song; the app's slot editor hosts the file picker for bespoke views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3b035d6a7d
commit
435305e42a
@@ -25,10 +25,11 @@ struct SlotEditor: View {
|
||||
/// the presentation binding before calling the completion handler.
|
||||
@State private var importing: ImportKind?
|
||||
@State private var pickerShown = false
|
||||
@State private var deviceCallback: ((URL) -> Void)?
|
||||
@State private var importError: String?
|
||||
|
||||
enum ImportKind: Identifiable {
|
||||
case preset, padSample, soundFont
|
||||
case preset, padSample, soundFont, device // device: a bespoke view's own load (deviceFilePicker)
|
||||
var id: Self { self }
|
||||
}
|
||||
|
||||
@@ -65,7 +66,8 @@ struct SlotEditor: View {
|
||||
}
|
||||
.background(Theme.background.opacity(0.96))
|
||||
.fileImporter(isPresented: $pickerShown, allowedContentTypes: importTypes, allowsMultipleSelection: false) { result in
|
||||
if case .success(let urls) = result, let url = urls.first, let kind = importing { load(url, kind) }
|
||||
guard case .success(let urls) = result, let url = urls.first, let kind = importing else { return }
|
||||
if kind == .device { deviceCallback?(url) } else { load(url, kind) }
|
||||
}
|
||||
.alert("Import failed", isPresented: Binding(get: { importError != nil }, set: { if !$0 { importError = nil } }),
|
||||
actions: { Button("OK") { importError = nil } }, message: { Text(importError ?? "") })
|
||||
@@ -97,6 +99,11 @@ struct SlotEditor: View {
|
||||
// The card editor brings its own padding and header row; with no name and
|
||||
// no preset menu (the bar above has them) the row is empty, so pull it up.
|
||||
DeviceEditor(model: model, showsHeader: false).padding(.horizontal, -10)
|
||||
.environment(\.deviceFilePicker) { done in
|
||||
deviceCallback = done
|
||||
importing = .device
|
||||
pickerShown = true
|
||||
}
|
||||
.frame(minHeight: 0, maxHeight: .infinity, alignment: .top).clipped()
|
||||
if type == "LFO" { LfoTargetPicker(lfo: slot) }
|
||||
}
|
||||
@@ -108,7 +115,7 @@ struct SlotEditor: View {
|
||||
private var importTypes: [UTType] {
|
||||
switch importing {
|
||||
case .padSample: return [.audio, .wav]
|
||||
case .preset, .soundFont, .none: return [.item]
|
||||
case .preset, .soundFont, .device, .none: return [.item]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +151,8 @@ struct SlotEditor: View {
|
||||
if (try? session.loadSampleData(data, name: name, intoSlot: slot, pad: 0)) == nil {
|
||||
importError = "Couldn't load this instrument. Supported formats are .sf2, .xi and uncompressed .wav."
|
||||
}
|
||||
case .device:
|
||||
break // handed to the bespoke view (deviceCallback)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +184,7 @@ struct SlotEditor: View {
|
||||
},
|
||||
applyPreset: { name in _ = session.loadPreset(name, intoSlot: slot) },
|
||||
reread: read)
|
||||
.withData(SlotDataSource(session: session, slot: slot))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user