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
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user