Const correctness.
[ardour.git] / libs / evoral / src / Note.cpp
index 88be34fb36559c5a151c8ce804cba8afe6544040..794fe33c48ac5993761de2f1cbd511776441e437 100644 (file)
  */
 
 #include <iostream>
-#include <evoral/Note.hpp>
+#include "evoral/Note.hpp"
 
 namespace Evoral {
 
-Note::Note(uint8_t chan, double t, double d, uint8_t n, uint8_t v)
-       : _on_event(t, 3, NULL, true)
-       , _off_event(t + d, 3, NULL, true)
+template<typename Time>
+Note<Time>::Note(uint8_t chan, Time t, EventLength l, uint8_t n, uint8_t v)
+       // FIXME: types?
+       : _on_event(0xDE, t, 3, NULL, true)
+       , _off_event(0xAD, t + l, 3, NULL, true)
 {
        assert(chan < 16);
 
@@ -36,7 +38,7 @@ Note::Note(uint8_t chan, double t, double d, uint8_t n, uint8_t v)
        _off_event.buffer()[2] = 0x40;
        
        assert(time() == t);
-       assert(duration() == d);
+       assert(length() == l);
        assert(note() == n);
        assert(velocity() == v);
        assert(_on_event.channel() == _off_event.channel());
@@ -44,7 +46,8 @@ Note::Note(uint8_t chan, double t, double d, uint8_t n, uint8_t v)
 }
 
 
-Note::Note(const Note& copy)
+template<typename Time>
+Note<Time>::Note(const Note<Time>& copy)
        : _on_event(copy._on_event, true)
        , _off_event(copy._off_event, true)
 {
@@ -64,40 +67,36 @@ Note::Note(const Note& copy)
        assert(end_time() == copy.end_time());
        assert(note() == copy.note());
        assert(velocity() == copy.velocity());
-       assert(duration() == copy.duration());
+       assert(length() == copy.length());
        assert(_on_event.channel() == _off_event.channel());
        assert(channel() == copy.channel());
 }
 
 
-Note::~Note()
+template<typename Time>
+Note<Time>::~Note()
 {
 }
 
 
-const Note&
-Note::operator=(const Note& copy)
+template<typename Time>
+const Note<Time>&
+Note<Time>::operator=(const Note<Time>& copy)
 {
        _on_event = copy._on_event;
        _off_event = copy._off_event;
-       /*_on_event.time = copy._on_event.time;
-       assert(copy._on_event.size == 3);
-       memcpy(_on_event_buffer, copy._on_event_buffer, 3);
-       
-       _off_event.time = copy._off_event.time;
-       assert(copy._off_event.size == 3);
-       memcpy(_off_event_buffer, copy._off_event_buffer, 3);
-       */
        
        assert(time() == copy.time());
        assert(end_time() == copy.end_time());
        assert(note() == copy.note());
        assert(velocity() == copy.velocity());
-       assert(duration() == copy.duration());
+       assert(length() == copy.length());
        assert(_on_event.channel() == _off_event.channel());
        assert(channel() == copy.channel());
        
        return *this;
 }
 
+template class Note<double>;
+
 } // namespace Evoral