summaryrefslogtreecommitdiffabout
path: root/lib/MTrk.cc
blob: fa1e0f8eaa0e3590a648201487d9e592b2677626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <algorithm>
#include <iterator>
#include <midillo/MTrk.h>
#include <midillo/exception.h>

namespace midillo {
    using std::copy;
    using std::ostream_iterator;
    using std::endl;

    void MTrk_t::load(istream& s) {
	header.load(s);
	if(header.id_number!=chunk_id_MTrk)
	    throw exception_unexpected_input(CODEPOINT,"MTrk chunk expected");
	events.load(s);
    }

    void MTrk_t::save(ostream& s) const {
	chunk_header_t h = header;
	h.id_number = chunk_id_MTrk;
	h.length = events.calculate_save_size();
	h.save(s);
	events.save(s);
    }

    void MTrk_t::dump(ostream& s) const {
	s << " " << header << endl
	    << "  ";
	copy(
		events.begin(), events.end(),
		ostream_iterator<event_t>(s,"\n  ") );
    }

}