summaryrefslogtreecommitdiffabout
path: root/include/midillo/MThd.h
authorMichael Krelin <hacker@klever.net>2006-08-11 16:01:56 (UTC)
committer Michael Krelin <hacker@klever.net>2006-08-11 16:01:56 (UTC)
commit0c21a7a0d5b84dc6726462f0fbe51b8c32433262 (patch) (side-by-side diff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /include/midillo/MThd.h
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0.0.zip
midillo-0.0.tar.gz
midillo-0.0.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'include/midillo/MThd.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/midillo/MThd.h74
1 files changed, 74 insertions, 0 deletions
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 <istream>
+#include <ostream>
+#include <midillo/chunk.h>
+
+/**
+ * @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 */