1 /* This file is part of Evoral.
2 * Copyright(C) 2008 Dave Robillard <http://drobilla.net>
3 * Copyright(C) 2000-2008 Paul Davis
6 * Evoral is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation; either version 2 of the License, or(at your option) any later
11 * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef EVORAL_STANDARD_MIDI_FILE_HPP
21 #define EVORAL_STANDARD_MIDI_FILE_HPP
24 #include "evoral/types.hpp"
28 template<typename Time> class Event;
29 template<typename Time> class EventRingBuffer;
31 #define THROW_FILE_ERROR throw(typename MIDIFile<Time>::FileError)
33 /** Standard MIDI File interface
35 template<typename Time>
38 class FileError : public std::exception {
39 const char* what() const throw() { return "libsmf error"; }
42 virtual void seek_to_start() const = 0;
44 virtual uint16_t ppqn() const = 0;
45 virtual bool is_empty() const = 0;
46 virtual bool eof() const = 0;
48 virtual Time last_event_time() const = 0;
50 virtual void begin_write(FrameTime start_time) = 0;
51 virtual void append_event_unlocked(uint32_t delta_t, const Event<Time>& ev) = 0;
52 virtual void end_write() throw(FileError) = 0;
54 virtual void flush() = 0;
55 virtual int flush_header() = 0;
56 virtual int flush_footer() = 0;
59 virtual int open(const std::string& path) throw(FileError) = 0;
60 virtual void close() throw(FileError) = 0;
62 virtual int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const = 0;
66 }; /* namespace Evoral */
68 #endif /* EVORAL_STANDARD_MIDI_FILE_HPP */