6#include "zrythm-config.h"
11#include "dsp/position.h"
12#include "gui/dsp/bounded_object.h"
13#include "gui/dsp/muteable_object.h"
14#include "gui/dsp/velocity.h"
27 public MuteableObject,
28 public RegionOwnedObject,
30 public ICloneable<MidiNote>
34 DEFINE_ARRANGER_OBJECT_QML_PROPERTIES (
MidiNote)
35 DEFINE_BOUNDED_OBJECT_QML_PROPERTIES (
MidiNote)
36 Q_PROPERTY (
int pitch READ getPitch WRITE setPitch NOTIFY pitchChanged)
39 using RegionT = MidiRegion;
41 DECLARE_FINAL_ARRANGER_OBJECT_CONSTRUCTORS (
MidiNote)
56 int getPitch ()
const {
return static_cast<int> (
pitch_); }
58 void setPitch (
int ipitch)
60 const auto pitch =
static_cast<midi_byte_t> (ipitch);
64 Q_EMIT pitchChanged ();
67 Q_SIGNAL
void pitchChanged ();
71 void set_cache_val (
const uint8_t val) {
cache_pitch_ = val; }
96 void set_velocity (
int vel) {
vel_->setValue (vel); }
105 ArrangerObjectPtrVariant
121 static constexpr std::string_view kVelocityKey =
"velocity";
122 static constexpr std::string_view kPitchKey =
"pitch";
123 friend void to_json (nlohmann::json &j,
const MidiNote ¬e)
125 to_json (j,
static_cast<const ArrangerObject &
> (note));
126 to_json (j,
static_cast<const BoundedObject &
> (note));
127 to_json (j,
static_cast<const MuteableObject &
> (note));
128 to_json (j,
static_cast<const RegionOwnedObject &
> (note));
129 j[kVelocityKey] = note.
vel_;
130 j[kPitchKey] = note.
pitch_;
132 friend void from_json (
const nlohmann::json &j,
MidiNote ¬e)
138 j.at (kVelocityKey).get_to (*note.
vel_);
139 j.at (kPitchKey).get_to (note.
pitch_);
176 "MidiNote [{} ~ {}]: note {}, vel {}", mn.
get_position (),
Base class for all objects in the arranger.
auto get_position() const
Getter.
Base class for all objects in the arranger that have a length.
auto get_end_position() const
Getter.
A MIDI note inside a Region shown in the piano roll.
utils::Utf8String get_val_as_string(Notation notation, bool use_markup) const
Gets the MIDI note's value as a string (eg "C#4").
bool currently_listened_
Whether or not this note is currently listened to.
bool validate(bool is_project, dsp::FramesPerTick frames_per_tick) const override
Validates the arranger object.
uint8_t last_listened_pitch_
The note/pitch that is currently playing, if currently_listened_ is true.
void init_after_cloning(const MidiNote &other, ObjectCloneType clone_type) override
Initializes the cloned object.
ArrangerObjectPtrVariant insert_clone_to_project() const override
Inserts the object where it belongs in the project (eg, a Track).
uint8_t pitch_
The note/pitch, (0-127).
void set_pitch(uint8_t val)
Sends a note off if currently playing and sets the pitch of the MidiNote.
void shift_pitch(int delta)
Shifts MidiNote's position and/or value.
void listen(bool listen)
Listen to the given MidiNote.
ArrangerObjectPtrVariant add_clone_to_project(bool fire_events) const override
Appends the ArrangerObject to where it belongs in the project (eg, a Track), without taking into acco...
utils::Utf8String gen_human_friendly_name() const override
Generates a human readable name for the object.
uint8_t cache_pitch_
Cached note, for live operations.
VelocityValueT vel_
Pointer back to the MIDI note (this is also the QObject parent).
Lightweight UTF-8 string wrapper with safe conversions.
#define DEFINE_OBJECT_FORMATTER(obj_type, function_prefix, formatter_func)
Defines a formatter for the given object type.
uint8_t midi_byte_t
MIDI byte.