summaryrefslogtreecommitdiffabout
path: root/include/midillo/event.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/event.h
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0.0.zip
midillo-0.0.tar.gz
midillo-0.0.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'include/midillo/event.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/midillo/event.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/include/midillo/event.h b/include/midillo/event.h
new file mode 100644
index 0000000..85f6175
--- a/dev/null
+++ b/include/midillo/event.h
@@ -0,0 +1,99 @@
+#ifndef __MIDILLO_EVENT_H
+#define __MIDILLO_EVENT_H
+
+#include <istream>
+#include <ostream>
+#include <list>
+#include <midillo/message.h>
+
+/**
+ * @file
+ * @brief midi event container
+ */
+
+namespace midillo {
+ using std::istream;
+ using std::ostream;
+ using std::list;
+
+ /**
+ * MIDI event container class
+ */
+ class event_t {
+ public:
+ /**
+ * delta time since the last event
+ */
+ long deltat;
+ /**
+ * MIDI message itself
+ */
+ message_t message;
+
+ /**
+ * Load MIDI event from the stream
+ * @param rs reference to the running status
+ * @param s input stream
+ */
+ void load(int& rs,istream& s);
+
+ /**
+ * Save MIDI event to the stream
+ * @param rs reference to the running status
+ * @param s output stream
+ */
+ void save(int& rs,ostream& s) const;
+
+ /**
+ * Calculate the amount of data that would be written to stream in
+ * case of save
+ * @param rs reference to the running status
+ * @return the number of bytes
+ */
+ unsigned long calculate_save_size(int& rs) const;
+
+ /**
+ * Dump textual representation of event to stream
+ * @param s output stream
+ */
+ void dump(ostream& s) const;
+ };
+
+ inline ostream& operator<<(ostream& s,const event_t& e) {
+ e.dump(s); return s;
+ }
+
+ /**
+ * MIDI events list container
+ */
+ class events_t : public list<event_t> {
+ public:
+
+ /**
+ * Append empty event to the end of the list
+ * @return iterator, pointing to the appended event
+ */
+ iterator append_event();
+
+ /**
+ * Load MIDI events (track data) from the stream
+ * @param s input stream
+ */
+ void load(istream& s);
+ /**
+ * Save MIDI events (track data) to the stream
+ * @param s output stream
+ */
+ void save(ostream& s) const;
+
+ /**
+ * Calculate the size of the track data that would be written to
+ * the stream by save()
+ * @return the number of bytes
+ */
+ unsigned long calculate_save_size() const;
+ };
+
+}
+
+#endif /* __MIDILLO_EVENT_H */