00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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 }
00069
00070 #endif // RAUL_SMF_READER_HPP
00071