- 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
1.8 KiB
C++
53 lines
1.8 KiB
C++
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// A device's MIDI mapping as plain text (.szm), the same format the Android app
|
|
// reads and writes (io/MidiMapIo.kt):
|
|
//
|
|
// SIZZLE-MIDIMAP 1
|
|
// # comments start with '#'
|
|
// TYPE=WAVETABLE
|
|
// NAME=Lead
|
|
// cutoff=74
|
|
// resonance=71
|
|
//
|
|
// One `parameter=CC` line per mapped parameter (CC 0..127), in the device's
|
|
// parameter order. In the song a mapping is the slot value `midicc@<parameter>`.
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "sizzle/Model.hpp"
|
|
|
|
namespace sizzle::io {
|
|
|
|
struct MidiMap {
|
|
std::string type; // ToolboxType name
|
|
std::string name; // the slot's name when exported (informational)
|
|
std::vector<std::pair<std::string, int>> bindings; // parameter key, CC
|
|
};
|
|
|
|
class MidiMapIo {
|
|
public:
|
|
static constexpr const char *HEADER = "SIZZLE-MIDIMAP 1";
|
|
static constexpr const char *CC_PREFIX = "midicc@";
|
|
|
|
/** [slot]'s mappings, in its device's parameter order. */
|
|
static MidiMap fromSlot(const model::ToolboxSlot &slot);
|
|
static std::string save(const MidiMap &map);
|
|
/** The mapping in [text], or nothing if it has no header or TYPE. Lines that
|
|
* aren't `key=CC` with CC 0..127 are skipped; a repeated key or CC keeps its
|
|
* first line (one control drives one parameter). */
|
|
static std::optional<MidiMap> parse(const std::string &text);
|
|
/** Replace toolbox [slot]'s mappings with [map]'s: only parameters its device
|
|
* has; a CC another parameter (of any slot) used moves to this one. Returns
|
|
* how many were applied, or -1 when [map] is for another device type. */
|
|
static int apply(model::Project &project, int slot, const MidiMap &map);
|
|
};
|
|
|
|
} // namespace sizzle::io
|