summaryrefslogtreecommitdiffabout
path: root/include/midillo/SMF.h
Unidiff
Diffstat (limited to 'include/midillo/SMF.h') (more/less context) (show whitespace changes)
-rw-r--r--include/midillo/SMF.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/include/midillo/SMF.h b/include/midillo/SMF.h
new file mode 100644
index 0000000..bec9f7a
--- a/dev/null
+++ b/include/midillo/SMF.h
@@ -0,0 +1,87 @@
1#ifndef __MIDILLO_SMF_H
2#define __MIDILLO_SMF_H
3
4#include <istream>
5#include <ostream>
6#include <list>
7#include <midillo/MThd.h>
8#include <midillo/MTrk.h>
9
10/**
11 * @file
12 * @brief the SMF_t -- standard midi file
13 */
14
15namespace midillo {
16 using std::istream;
17 using std::vector;
18 using std::ostream;
19
20 /**
21 * Standard midi file object
22 */
23 class SMF_t {
24 public:
25 /**
26 * MThd header chunk
27 */
28 MThd_t mthd;
29 /**
30 * The type for collection of MTrk track chunks
31 */
32 typedef list<MTrk_t> tracks_t;
33 /**
34 * MTrk track chunks collection for the file
35 */
36 tracks_t tracks;
37
38 SMF_t() { }
39 /**
40 * Construct object from the file
41 * @see load(const char *f,bool stdinable)
42 */
43 SMF_t(const char *f,bool stdinable=true) { load(f,stdinable); }
44 /**
45 * Construct object from the stream
46 * @see load(istream& s)
47 */
48 SMF_t(istream& s) { load(s); }
49
50 /**
51 * Load MIDI data from the file
52 * @param f filename
53 * @param stdinable true if '-' is treatead as cin input stream
54 */
55 void load(const char *f,bool stdinable=true);
56 /**
57 * Load midi data from the stream
58 * @param s input stream
59 */
60 void load(istream& s);
61
62 /**
63 * Save MIDI data to the file
64 * @param f filename
65 * @param stdoutable true if '-' is treated as cout output stream
66 */
67 void save(const char *f,bool stdoutable=true) const;
68 /**
69 * Save MIDI data to the stream
70 * @param s output stream
71 */
72 void save(ostream& s) const;
73
74 /**
75 * Dump textual representation of SMF to stream
76 * @param s output stream
77 */
78 void dump(ostream& s) const;
79 };
80
81 inline ostream& operator<<(ostream& s,const SMF_t& smf) {
82 smf.dump(s); return s;
83 }
84
85}
86
87#endif /* __MIDILLO_SMF_H */