/builddir/build/BUILD/raul-0.4.0/raul/SMFReader.hpp

00001 /* This file is part of Raul.
00002  * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
00003  * 
00004  * Raul is free software; you can redistribute it and/or modify it under the
00005  * terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  * 
00009  * Raul is distributed in the hope that it will be useful, but WITHOUT ANY
00010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
00012  * 
00013  * You should have received a copy of the GNU General Public License along
00014  * with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00016  */
00017 
00018 #ifndef RAUL_SMF_READER_HPP
00019 #define RAUL_SMF_READER_HPP
00020 
00021 #include <stdexcept>
00022 #include <string>
00023 #include <inttypes.h>
00024 
00025 namespace Raul {
00026 
00027 
00032 class SMFReader {
00033 public:
00034     SMFReader();
00035     ~SMFReader();
00036 
00037     bool open(const std::string& filename);
00038 
00039     bool seek_to_track(unsigned track) throw (std::logic_error);
00040 
00041     uint16_t type() const { return _type; }
00042     uint16_t ppqn() const { return _ppqn; }
00043     size_t   num_tracks() { return _num_tracks; }
00044 
00045     int read_event(size_t    buf_len,
00046                    uint8_t*  buf,
00047                    uint32_t* ev_size,
00048                    uint32_t* ev_delta_time) throw (std::logic_error);
00049     
00050     void close();
00051 
00052 protected:
00054     static const uint32_t HEADER_SIZE = 22;
00055 
00056     uint32_t read_var_len() const;
00057 
00058     std::string    _filename;
00059     FILE*          _fd;
00060     uint16_t       _type;
00061     uint16_t       _ppqn;
00062     uint16_t       _num_tracks;
00063     uint32_t       _track;
00064     uint32_t       _track_size;
00065 };
00066 
00067 
00068 } // namespace Raul
00069 
00070 #endif // RAUL_SMF_READER_HPP
00071 

Generated on Wed Apr 9 08:14:41 2008 for RAUL by  doxygen 1.5.1