From 8b6b314cce7a721e828ecb022f2b5400aa05c07c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 9 Mar 2007 22:28:33 +0000 Subject: SMF reading/writing fixes. git-svn-id: http://svn.drobilla.net/lad/raul@345 a436a847-0d15-0410-975c-d299462d15a1 --- raul/SMFReader.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 raul/SMFReader.h (limited to 'raul/SMFReader.h') diff --git a/raul/SMFReader.h b/raul/SMFReader.h new file mode 100644 index 0000000..3878044 --- /dev/null +++ b/raul/SMFReader.h @@ -0,0 +1,67 @@ +/* This file is part of Raul. + * Copyright (C) 2007 Dave Robillard + * + * Raul is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Raul is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef RAUL_SMFREADER_H +#define RAUL_SMFREADER_H + +#include + +namespace Raul { + + +/** Standard Midi File (Type 0) Reader + * + * Currently this only reads SMF files with tempo-based timing. + */ +class SMFReader { +public: + SMFReader(); + ~SMFReader(); + + bool open(const std::string& filename); + + uint16_t ppqn() const { return _ppqn; } + + size_t num_tracks() throw (std::logic_error); + + int read_event(size_t buf_len, char* buf, size_t* ev_size, uint64_t* ev_time); + + void close(); + +protected: + //static const uint32_t VAR_LEN_MAX = 0x0FFFFFFF; + + /** size of SMF header, including MTrk chunk header */ + static const uint32_t HEADER_SIZE = 22; + + uint32_t read_var_len() const; + + std::string _filename; + FILE* _fd; + uint16_t _ppqn; + uint64_t _last_ev_time; + uint32_t _track_size; +/* Raul::BeatTime _start_time; + Raul::BeatTime _last_ev_time; ///< Time last event was written relative to _start_time + */ +}; + + +} // namespace Raul + +#endif // RAUL_SMFREADER_H + -- cgit v1.2.1