- 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>
53 lines
2.4 KiB
C++
53 lines
2.4 KiB
C++
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// io::MidiMapIo against the fixture the Android test reads too
|
|
// (argv[1]: app/src/test/resources/midimap/filter.szm).
|
|
|
|
#include "io/MidiMapIo.hpp"
|
|
#include "io/ProjectIo.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
|
|
using namespace sizzle;
|
|
|
|
static int failures = 0;
|
|
#define CHECK(c) do { if (!(c)) { std::printf("FAIL %s:%d %s\n", __FILE__, __LINE__, #c); ++failures; } } while (0)
|
|
|
|
int main(int argc, char **argv) {
|
|
if (argc < 2) { std::printf("usage: midimap_test <filter.szm>\n"); return 2; }
|
|
std::ifstream f(argv[1]);
|
|
std::stringstream ss;
|
|
ss << f.rdbuf();
|
|
const auto map = io::MidiMapIo::parse(ss.str());
|
|
CHECK(map && map->type == "FILTER" && map->name == "Sweep");
|
|
// Repeated key, repeated CC, CC out of range and junk lines are skipped.
|
|
const std::vector<std::pair<std::string, int>> want = {{"cutoff", 74}, {"resonance", 71}, {"nosuchparam", 20}, {"release", 7}};
|
|
CHECK(map && map->bindings == want);
|
|
CHECK(!io::MidiMapIo::parse("TYPE=FILTER\ncutoff=1\n")); // no header
|
|
CHECK(!io::MidiMapIo::parse("SIZZLE-MIDIMAP 1\ncutoff=1\n")); // no type
|
|
|
|
model::Project p;
|
|
p.toolbox[2].fill("FILTER");
|
|
p.toolbox[5].fill("BITCRUSHER");
|
|
p.toolbox[5].set("midicc@bits", "71"); // CC 71 moves to the filter
|
|
p.toolbox[2].set("midicc@warmth", "30"); // replaced by the import
|
|
CHECK(io::MidiMapIo::apply(p, 5, *map) == -1); // another device
|
|
CHECK(io::MidiMapIo::apply(p, 2, *map) == 3); // nosuchparam skipped
|
|
CHECK(!p.toolbox[5].values.has("midicc@bits"));
|
|
CHECK(!p.toolbox[2].values.has("midicc@warmth"));
|
|
const io::MidiMap back = io::MidiMapIo::fromSlot(p.toolbox[2]);
|
|
const std::vector<std::pair<std::string, int>> applied = {{"cutoff", 74}, {"resonance", 71}, {"release", 7}};
|
|
CHECK(back.bindings == applied && back.type == "FILTER");
|
|
// Round trip, and the mapping survives the song file.
|
|
CHECK(io::MidiMapIo::parse(io::MidiMapIo::save(back))->bindings == applied);
|
|
model::Project q;
|
|
io::ProjectIo::loadInto(q, io::ProjectIo::save(p));
|
|
CHECK(io::MidiMapIo::fromSlot(q.toolbox[2]).bindings == applied);
|
|
|
|
std::printf(failures ? "midimap_test: %d failure(s)\n" : "midimap_test: ok\n", failures);
|
|
return failures ? 1 : 0;
|
|
}
|