// 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@`. #pragma once #include #include #include #include #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> 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 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