#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();
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();
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();
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