fix up and re-enable MTC transmission
[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(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)
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(duration() == d);
41         assert(note() == n);
42         assert(velocity() == v);
43 }
44
45
46 Note::Note(const Note& copy)
47         : _on_event(copy._on_event, true)
48         , _off_event(copy._off_event, true)
49 {
50         assert(_on_event.buffer());
51         assert(_off_event.buffer());
52         /*
53         assert(copy._on_event.size == 3);
54         _on_event.buffer = _on_event_buffer;
55         memcpy(_on_event_buffer, copy._on_event_buffer, 3);
56         
57         assert(copy._off_event.size == 3);
58         _off_event.buffer = _off_event_buffer;
59         memcpy(_off_event_buffer, copy._off_event_buffer, 3);
60         */
61
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());
67 }
68
69
70 const Note&
71 Note::operator=(const Note& copy)
72 {
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);
78         
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);
82         */
83         
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());
89
90         return *this;
91 }
92
93 } // namespace ARDOUR