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(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)
29 _on_event.buffer()[0] = MIDI_CMD_NOTE_ON;
30 _on_event.buffer()[1] = n;
31 _on_event.buffer()[2] = v;
33 _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF;
34 _off_event.buffer()[1] = n;
35 _off_event.buffer()[2] = 0x40;
38 assert(duration() == d);
40 assert(velocity() == v);
44 Note::Note(const Note& copy)
45 : _on_event(copy._on_event, true)
46 , _off_event(copy._off_event, true)
48 assert(_on_event.buffer());
49 assert(_off_event.buffer());
51 assert(copy._on_event.size == 3);
52 _on_event.buffer = _on_event_buffer;
53 memcpy(_on_event_buffer, copy._on_event_buffer, 3);
55 assert(copy._off_event.size == 3);
56 _off_event.buffer = _off_event_buffer;
57 memcpy(_off_event_buffer, copy._off_event_buffer, 3);
60 assert(time() == copy.time());
61 assert(end_time() == copy.end_time());
62 assert(note() == copy.note());
63 assert(velocity() == copy.velocity());
64 assert(duration() == copy.duration());
69 Note::operator=(const Note& copy)
71 _on_event = copy._on_event;
72 _off_event = copy._off_event;
73 /*_on_event.time = copy._on_event.time;
74 assert(copy._on_event.size == 3);
75 memcpy(_on_event_buffer, copy._on_event_buffer, 3);
77 _off_event.time = copy._off_event.time;
78 assert(copy._off_event.size == 3);
79 memcpy(_off_event_buffer, copy._off_event_buffer, 3);
82 assert(time() == copy.time());
83 assert(end_time() == copy.end_time());
84 assert(note() == copy.note());
85 assert(velocity() == copy.velocity());
86 assert(duration() == copy.duration());