2 Copyright (C) 2007 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <ardour/note.h>
25 Note::Note(uint8_t chan, double t, double d, uint8_t n, uint8_t v)
26 : _on_event(t, 3, NULL, true)
27 , _off_event(t + d, 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(duration() == d);
42 assert(velocity() == v);
46 Note::Note(const Note& copy)
47 : _on_event(copy._on_event, true)
48 , _off_event(copy._off_event, true)
50 assert(_on_event.buffer());
51 assert(_off_event.buffer());
53 assert(copy._on_event.size == 3);
54 _on_event.buffer = _on_event_buffer;
55 memcpy(_on_event_buffer, copy._on_event_buffer, 3);
57 assert(copy._off_event.size == 3);
58 _off_event.buffer = _off_event_buffer;
59 memcpy(_off_event_buffer, copy._off_event_buffer, 3);
62 assert(time() == copy.time());
63 assert(end_time() == copy.end_time());
64 assert(note() == copy.note());
65 assert(velocity() == copy.velocity());
66 assert(duration() == copy.duration());
71 Note::operator=(const Note& copy)
73 _on_event = copy._on_event;
74 _off_event = copy._off_event;
75 /*_on_event.time = copy._on_event.time;
76 assert(copy._on_event.size == 3);
77 memcpy(_on_event_buffer, copy._on_event_buffer, 3);
79 _off_event.time = copy._off_event.time;
80 assert(copy._off_event.size == 3);
81 memcpy(_off_event_buffer, copy._off_event_buffer, 3);
84 assert(time() == copy.time());
85 assert(end_time() == copy.end_time());
86 assert(note() == copy.note());
87 assert(velocity() == copy.velocity());
88 assert(duration() == copy.duration());