15class PianoRollTrackMixin :
public QObject
19 bool drumMode READ drumMode WRITE setDrumMode NOTIFY drumModeChanged)
21 bool passthroughMidiInput READ passthroughMidiInput WRITE
22 setPassthroughMidiInput NOTIFY passthroughMidiInputChanged)
24 std::uint8_t midiChannel READ midiChannel WRITE setMidiChannel NOTIFY
29 PianoRollTrackMixin (QObject * parent =
nullptr);
30 Q_DISABLE_COPY_MOVE (PianoRollTrackMixin)
31 ~PianoRollTrackMixin ()
override =
default;
37 std::uint8_t midiChannel ()
const {
return midi_ch_; }
38 void setMidiChannel (std::uint8_t midi_ch)
40 midi_ch = std::clamp (
41 midi_ch,
static_cast<std::uint8_t
> (1),
static_cast<std::uint8_t
> (16));
42 if (midi_ch_ == midi_ch)
46 Q_EMIT midiChannelChanged (midi_ch);
48 Q_SIGNAL
void midiChannelChanged (std::uint8_t midi_ch);
50 bool passthroughMidiInput ()
const {
return passthrough_midi_input_; }
51 void setPassthroughMidiInput (
bool passthrough)
53 if (passthrough_midi_input_ == passthrough)
56 passthrough_midi_input_ = passthrough;
57 Q_EMIT passthroughMidiInputChanged (passthrough);
59 Q_SIGNAL
void passthroughMidiInputChanged (
bool passthrough);
61 bool drumMode ()
const {
return drum_mode_; }
62 void setDrumMode (
bool drum_mode)
64 if (drum_mode_ == drum_mode)
67 drum_mode_ = drum_mode;
68 Q_EMIT drumModeChanged (drum_mode);
70 Q_SIGNAL
void drumModeChanged (
bool drum_mode);
74 bool allow_only_specific_midi_channels ()
const
76 return midi_channels_.has_value ();
78 auto &midi_channels_to_allow ()
const {
return midi_channels_.value (); }
86 if (!passthrough_midi_input_)
93 static constexpr auto kDrumModeKey =
"drumMode"sv;
94 static constexpr auto kMidiChKey =
"midiChannel"sv;
95 static constexpr auto kPassthroughMidiInputKey =
"passthroughMidiInput"sv;
96 static constexpr auto kMidiChannelsKey =
"midiChannels"sv;
97 friend void to_json (nlohmann::json &j,
const PianoRollTrackMixin &track);
98 friend void from_json (
const nlohmann::json &j, PianoRollTrackMixin &track);
100 friend void init_from (
101 PianoRollTrackMixin &obj,
102 const PianoRollTrackMixin &other,
109 bool drum_mode_ =
false;
121 std::atomic_bool passthrough_midi_input_ =
false;
128 std::optional<std::array<bool, 16>> midi_channels_;