From 0c21a7a0d5b84dc6726462f0fbe51b8c32433262 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Fri, 11 Aug 2006 16:01:56 +0000 Subject: initial commit into repository --- (limited to 'include/midillo/MThd.h') diff --git a/include/midillo/MThd.h b/include/midillo/MThd.h new file mode 100644 index 0000000..20263cd --- a/dev/null +++ b/include/midillo/MThd.h @@ -0,0 +1,74 @@ +#ifndef __MIDILLO_MTHD_H +#define __MIDILLO_MTHD_H + +#include +#include +#include + +/** + * @file + * @brief the MThd_t -- MThd header chunk class + */ + +namespace midillo { + using std::istream; + using std::ostream; + + /** + * MThd header chunk container + */ + class MThd_t : public chunk_t { + public: + enum { + fmt_0 = 0, fmt_1 = 1, fmt_2 = 2, + fmt_singletrack = fmt_0, + fmt_multitrack = fmt_1, + fmt_tracksequence = fmt_2 + }; + /** + * SMF format. 0 for single track, 1 for multitrack, 2 for track + * sequence. + */ + int fmt; + /** + * Number of tracks in the file + */ + int ntracks; + /** + * The number of pulses per quarter note + */ + int division; + + /** + * Load MThd chunk from the stream + * @param s input stream + */ + void load(istream& s); + + /** + * Read MThd chunk data from the stream. This function assumes that + * header is already read. + * @param s input stream + */ + void load_data(istream& s); + + /** + * Save MThd chunk to the stream + * @param s output stream + */ + void save(ostream& s) const; + + /** + * Dump textual representation of MThd chunk to stream + * @param s output stream + */ + void dump(ostream& s) const; + }; + + inline ostream& operator<<(ostream& s,const MThd_t& mthd) { + mthd.dump(s); return s; + } + +} + +#endif /* MIDILLO_MTHD_H */ -- cgit v0.9.0.2