16class MidiMapping :
public QObject
25 QObject * parent =
nullptr);
26 Z_DISABLE_COPY_MOVE (MidiMapping)
29 friend void init_from (
31 const MidiMapping &other,
34 void set_enabled (
bool enabled) {
enabled_.store (enabled); }
36 void apply (std::array<midi_byte_t, 3> buf);
39 static constexpr auto kKeyKey =
"key"sv;
40 static constexpr auto kDeviceIdKey =
"deviceIdentifier"sv;
41 static constexpr auto kDestIdKey =
"destId"sv;
42 static constexpr auto kEnabledKey =
"enabled"sv;
43 friend void to_json (nlohmann::json &j,
const MidiMapping &mapping)
45 j[kKeyKey] = mapping.
key_;
51 j[kEnabledKey] = mapping.
enabled_.load ();
53 friend void from_json (
const nlohmann::json &j, MidiMapping &mapping)
55 j.at (kKeyKey).get_to (mapping.
key_);
56 j.at (kDeviceIdKey).get_to (mapping.
device_id_);
57 if (j.contains (kDestIdKey))
59 mapping.
dest_id_.emplace (mapping.param_registry_);
60 j.at (kDestIdKey).get_to (*mapping.
dest_id_);
62 mapping.
enabled_.store (j.at (kEnabledKey).get<
bool> ());
69 std::array<midi_byte_t, 3>
key_ = {};
79 std::optional<dsp::ProcessorParameterUuidReference>
dest_id_;
89class MidiMappings final
103 std::array<midi_byte_t, 3> buf,
104 std::optional<utils::Utf8String> device_id,
105 dsp::ProcessorParameterUuidReference dest_port,
118 std::array<midi_byte_t, 3> buf,
119 std::optional<utils::Utf8String> device_id,
120 dsp::ProcessorParameterUuidReference dest_port,
124 buf, device_id, dest_port,
static_cast<int> (mappings_.size ()),
129 std::array<midi_byte_t, 3> buf,
130 dsp::ProcessorParameterUuidReference dest_port,
134 buf, std::nullopt, dest_port,
static_cast<int> (mappings_.size ()),
138 int get_mapping_index (
const MidiMapping &mapping)
const;
163 std::vector<MidiMapping *> * arr)
const;
165 friend void init_from (
167 const MidiMappings &other,
175 static constexpr auto kMappingsKey =
"mappings"sv;
176 friend void to_json (nlohmann::json &j,
const MidiMappings &mappings)
178 j[kMappingsKey] = mappings.mappings_;
180 friend void from_json (
const nlohmann::json &j, MidiMappings &mappings);
183 std::vector<std::unique_ptr<MidiMapping>> mappings_;
void bind_at(std::array< midi_byte_t, 3 > buf, std::optional< utils::Utf8String > device_id, dsp::ProcessorParameterUuidReference dest_port, int idx, bool fire_events)
Binds the CC represented by the given raw buffer (must be size 3) to the given Port.