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) (unidiff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /include/midillo/MThd.h
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.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 @@
1#ifndef __MIDILLO_MTHD_H
2#define __MIDILLO_MTHD_H
3
4#include <istream>
5#include <ostream>
6#include <midillo/chunk.h>
7
8/**
9 * @file
10 * @brief the MThd_t -- MThd header chunk class
11 */
12
13namespace midillo {
14 using std::istream;
15 using std::ostream;
16
17 /**
18 * MThd header chunk container
19 */
20 class MThd_t : public chunk_t {
21 public:
22 enum {
23 fmt_0 = 0, fmt_1 = 1, fmt_2 = 2,
24 fmt_singletrack = fmt_0,
25 fmt_multitrack = fmt_1,
26 fmt_tracksequence = fmt_2
27 };
28 /**
29 * SMF format. 0 for single track, 1 for multitrack, 2 for track
30 * sequence.
31 */
32 int fmt;
33 /**
34 * Number of tracks in the file
35 */
36 int ntracks;
37 /**
38 * The number of pulses per quarter note
39 */
40 int division;
41
42 /**
43 * Load MThd chunk from the stream
44 * @param s input stream
45 */
46 void load(istream& s);
47
48 /**
49 * Read MThd chunk data from the stream. This function assumes that
50 * header is already read.
51 * @param s input stream
52 */
53 void load_data(istream& s);
54
55 /**
56 * Save MThd chunk to the stream
57 * @param s output stream
58 */
59 void save(ostream& s) const;
60
61 /**
62 * Dump textual representation of MThd chunk to stream
63 * @param s output stream
64 */
65 void dump(ostream& s) const;
66 };
67
68 inline ostream& operator<<(ostream& s,const MThd_t& mthd) {
69 mthd.dump(s); return s;
70 }
71
72}
73
74#endif /* MIDILLO_MTHD_H */