-rw-r--r-- | lib/MTrk.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/MTrk.cc b/lib/MTrk.cc new file mode 100644 index 0000000..fa1e0f8 --- a/dev/null +++ b/lib/MTrk.cc | |||
@@ -0,0 +1,34 @@ | |||
1 | #include <algorithm> | ||
2 | #include <iterator> | ||
3 | #include <midillo/MTrk.h> | ||
4 | #include <midillo/exception.h> | ||
5 | |||
6 | namespace midillo { | ||
7 | using std::copy; | ||
8 | using std::ostream_iterator; | ||
9 | using std::endl; | ||
10 | |||
11 | void MTrk_t::load(istream& s) { | ||
12 | header.load(s); | ||
13 | if(header.id_number!=chunk_id_MTrk) | ||
14 | throw exception_unexpected_input(CODEPOINT,"MTrk chunk expected"); | ||
15 | events.load(s); | ||
16 | } | ||
17 | |||
18 | void MTrk_t::save(ostream& s) const { | ||
19 | chunk_header_t h = header; | ||
20 | h.id_number = chunk_id_MTrk; | ||
21 | h.length = events.calculate_save_size(); | ||
22 | h.save(s); | ||
23 | events.save(s); | ||
24 | } | ||
25 | |||
26 | void MTrk_t::dump(ostream& s) const { | ||
27 | s << " " << header << endl | ||
28 | << " "; | ||
29 | copy( | ||
30 | events.begin(), events.end(), | ||
31 | ostream_iterator<event_t>(s,"\n ") ); | ||
32 | } | ||
33 | |||
34 | } | ||