1 /* This file is part of Evoral.
2 * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
3 * Copyright (C) 2000-2008 Paul Davis
5 * Evoral is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option) any later
10 * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <evoral/Note.hpp>
24 Note::Note(uint8_t chan, EventTime t, EventLength l, uint8_t n, uint8_t v)
26 : _on_event(0xDE, t, 3, NULL, true)
27 , _off_event(0xAD, t + l, 3, NULL, true)
31 _on_event.buffer()[0] = MIDI_CMD_NOTE_ON + chan;
32 _on_event.buffer()[1] = n;
33 _on_event.buffer()[2] = v;
35 _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF + chan;
36 _off_event.buffer()[1] = n;
37 _off_event.buffer()[2] = 0x40;
40 assert(length() == l);
42 assert(velocity() == v);
43 assert(_on_event.channel() == _off_event.channel());
44 assert(channel() == chan);
48 Note::Note(const Note& copy)
49 : _on_event(copy._on_event, true)
50 , _off_event(copy._off_event, true)
52 assert(_on_event.buffer());
53 assert(_off_event.buffer());
55 assert(copy._on_event.size == 3);
56 _on_event.buffer = _on_event_buffer;
57 memcpy(_on_event_buffer, copy._on_event_buffer, 3);
59 assert(copy._off_event.size == 3);
60 _off_event.buffer = _off_event_buffer;
61 memcpy(_off_event_buffer, copy._off_event_buffer, 3);
64 assert(time() == copy.time());
65 assert(end_time() == copy.end_time());
66 assert(note() == copy.note());
67 assert(velocity() == copy.velocity());
68 assert(length() == copy.length());
69 assert(_on_event.channel() == _off_event.channel());
70 assert(channel() == copy.channel());
80 Note::operator=(const Note& copy)
82 _on_event = copy._on_event;
83 _off_event = copy._off_event;
85 assert(time() == copy.time());
86 assert(end_time() == copy.end_time());
87 assert(note() == copy.note());
88 assert(velocity() == copy.velocity());
89 assert(length() == copy.length());
90 assert(_on_event.channel() == _off_event.channel());
91 assert(channel() == copy.channel());