blob: 8b6c0344a0a6a059fca10fcde8a360e631076070 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#ifndef __MIDILLO_CHUNK_H
#define __MIDILLO_CHUNK_H
#include <istream>
#include <ostream>
/**
* @file
* @brief Generic SMF chunk manipulation
*/
namespace midillo {
using std::istream;
using std::ostream;
enum {
chunk_id_MThd = 0x6468544d,
chunk_id_MTrk = 0x6b72544d
};
/**
* Chunk header data structure
*/
struct chunk_header_t {
/**
* Track signature data
*/
union {
/**
* ASCII representation
*/
char id_chars[4];
/**
* long integer representation
*/
unsigned long id_number;
};
/**
* Chunk length
*/
unsigned long length;
chunk_header_t()
: id_number(0), length(0) { }
chunk_header_t(const chunk_header_t& s)
: id_number(s.id_number), length(s.length) { };
chunk_header_t& operator=(const chunk_header_t& s) {
id_number=s.id_number; length=s.length;
return *this;
}
/**
* Load chunk header from the stream
* @param s input stream
*/
void load(istream& s);
/**
* Save chunk header to the stream
* @param s output stream
*/
void save(ostream& s) const;
/**
* Dump textual representation of chunk header to stream
* @param s output stream
*/
void dump(ostream& s) const;
};
inline ostream& operator<<(ostream& s,const chunk_header_t& ch) {
ch.dump(s); return s;
}
/**
* Base class for specific chunk containers
*/
class chunk_t {
public:
/**
* Chunk header data
*/
chunk_header_t header;
};
}
#endif /* __MIDILLO_CHUNK_H */
|