0.39.0 (73): export and import MIDI mappings as .szm text (Android and iOS)

- SIZZLE-MIDIMAP 1 format: TYPE, NAME, one parameter=CC line each
- core/src/io/MidiMapIo (iOS) and io/MidiMapIo.kt (Android), tested on one
  shared fixture (midimap_test, MidiMapIoTest)
- EXPORT / IMPORT in each device's MIDI learn panel on both platforms
- Params::remove; iOS clears a mapping by removing it
- ios/Makefile regenerates the Xcode project when source folders change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 16:31:46 +01:00
co-authored by Claude Opus 5.5
parent 4d9e2328cb
commit 6688718bed
19 changed files with 580 additions and 8 deletions
+7
View File
@@ -5,6 +5,13 @@ Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
is shared with Android, continuing Android's numbering, and both apps ship the
same features; the Android side of each version is in `../CHANGELOG.md`.
## 0.39.0 (build 73)
- MIDI mappings as files: EXPORT / IMPORT in each device's ⇄ MIDI sheet share a
device's CC mapping as a plain-text `.szm` file (the same files as Android).
Clearing a mapping now removes it from the song instead of leaving it empty.
(Android has the same in 0.39.0.)
## 0.38.0 (build 72)
- Bluetooth LE MIDI controllers: Setup › MIDI Sync › Bluetooth MIDI › Find
+11 -2
View File
@@ -82,6 +82,10 @@ build/core/host_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/host_test.cpp
mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/host_test.cpp
build/core/midimap_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/midimap_test.cpp
mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/midimap_test.cpp
build/core/midi_test: ../core/include/sizzle/Midi.hpp ../core/tests/midi_test.cpp
mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ ../core/tests/midi_test.cpp
@@ -98,7 +102,7 @@ zip-test: build/core/zip_test
build/core/zip_test build/core/java.zip build/core/ours.zip
unzip -tq build/core/ours.zip
core-test: build/core/golden_test build/core/sampler_test build/core/engine_test build/core/io_test build/core/midi_test build/core/host_test zip-test
core-test: build/core/golden_test build/core/sampler_test build/core/engine_test build/core/io_test build/core/midi_test build/core/host_test build/core/midimap_test zip-test
@test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden
build/core/golden_test $(GOLDEN) $(TYPES)
build/core/sampler_test
@@ -106,6 +110,7 @@ core-test: build/core/golden_test build/core/sampler_test build/core/engine_test
build/core/io_test $(GOLDEN)/songs ../app/src/test/resources/mikroseq
build/core/midi_test
build/core/host_test $(GOLDEN)/songs
build/core/midimap_test ../app/src/test/resources/midimap/filter.szm
# ------------------------------------------------------------------ app
AU_SRC := app/FX/SizzleDeviceAU.mm app/FX/SizzleEffectAU.mm app/FX/SizzleInstrumentAU.mm app/FX/SizzleDeviceAU+Sources.mm
@@ -158,8 +163,12 @@ app/FX/Info.plist app/FX/Components.gen.h: app/components.txt tools/gen_componen
python3 tools/gen_components.py app/components.txt app/FX/Info.plist app/FX/Components.gen.h
project: $(PROJECT)/project.pbxproj
$(PROJECT)/project.pbxproj: app/project.yml app/FX/Info.plist
# The folders too: a directory's time changes when a file is added or removed, and
# the generated project lists every source file.
SRC_DIRS := $(shell find app ../core/src ../core/include -type d -not -path '*.xcodeproj*')
$(PROJECT)/project.pbxproj: app/project.yml app/FX/Info.plist $(SRC_DIRS)
cd app && xcodegen generate --spec project.yml --quiet
touch $@
# Device: build without signing, then ad-hoc sign inside-out (extension first) with
# each target's entitlements. TrollStore re-signs at install and keeps them.
+2 -1
View File
@@ -158,7 +158,7 @@ final class InputController: ObservableObject {
func paramCc(slot: Int, key: String) -> Int? { Int(session.value(ofSlot: slot, key: Self.ccPrefix + key)) }
func clearParamCc(slot: Int, key: String) { session.setValue("", ofSlot: slot, key: Self.ccPrefix + key) }
func clearParamCc(slot: Int, key: String) { session.removeValue(ofSlot: slot, key: Self.ccPrefix + key) }
private func onRaw(_ source: InputSource, _ code: Int, _ value: Float, _ modifier: Int) {
if let key = paramLearnKey {
@@ -187,6 +187,7 @@ final class InputController: ObservableObject {
clearParamCc(slot: s, key: spec.key)
}
}
// (Same rule as MidiMapIo.apply: one control drives one parameter.)
session.setValue(String(cc), ofSlot: slot, key: Self.ccPrefix + key)
}
@@ -6,12 +6,15 @@ 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.
/// EXPORT shares them as a .szm text file; IMPORT takes one for this device type.
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
@State private var importing = false
@State private var importError: String?
var body: some View {
let session = SizzleSession.shared
@@ -19,6 +22,12 @@ struct MidiLearnSheet: View {
HStack {
Text("MIDI LEARN — \(session.name(ofSlot: slot))").font(Theme.mono(14)).foregroundColor(Theme.accent)
Spacer()
Text("EXPORT").font(Theme.mono(13)).foregroundColor(Theme.accent)
.contentShape(Rectangle()).onTapGesture(perform: export)
.padding(.trailing, 14)
Text("IMPORT").font(Theme.mono(13)).foregroundColor(Theme.accent)
.contentShape(Rectangle()).onTapGesture { importing = true }
.padding(.trailing, 14)
Text("DONE").font(Theme.mono(13)).foregroundColor(Theme.dim)
.contentShape(Rectangle()).onTapGesture { dismiss() }
}
@@ -46,5 +55,32 @@ struct MidiLearnSheet: View {
.background(Theme.surface.ignoresSafeArea())
.preferredColorScheme(.dark)
.onDisappear { input.cancelParamLearn() }
// The completion needs nothing but the URL (iOS 15 resets the binding first).
.fileImporter(isPresented: $importing, allowedContentTypes: [.item]) { result in
guard case .success(let url) = result else { return }
do {
let data = try SetupFiles.readData(url, limit: 1 << 20)
guard let text = String(data: data, encoding: .utf8) else { throw SetupFileError.notText }
try SizzleSession.shared.importMidiMapText(text, intoSlot: slot)
} catch {
importError = error.localizedDescription
}
}
.alert("Import failed", isPresented: Binding(get: { importError != nil }, set: { if !$0 { importError = nil } }),
actions: { Button("OK") { importError = nil } }, message: { Text(importError ?? "") })
}
/// The mapping as "<slot name> MIDI.szm", through the share sheet.
private func export() {
let session = SizzleSession.shared
guard let text = session.midiMapText(ofSlot: slot) else { return }
let name = session.name(ofSlot: slot).trimmingCharacters(in: .whitespaces)
let base = SetupFiles.fileStem(name.isEmpty ? type : name) + " MIDI"
do {
let url = try SetupFiles.export(Data(text.utf8), name: base, ext: "szm")
ShareSheet.present(url) { try? FileManager.default.removeItem(at: url.deletingLastPathComponent()) }
} catch {
importError = error.localizedDescription
}
}
}
+9
View File
@@ -19,6 +19,15 @@ NS_ASSUME_NONNULL_BEGIN
/// True for a ZIP archive (bundle or backup) rather than text.
+ (BOOL)isZipData:(NSData *)data;
/// Toolbox [slot]'s MIDI mapping as .szm text (io/MidiMapIo: TYPE, NAME, one
/// `parameter=CC` line each), or nil for an empty slot.
- (nullable NSString *)midiMapTextOfSlot:(NSInteger)slot;
/// Replace [slot]'s MIDI mapping with the .szm [text] (a CC another parameter used
/// moves here). NO with [error] set when it isn't a mapping or is for another device.
- (BOOL)importMidiMapText:(NSString *)text intoSlot:(NSInteger)slot error:(NSError **)error;
/// Remove setting [key] from [slot] (a cleared MIDI mapping).
- (void)removeValueOfSlot:(NSInteger)slot key:(NSString *)key;
/// Everything Sizzle keeps: Documents/songs, themes, presets and samples, the
/// autosaved song, and [settings] as settings.txt. The open song is autosaved first.
- (nullable NSData *)backupDataWithSettings:(NSString *)settings;
+40
View File
@@ -9,7 +9,9 @@
#include <string>
#include <vector>
#include "io/MidiMapIo.hpp"
#include "io/Zip.hpp"
#include "sizzle/Specs.hpp"
using namespace sizzle;
namespace zip = sizzle::io::zip;
@@ -138,6 +140,44 @@ NSString *const kSettings = @"settings.txt";
return [self importProjectText:text error:error];
}
#pragma mark - MIDI mappings
- (nullable NSString *)midiMapTextOfSlot:(NSInteger)slot {
if (slot < 0 || slot >= 16) return nil;
__block std::string text;
[self read:^(const model::Project &p, const engine::Engine &) {
const auto &s = p.toolbox[(size_t)slot];
if (!s.isEmpty()) text = io::MidiMapIo::save(io::MidiMapIo::fromSlot(s));
}];
return text.empty() ? nil : @(text.c_str());
}
- (BOOL)importMidiMapText:(NSString *)text intoSlot:(NSInteger)slot error:(NSError **)error {
const auto map = io::MidiMapIo::parse(text.UTF8String ?: "");
if (!map) {
if (error) *error = filesError(@"This doesn't look like a Sizzle MIDI mapping (.szm).");
return NO;
}
__block int applied = -1;
[self edit:^(model::Project &p, engine::Engine &) { applied = io::MidiMapIo::apply(p, (int)slot, *map); }];
if (applied < 0 && error) {
const DeviceSpec *want = findDevice(map->type.c_str());
const DeviceSpec *have = findDevice([self typeOfSlot:slot].UTF8String);
*error = filesError([NSString stringWithFormat:@"This mapping is for a %s, not a %s.",
want ? want->displayName : map->type.c_str(), have ? have->displayName : "empty slot"]);
}
return applied >= 0;
}
- (void)removeValueOfSlot:(NSInteger)slot key:(NSString *)key {
if (slot < 0 || slot >= 16) return;
std::string k = key.UTF8String ?: "";
[self edit:^(model::Project &p, engine::Engine &) {
p.toolbox[(size_t)slot].values.remove(k.c_str());
++p.toolbox[(size_t)slot].version;
}];
}
#pragma mark - backups
- (nullable NSData *)backupDataWithSettings:(NSString *)settings {