summaryrefslogtreecommitdiffabout
path: root/include/midillo/chunk.h
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) (side-by-side diff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /include/midillo/chunk.h
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'include/midillo/chunk.h') (more/less context) (show whitespace changes)
-rw-r--r--include/midillo/chunk.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/include/midillo/chunk.h b/include/midillo/chunk.h
new file mode 100644
index 0000000..8b6c034
--- a/dev/null
+++ b/include/midillo/chunk.h
@@ -0,0 +1,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 */