1 /* This file is part of Evoral.
2 * Copyright(C) 2008 Dave Robillard <http://drobilla.net>
3 * Copyright(C) 2000-2008 Paul Davis
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
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.
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
19 #ifndef EVORAL_OLD_SMF_HPP
20 #define EVORAL_OLD_SMF_HPP
24 template<typename Time> class Event;
25 template<typename Time> class EventRingBuffer;
28 /** Standard Midi File (Type 0)
30 template<typename Time>
36 void seek_to_start() const;
38 uint16_t ppqn() const { return _ppqn; }
39 bool is_empty() const { return _empty; }
40 bool eof() const { return feof(_fd); }
42 Time last_event_time() const { return _last_ev_time; }
45 void append_event_delta(uint32_t delta_t, const Event<Time>& ev);
46 void end_write() THROW_FILE_ERROR;
53 int open(const std::string& path) THROW_FILE_ERROR;
54 void close() THROW_FILE_ERROR;
56 int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const;
59 /** Used by flush_footer() to find the position to write the footer */
60 void seek_to_footer_position();
62 /** Write the track footer at the current seek position */
65 void write_chunk_header(const char id[4], uint32_t length);
66 void write_chunk(const char id[4], uint32_t length, void* data);
67 size_t write_var_len(uint32_t val);
68 uint32_t read_var_len() const;
70 static const uint16_t _ppqn = 19200;
73 Time _last_ev_time; ///< last frame time written, relative to source start
75 uint32_t _header_size; ///< size of SMF header, including MTrk chunk header
76 bool _empty; ///< true iff file contains(non-empty) events
79 }; /* namespace Evoral */
81 #endif /* EVORAL_OLD_SMF_HPP */