summaryrefslogtreecommitdiffabout
path: root/lib/MThd.cc
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 /lib/MThd.cc
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'lib/MThd.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/MThd.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/MThd.cc b/lib/MThd.cc
new file mode 100644
index 0000000..110c98a
--- a/dev/null
+++ b/lib/MThd.cc
@@ -0,0 +1,38 @@
1#include <midillo/MThd.h>
2#include <midillo/util.h>
3#include <midillo/exception.h>
4
5namespace midillo {
6 using std::endl;
7
8 void MThd_t::load(istream& s) {
9 header.load(s);
10 if(header.id_number!=chunk_id_MThd)
11 throw exception_unexpected_input(CODEPOINT,"MThd chunk expected");
12 if(header.length!=6)
13 throw exception_invalid_input(CODEPOINT,"MThd chunk is not 6 bytes long");
14 load_data(s);
15 }
16
17 void MThd_t::load_data(istream& s) {
18 fmt = read16(s);
19 ntracks = read16(s);
20 division = read16(s);
21 }
22
23 void MThd_t::save(ostream& s) const {
24 header.save(s);
25 write16(s,fmt);
26 write16(s,ntracks);
27 write16(s,division);
28 }
29
30 void MThd_t::dump(ostream& s) const {
31 std::ios::fmtflags ff = s.flags();
32 s.unsetf(std::ios::hex); s.setf(std::ios::dec);
33 s << " " << header << endl
34 << " fmt=" << fmt << ", " << ntracks << " track(s), division=" << division << endl;
35 s.flags(ff);
36 }
37
38}