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 'lib/MThd.cc') 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 @@ +#include +#include +#include + +namespace midillo { + using std::endl; + + void MThd_t::load(istream& s) { + header.load(s); + if(header.id_number!=chunk_id_MThd) + throw exception_unexpected_input(CODEPOINT,"MThd chunk expected"); + if(header.length!=6) + throw exception_invalid_input(CODEPOINT,"MThd chunk is not 6 bytes long"); + load_data(s); + } + + void MThd_t::load_data(istream& s) { + fmt = read16(s); + ntracks = read16(s); + division = read16(s); + } + + void MThd_t::save(ostream& s) const { + header.save(s); + write16(s,fmt); + write16(s,ntracks); + write16(s,division); + } + + void MThd_t::dump(ostream& s) const { + std::ios::fmtflags ff = s.flags(); + s.unsetf(std::ios::hex); s.setf(std::ios::dec); + s << " " << header << endl + << " fmt=" << fmt << ", " << ntracks << " track(s), division=" << division << endl; + s.flags(ff); + } + +} -- cgit v0.9.0.2