22class PianoRollTrackMixin :
public QObject
26 bool drumMode READ drumMode WRITE setDrumMode NOTIFY drumModeChanged)
28 bool passthroughMidiInput READ passthroughMidiInput WRITE
29 setPassthroughMidiInput NOTIFY passthroughMidiInputChanged)
31 std::uint8_t midiChannel READ midiChannel WRITE setMidiChannel NOTIFY
36 PianoRollTrackMixin (QObject * parent =
nullptr);
37 Q_DISABLE_COPY_MOVE (PianoRollTrackMixin)
38 ~PianoRollTrackMixin ()
override =
default;
44 std::uint8_t midiChannel ()
const {
return midi_ch_; }
45 void setMidiChannel (std::uint8_t midi_ch)
47 midi_ch = std::clamp (
48 midi_ch,
static_cast<std::uint8_t
> (1),
static_cast<std::uint8_t
> (16));
49 if (midi_ch_ == midi_ch)
53 Q_EMIT midiChannelChanged (midi_ch);
55 Q_SIGNAL
void midiChannelChanged (std::uint8_t midi_ch);
57 bool passthroughMidiInput ()
const {
return passthrough_midi_input_; }
58 void setPassthroughMidiInput (
bool passthrough)
60 if (passthrough_midi_input_ == passthrough)
63 passthrough_midi_input_ = passthrough;
64 Q_EMIT passthroughMidiInputChanged (passthrough);
66 Q_SIGNAL
void passthroughMidiInputChanged (
bool passthrough);
68 bool drumMode ()
const {
return drum_mode_; }
69 void setDrumMode (
bool drum_mode)
71 if (drum_mode_ == drum_mode)
74 drum_mode_ = drum_mode;
75 Q_EMIT drumModeChanged (drum_mode);
77 Q_SIGNAL
void drumModeChanged (
bool drum_mode);
81 bool allow_only_specific_midi_channels ()
const
83 return midi_channels_.has_value ();
85 auto &midi_channels_to_allow ()
const {
return midi_channels_.value (); }
93 if (!passthrough_midi_input_)
100 static constexpr auto kDrumModeKey =
"drumMode"sv;
101 static constexpr auto kMidiChKey =
"midiChannel"sv;
102 static constexpr auto kPassthroughMidiInputKey =
"passthroughMidiInput"sv;
103 static constexpr auto kMidiChannelsKey =
"midiChannels"sv;
104 friend void to_json (nlohmann::json &j,
const PianoRollTrackMixin &track);
105 friend void from_json (
const nlohmann::json &j, PianoRollTrackMixin &track);
107 friend void init_from (
108 PianoRollTrackMixin &obj,
109 const PianoRollTrackMixin &other,
116 bool drum_mode_ =
false;
128 std::atomic_bool passthrough_midi_input_ =
false;
135 std::optional<std::array<bool, 16>> midi_channels_;