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) (unidiff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /include/midillo/event.h
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.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 @@
1#ifndef __MIDILLO_EVENT_H
2#define __MIDILLO_EVENT_H
3
4#include <istream>
5#include <ostream>
6#include <list>
7#include <midillo/message.h>
8
9/**
10 * @file
11 * @brief midi event container
12 */
13
14namespace midillo {
15 using std::istream;
16 using std::ostream;
17 using std::list;
18
19 /**
20 * MIDI event container class
21 */
22 class event_t {
23 public:
24 /**
25 * delta time since the last event
26 */
27 long deltat;
28 /**
29 * MIDI message itself
30 */
31 message_t message;
32
33 /**
34 * Load MIDI event from the stream
35 * @param rs reference to the running status
36 * @param s input stream
37 */
38 void load(int& rs,istream& s);
39
40 /**
41 * Save MIDI event to the stream
42 * @param rs reference to the running status
43 * @param s output stream
44 */
45 void save(int& rs,ostream& s) const;
46
47 /**
48 * Calculate the amount of data that would be written to stream in
49 * case of save
50 * @param rs reference to the running status
51 * @return the number of bytes
52 */
53 unsigned long calculate_save_size(int& rs) const;
54
55 /**
56 * Dump textual representation of event to stream
57 * @param s output stream
58 */
59 void dump(ostream& s) const;
60 };
61
62 inline ostream& operator<<(ostream& s,const event_t& e) {
63 e.dump(s); return s;
64 }
65
66 /**
67 * MIDI events list container
68 */
69 class events_t : public list<event_t> {
70 public:
71
72 /**
73 * Append empty event to the end of the list
74 * @return iterator, pointing to the appended event
75 */
76 iterator append_event();
77
78 /**
79 * Load MIDI events (track data) from the stream
80 * @param s input stream
81 */
82 void load(istream& s);
83 /**
84 * Save MIDI events (track data) to the stream
85 * @param s output stream
86 */
87 void save(ostream& s) const;
88
89 /**
90 * Calculate the size of the track data that would be written to
91 * the stream by save()
92 * @return the number of bytes
93 */
94 unsigned long calculate_save_size() const;
95 };
96
97}
98
99#endif /* __MIDILLO_EVENT_H */