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 'include/midillo/chunk.h') 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 +#include + +/** + * @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 */ -- cgit v0.9.0.2