Fix include statements so they match all other files in gtk2_ardour
[ardour.git] / libs / ardour / note.cc
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: Dave Robillard
4
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.
9
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.
14
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.
18
19 */
20
21 #include <ardour/note.h>
22
23 namespace ARDOUR {
24
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)
28 {
29         _on_event.buffer()[0] = MIDI_CMD_NOTE_ON;
30         _on_event.buffer()[1] = n;
31         _on_event.buffer()[2] = v;
32         
33         _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF;
34         _off_event.buffer()[1] = n;
35         _off_event.buffer()[2] = 0x40;
36         
37         assert(time() == t);
38         assert(duration() == d);
39         assert(note() == n);
40         assert(velocity() == v);
41 }
42
43
44 Note::Note(const Note& copy)
45         : _on_event(copy._on_event, true)
46         , _off_event(copy._off_event, true)
47 {
48         assert(_on_event.buffer());
49         assert(_off_event.buffer());
50         /*
51         assert(copy._on_event.size == 3);
52         _on_event.buffer = _on_event_buffer;
53         memcpy(_on_event_buffer, copy._on_event_buffer, 3);
54         
55         assert(copy._off_event.size == 3);
56         _off_event.buffer = _off_event_buffer;
57         memcpy(_off_event_buffer, copy._off_event_buffer, 3);
58         */
59
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());
65 }
66
67
68 const Note&
69 Note::operator=(const Note& copy)
70 {
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);
76         
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);
80         */
81         
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());
87
88         return *this;
89 }
90
91 } // namespace ARDOUR