19 #ifndef EVORAL_NOTE_HPP
20 #define EVORAL_NOTE_HPP
35 template<
typename Time>
42 Note(uint8_t chan=0, Time time=Time(), Time len=Time(), uint8_t note=0, uint8_t vel=0x40);
49 return time() == other.
time() &&
50 note() == other.
note() &&
60 inline Time
time()
const {
return _on_event.time(); }
61 inline Time
end_time()
const {
return _off_event.time(); }
62 inline uint8_t
note()
const {
return _on_event.note(); }
63 inline uint8_t
velocity()
const {
return _on_event.velocity(); }
64 inline uint8_t
off_velocity()
const {
return _off_event.velocity(); }
65 inline Time
length()
const {
return _off_event.time() - _on_event.time(); }
67 assert(_on_event.channel() == _off_event.channel());
68 return _on_event.channel();
72 inline int clamp(
int val,
int low,
int high) {
73 return std::min (std::max (val, low), high);
78 _off_event.set_time(t +
length());
79 _on_event.set_time(t);
82 const uint8_t nn =
clamp(n, 0, 127);
83 _on_event.buffer()[1] = nn;
84 _off_event.buffer()[1] = nn;
87 _on_event.buffer()[2] =
clamp(n, 0, 127);
90 _off_event.buffer()[2] =
clamp(n, 0, 127);
93 _off_event.set_time(_on_event.time() + l);
96 const uint8_t cc =
clamp(c, 0, 16);
97 _on_event.set_channel(cc);
98 _off_event.set_channel(cc);
112 template<
typename Time>
113 std::ostream& operator<<(std::ostream& o, const Evoral::Note<Time>& n) {
114 o <<
"Note #" << n.id() <<
": pitch = " << (int) n.note()
115 <<
" @ " << n.time() <<
" .. " << n.end_time()
116 <<
" velocity " << (int) n.velocity()
117 <<
" chn " << (int) n.channel();
124 #include "../src/Note.impl"
127 #endif // EVORAL_NOTE_HPP
Event< Time > & on_event()
void set_velocity(uint8_t n)
LIBEVORAL_API uint64_t Note
bool operator==(const Note< Time > &other)
MIDIEvent< Time > _off_event
void set_channel(uint8_t c)
Event< Time > & off_event()
const Event< Time > & off_event() const
const Event< Time > & on_event() const
uint8_t off_velocity() const
#define LIBEVORAL_TEMPLATE_API
void set_off_velocity(uint8_t n)
static double clamp(double val, double min, double max)
MIDIEvent< Time > _on_event
int clamp(int val, int low, int high)
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length