summaryrefslogtreecommitdiff
path: root/doxygen/html/classMidiFileIn.html
blob: e03bb485cefda56763d763a0ad52dc5b1fa3d13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<HTML>
<HEAD>
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<img src="princeton.gif"> &nbsp; <img src="ccrma.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="links.html">Links</a> &nbsp; <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.3-rc3 -->
<h1>MidiFileIn Class Reference</h1>A standard MIDI file reading/parsing class. 
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a>&gt;</code>
<p>
<p>Inheritance diagram for MidiFileIn:
<p><center><img src="classMidiFileIn.png" usemap="#MidiFileIn_map" border="0" alt=""></center>
<map name="MidiFileIn_map">
<area href="classStk.html" alt="Stk" shape="rect" coords="0,0,67,24">
</map>
<a href="classMidiFileIn-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a0">MidiFileIn</a> (std::string fileName)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Default constructor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top><a name="a1" doxytag="MidiFileIn::~MidiFileIn"></a>
&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a1">~MidiFileIn</a> ()</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Class destructor.</em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top><a name="a2" doxytag="MidiFileIn::getFileFormat"></a>
int&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a2">getFileFormat</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Return the MIDI file format (0, 1, or 2).</em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top><a name="a3" doxytag="MidiFileIn::getNumberOfTracks"></a>
unsigned int&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a3">getNumberOfTracks</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Return the number of tracks in the MIDI file.</em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a4">getDivision</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Return the MIDI file division value from the file header.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a5">rewindTrack</a> (unsigned int track=0)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Move the specified track event reader to the beginning of its track.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>double&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a6">getTickSeconds</a> (unsigned int track=0)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Get the current value, in seconds, of delta-time ticks for the specified track.</em> <a href="#a6"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>unsigned long&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a7">getNextEvent</a> (std::vector&lt; unsigned char &gt; *event, unsigned int track=0)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks.</em> <a href="#a7"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>unsigned long&nbsp;</td><td valign=bottom><a class="el" href="classMidiFileIn.html#a8">getNextMidiEvent</a> (std::vector&lt; unsigned char &gt; *midiEvent, unsigned int track=0)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks.</em> <a href="#a8"></a><em></em></font><br><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A standard MIDI file reading/parsing class.
<p>
This class can be used to read events from a standard MIDI file. Event bytes are copied to a C++ vector and must be subsequently interpreted by the user. The function <a class="el" href="classMidiFileIn.html#a8">getNextMidiEvent()</a> skips meta and sysex events, returning only MIDI channel messages. Event delta-times are returned in the form of "ticks" and a function is provided to determine the current "seconds per tick". Tempo changes are internally tracked by the class and reflected in the values returned by the function <a class="el" href="classMidiFileIn.html#a6">getTickSeconds()</a>.<p>
by Gary P. Scavone, 2003. 
<p>

<p>
Definition at line <a class="el" href="MidiFileIn_8h-source.html#l00027">27</a> of file <a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a name="a0" doxytag="MidiFileIn::MidiFileIn"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> MidiFileIn::MidiFileIn </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">std::string&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>&nbsp; <em>fileName</em>          </td>
          <td class="md" valign="top">)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Default constructor.
<p>
If an error occurs while opening or parsing the file header, an <a class="el" href="classStkError.html">StkError</a> exception will be thrown. 
<p>
Definition at line <a class="el" href="MidiFileIn_8cpp-source.html#l00021">21</a> of file <a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a>.
<p>
References <a class="el" href="MidiFileIn_8cpp-source.html#l00186">getNextEvent()</a>, <a class="el" href="Stk_8cpp-source.html#l00104">Stk::handleError()</a>, and <a class="el" href="MidiFileIn_8cpp-source.html#l00163">rewindTrack()</a>.    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="a4" doxytag="MidiFileIn::getDivision"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int MidiFileIn::getDivision </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
          <td class="md" valign="top">)&nbsp;</td>
          <td class="md" nowrap> const</td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Return the MIDI file division value from the file header.
<p>
Note that this value must be "parsed" in accordance with the MIDI File Specification. In particular, if the MSB is set, the file uses time-code representations for delta-time values. 
<p>
Definition at line <a class="el" href="MidiFileIn_8cpp-source.html#l00158">158</a> of file <a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a>.    </td>
  </tr>
</table>
<a name="a5" doxytag="MidiFileIn::rewindTrack"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void MidiFileIn::rewindTrack </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">unsigned int&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>&nbsp; <em>track</em> = 0          </td>
          <td class="md" valign="top">)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Move the specified track event reader to the beginning of its track.
<p>
The relevant track tempo value is reset as well. If an invalid track number is specified, an <a class="el" href="classStkError.html">StkError</a> exception will be thrown. 
<p>
Definition at line <a class="el" href="MidiFileIn_8cpp-source.html#l00163">163</a> of file <a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a>.
<p>
References <a class="el" href="Stk_8cpp-source.html#l00104">Stk::handleError()</a>.
<p>
Referenced by <a class="el" href="MidiFileIn_8cpp-source.html#l00021">MidiFileIn()</a>.    </td>
  </tr>
</table>
<a name="a6" doxytag="MidiFileIn::getTickSeconds"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> double MidiFileIn::getTickSeconds </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">unsigned int&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>&nbsp; <em>track</em> = 0          </td>
          <td class="md" valign="top">)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get the current value, in seconds, of delta-time ticks for the specified track.
<p>
This value can change as events are read (via "Set Tempo" Meta-Events). Therefore, one should call this function after every call to <a class="el" href="classMidiFileIn.html#a7">getNextEvent()</a> or <a class="el" href="classMidiFileIn.html#a8">getNextMidiEvent()</a>. If an invalid track number is specified, an <a class="el" href="classStkError.html">StkError</a> exception will be thrown. 
<p>
Definition at line <a class="el" href="MidiFileIn_8cpp-source.html#l00175">175</a> of file <a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a>.
<p>
References <a class="el" href="Stk_8cpp-source.html#l00104">Stk::handleError()</a>.    </td>
  </tr>
</table>
<a name="a7" doxytag="MidiFileIn::getNextEvent"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> unsigned long MidiFileIn::getNextEvent </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">std::vector&lt; unsigned char &gt; *&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>event</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>unsigned int&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>track</em> = 0</td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks.
<p>
MIDI File events consist of a delta time and a sequence of event bytes. This function returns the delta-time value and writes the subsequent event bytes directly to the event vector. The user must parse the event bytes in accordance with the MIDI File Specification. All returned MIDI channel events are complete ... a status byte is provided even when running status is used in the file. If the track has reached its end, no bytes will be written and the event vector size will be zero. If an invalid track number is specified or an error occurs while reading the file, an <a class="el" href="classStkError.html">StkError</a> exception will be thrown. 
<p>
Definition at line <a class="el" href="MidiFileIn_8cpp-source.html#l00186">186</a> of file <a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a>.
<p>
References <a class="el" href="Stk_8cpp-source.html#l00104">Stk::handleError()</a>.
<p>
Referenced by <a class="el" href="MidiFileIn_8cpp-source.html#l00301">getNextMidiEvent()</a>, and <a class="el" href="MidiFileIn_8cpp-source.html#l00021">MidiFileIn()</a>.    </td>
  </tr>
</table>
<a name="a8" doxytag="MidiFileIn::getNextMidiEvent"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> unsigned long MidiFileIn::getNextMidiEvent </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">std::vector&lt; unsigned char &gt; *&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>midiEvent</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>unsigned int&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>track</em> = 0</td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks.
<p>
All returned MIDI events are complete ... a status byte is provided even when running status is used in the file. Meta and sysex events in the track are skipped though "Set Tempo" events are properly parsed for use by the <a class="el" href="classMidiFileIn.html#a6">getTickSeconds()</a> function. If the track has reached its end, no bytes will be written and the event vector size will be zero. If an invalid track number is specified or an error occurs while reading the file, an <a class="el" href="classStkError.html">StkError</a> exception will be thrown. 
<p>
Definition at line <a class="el" href="MidiFileIn_8cpp-source.html#l00301">301</a> of file <a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a>.
<p>
References <a class="el" href="MidiFileIn_8cpp-source.html#l00186">getNextEvent()</a>, and <a class="el" href="Stk_8cpp-source.html#l00104">Stk::handleError()</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a><li><a class="el" href="MidiFileIn_8cpp-source.html">MidiFileIn.cpp</a></ul>
<HR>

<table>
  <tr><td><A HREF="http://www-ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
  <tr><td>&copy;1995-2002 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>

</BODY>
</HTML>