Include stripped down libsmf code internally.
[ardour.git] / libs / evoral / evoral / SMF.hpp
index 2587781d7af06a7fae6481f27a239e821dd681a1..313035f5e3a0f862f5c297ef7dc34efff6a3e677 100644 (file)
 #ifndef EVORAL_SMF_HPP
 #define EVORAL_SMF_HPP
 
-#include <string>
-#include "evoral/types.hpp"
+#include "evoral/StandardMIDIFile.hpp"
 
 namespace Evoral {
        
-template<typename T> class Event;
-template<typename T> class EventRingBuffer;
+template<typename Time> class Event;
+template<typename Time> class EventRingBuffer;
 
 
 /** Standard Midi File (Type 0)
  */
-template<typename T>
-class SMF {
+template<typename Time>
+class SMF : public StandardMIDIFile<Time> {
 public:
        SMF();
        virtual ~SMF();
@@ -42,10 +41,10 @@ public:
        bool     is_empty() const { return _empty; }
        bool     eof()      const { return feof(_fd); }
        
-       T last_event_time() const { return _last_ev_time; }
+       Time last_event_time() const { return _last_ev_time; }
        
        void begin_write(FrameTime start_time);
-       void append_event_unlocked(uint32_t delta_t, const Event<T>& ev);
+       void append_event_unlocked(uint32_t delta_t, const Event<Time>& ev);
        void end_write();
        
        void flush();
@@ -56,6 +55,9 @@ protected:
        int  open(const std::string& path);
        void close();
        
+       int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const;
+
+private:
        /** Used by flush_footer() to find the position to write the footer */
        void seek_to_footer_position();
        
@@ -66,13 +68,11 @@ protected:
        void     write_chunk(const char id[4], uint32_t length, void* data);
        size_t   write_var_len(uint32_t val);
        uint32_t read_var_len() const;
-       int      read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const;
 
-private:
        static const uint16_t _ppqn = 19200;
 
        FILE*    _fd;
-       T        _last_ev_time; ///< last frame time written, relative to source start
+       Time     _last_ev_time; ///< last frame time written, relative to source start
        uint32_t _track_size;
        uint32_t _header_size; ///< size of SMF header, including MTrk chunk header
        bool     _empty; ///< true iff file contains(non-empty) events