Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
midi_input_selection.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <string>
7
8#include "utils/qt.h"
9#include "utils/utf8_string.h"
10
11#include <QObject>
12#include <QtQmlIntegration/qqmlintegration.h>
13
14#include <nlohmann/json_fwd.hpp>
15
16namespace zrythm::dsp
17{
18
26class MidiInputSelection : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY (
30 QString deviceIdentifier READ deviceIdentifier WRITE setDeviceIdentifier
31 NOTIFY deviceIdentifierChanged)
32 Q_PROPERTY (
33 int midiChannel READ midiChannel WRITE setMidiChannel NOTIFY
34 midiChannelChanged)
35 QML_ELEMENT
36 QML_UNCREATABLE ("Created by ProjectUiState")
37
38public:
39 explicit MidiInputSelection (QObject * parent = nullptr)
40 : QObject (parent) { }
41 ~MidiInputSelection () override = default;
42 Q_DISABLE_COPY_MOVE (MidiInputSelection)
43
44 QString deviceIdentifier () const;
45 void setDeviceIdentifier (const QString &identifier);
46 Q_SIGNAL void deviceIdentifierChanged ();
47
48 int midiChannel () const { return midi_channel_; }
49 void setMidiChannel (int ch);
50 Q_SIGNAL void midiChannelChanged ();
51
52 friend bool
53 operator== (const MidiInputSelection &a, const MidiInputSelection &b);
54
55private:
56 friend void to_json (nlohmann::json &j, const MidiInputSelection &sel);
57 friend void from_json (const nlohmann::json &j, MidiInputSelection &sel);
58
59 utils::Utf8String device_identifier_;
60 int midi_channel_ = 0; // 0 = omni (all channels), 1-16 = specific
61};
62
63} // namespace zrythm::dsp
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:37