Fix pollution of global namespace by Evoral.
[ardour.git] / libs / evoral / src / Note.cpp
1 /* This file is part of Evoral.
2  * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
3  * Copyright (C) 2000-2008 Paul Davis
4  * 
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
8  * version.
9  * 
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.
13  * 
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
17  */
18
19 #include <iostream>
20 #include <evoral/Note.hpp>
21
22 namespace Evoral {
23
24 Note::Note(uint8_t chan, EventTime t, EventLength l, uint8_t n, uint8_t v)
25         // FIXME: types?
26         : _on_event(0xDE, t, 3, NULL, true)
27         , _off_event(0xAD, t + l, 3, NULL, true)
28 {
29         assert(chan < 16);
30
31         _on_event.buffer()[0] = MIDI_CMD_NOTE_ON + chan;
32         _on_event.buffer()[1] = n;
33         _on_event.buffer()[2] = v;
34         
35         _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF + chan;
36         _off_event.buffer()[1] = n;
37         _off_event.buffer()[2] = 0x40;
38         
39         assert(time() == t);
40         assert(length() == l);
41         assert(note() == n);
42         assert(velocity() == v);
43         assert(_on_event.channel() == _off_event.channel());
44         assert(channel() == chan);
45 }
46
47
48 Note::Note(const Note& copy)
49         : _on_event(copy._on_event, true)
50         , _off_event(copy._off_event, true)
51 {
52         assert(_on_event.buffer());
53         assert(_off_event.buffer());
54         /*
55         assert(copy._on_event.size == 3);
56         _on_event.buffer = _on_event_buffer;
57         memcpy(_on_event_buffer, copy._on_event_buffer, 3);
58         
59         assert(copy._off_event.size == 3);
60         _off_event.buffer = _off_event_buffer;
61         memcpy(_off_event_buffer, copy._off_event_buffer, 3);
62         */
63
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());
71 }
72
73
74 Note::~Note()
75 {
76 }
77
78
79 const Note&
80 Note::operator=(const Note& copy)
81 {
82         _on_event = copy._on_event;
83         _off_event = copy._off_event;
84         
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());
92         
93         return *this;
94 }
95
96 } // namespace Evoral