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:
co-authored by
Claude Opus 5.5
parent
4d9e2328cb
commit
6688718bed
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user