21 #ifndef EVORAL_NOTE_HPP
22 #define EVORAL_NOTE_HPP
38 template<
typename Time>
45 Note(uint8_t chan=0, Time time=Time(), Time len=Time(), uint8_t note=0, uint8_t vel=0x40);
50 return time() == other.
time() &&
51 note() == other.
note() &&
61 inline Time
time()
const {
return _on_event.time(); }
62 inline Time
end_time()
const {
return _off_event.time(); }
63 inline uint8_t
note()
const {
return _on_event.note(); }
64 inline uint8_t
velocity()
const {
return _on_event.velocity(); }
65 inline uint8_t
off_velocity()
const {
return _off_event.velocity(); }
66 inline Time
length()
const {
return _off_event.time() - _on_event.time(); }
68 assert(_on_event.channel() == _off_event.channel());
69 return _on_event.channel();
75 inline uint8_t
clamp(
int val,
int low,
int high) {
76 const int r = std::min (std::max (val, low), high);
77 assert (r < 256 && r >= 0);
83 _off_event.set_time(t +
length());
84 _on_event.set_time(t);
87 const uint8_t nn = clamp(n, 0, 127);
88 _on_event.buffer()[1] = nn;
89 _off_event.buffer()[1] = nn;
92 _on_event.buffer()[2] = clamp(n, 0, 127);
95 _off_event.buffer()[2] = clamp(n, 0, 127);
98 _off_event.set_time(_on_event.time() + l);
101 const uint8_t cc = clamp(c, 0, 16);
102 _on_event.set_channel(cc);
103 _off_event.set_channel(cc);
117 template<
typename Time>
119 o <<
"Note #" << n.
id() <<
": pitch = " << (int) n.
note()
121 <<
" velocity " << (int) n.
velocity()
122 <<
" chn " << (int) n.
channel();
129 #include "../src/Note.impl"
uint8_t off_velocity() const
bool operator==(const Note< Time > &other)
const Event< Time > & on_event() const
void set_off_velocity(uint8_t n)
void set_velocity(uint8_t n)
const Event< Time > & off_event() const
Event< Time > & off_event()
Note(const Note< Time > ©)
Event< Time > & on_event()
const Note< Time > & operator=(const Note< Time > ©)
Note(uint8_t chan=0, Time time=Time(), Time len=Time(), uint8_t note=0, uint8_t vel=0x40)
uint8_t clamp(int val, int low, int high)
void set_channel(uint8_t c)
#define LIBEVORAL_TEMPLATE_API
PBD::PropertyDescriptor< timecnt_t > length
std::ostream & operator<<(std::ostream &o, const Evoral::Event< Time > &ev)