mirror of
https://github.com/thestk/stk
synced 2026-01-12 04:21:52 +00:00
277 lines
14 KiB
HTML
277 lines
14 KiB
HTML
<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"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
|
|
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
|
<HR>
|
|
<!-- Generated by Doxygen 1.3.4 -->
|
|
<h1>MidiFileIn Class Reference</h1><code>#include <<a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a>></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><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>.<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 class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a0">MidiFileIn</a> (std::string fileName)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. </em> <a href="#a0"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a1" doxytag="MidiFileIn::~MidiFileIn" ></a>
|
|
</td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a1">~MidiFileIn</a> ()</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Class destructor. <br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a2" doxytag="MidiFileIn::getFileFormat" ></a>
|
|
int </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a2">getFileFormat</a> () const </td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the MIDI file format (0, 1, or 2). <br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a3" doxytag="MidiFileIn::getNumberOfTracks" ></a>
|
|
unsigned int </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a3">getNumberOfTracks</a> () const </td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the number of tracks in the MIDI file. <br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a4">getDivision</a> () const </td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the MIDI file division value from the file header. </em> <a href="#a4"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a5">rewindTrack</a> (unsigned int track=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Move the specified track event reader to the beginning of its track. </em> <a href="#a5"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>double </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a6">getTickSeconds</a> (unsigned int track=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the current value, in seconds, of delta-time ticks for the specified track. </em> <a href="#a6"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned long </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a7">getNextEvent</a> (std::vector< unsigned char > *event, unsigned int track=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">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><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned long </td><td class="memItemRight" valign=bottom><a class="el" href="classMidiFileIn.html#a8">getNextMidiEvent</a> (std::vector< unsigned char > *midiEvent, unsigned int track=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">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><br><br></td></tr>
|
|
</table>
|
|
<hr><h2>Constructor & Destructor Documentation</h2>
|
|
<a class="anchor" name="a0" doxytag="MidiFileIn::MidiFileIn" ></a><p>
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> MidiFileIn::MidiFileIn </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">std::string </td>
|
|
<td class="mdname1" valign="top" nowrap> <em>fileName</em> </td>
|
|
<td class="md" valign="top"> ) </td>
|
|
<td class="md" nowrap></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</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. </td>
|
|
</tr>
|
|
</table>
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<a class="anchor" name="a4" doxytag="MidiFileIn::getDivision" ></a><p>
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> int MidiFileIn::getDivision </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="mdname1" valign="top" nowrap> </td>
|
|
<td class="md" valign="top"> ) </td>
|
|
<td class="md" nowrap> const</td>
|
|
</tr>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</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. </td>
|
|
</tr>
|
|
</table>
|
|
<a class="anchor" name="a5" doxytag="MidiFileIn::rewindTrack" ></a><p>
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> void MidiFileIn::rewindTrack </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">unsigned int </td>
|
|
<td class="mdname1" valign="top" nowrap> <em>track</em> = 0 </td>
|
|
<td class="md" valign="top"> ) </td>
|
|
<td class="md" nowrap></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</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. </td>
|
|
</tr>
|
|
</table>
|
|
<a class="anchor" name="a6" doxytag="MidiFileIn::getTickSeconds" ></a><p>
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> double MidiFileIn::getTickSeconds </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">unsigned int </td>
|
|
<td class="mdname1" valign="top" nowrap> <em>track</em> = 0 </td>
|
|
<td class="md" valign="top"> ) </td>
|
|
<td class="md" nowrap></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</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. </td>
|
|
</tr>
|
|
</table>
|
|
<a class="anchor" name="a7" doxytag="MidiFileIn::getNextEvent" ></a><p>
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> unsigned long MidiFileIn::getNextEvent </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">std::vector< unsigned char > * </td>
|
|
<td class="mdname" nowrap> <em>event</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="md" nowrap>unsigned int </td>
|
|
<td class="mdname" nowrap> <em>track</em> = 0</td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td class="md">) </td>
|
|
<td class="md" colspan="2"></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</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. </td>
|
|
</tr>
|
|
</table>
|
|
<a class="anchor" name="a8" doxytag="MidiFileIn::getNextMidiEvent" ></a><p>
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> unsigned long MidiFileIn::getNextMidiEvent </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">std::vector< unsigned char > * </td>
|
|
<td class="mdname" nowrap> <em>midiEvent</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="md" nowrap>unsigned int </td>
|
|
<td class="mdname" nowrap> <em>track</em> = 0</td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td class="md">) </td>
|
|
<td class="md" colspan="2"></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</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. </td>
|
|
</tr>
|
|
</table>
|
|
<hr>The documentation for this class was generated from the following file:<ul>
|
|
<li><a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a></ul>
|
|
<HR>
|
|
|
|
<table>
|
|
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
|
<tr><td>©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|