/usr/share/doc/libtse3-dev/Examples.html is in libtse3-dev 0.3.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <html>
<head>
<title>TSE3 code examples</title>
</head>
<body bgcolor=#ffffff text=#000000>
<table width=100% cellspacing=0 cellpadding=1 border=0 bgcolor=#000000><tr><td>
<table width=100% cellspacing=0 cellpadding=1 border=0><tr><td valign=center bgcolor=#c8d559>
<table width=100% cellspacing=0 cellpadding=0 border=0><tr>
<td align=left width=30%><b> TSE3 documentation<b></td>
<td align=center width=30%>Version 0.3.1</td>
<td align=right width=30%>
<a href="index.html"><b>Index</b></a>
<a href="api/index.html">API</a>
<a href="Version.html">Version</a>
<a href="Structure.html">Structure</a>
</td>
</tr></table>
</td></tr></table>
</td></tr></table>
<h1>TSE3 code examples</h1>
<p>
These are a few simple examples of using the TSE3 library to show how easy it really is to use. There are some more example programs in the TSE3 source tree, look in <code>tse3/src/examples</code> for more information.
<p>
First, this is how you load a standard MIDI file:
<pre>
void loadAMidiSong(const std::string &filename)
{
TSE3::MidiFileImport mfi(filename);
TSE3::Song *song = mfi.load();
}
</pre>
<p>
The song variable now contains a TSE3 Song class with the contents of this MIDI file. In fact, if you just want to play the MIDI file, and don't want to work on the data in it, you don't even need to convert it to a TSE3 Song - you can just play it directly. The Transport class is used to perform playback:
<pre>
void playAMidiSong(const std::string &filename, TSE3::Transport &transport)
{
TSE3::MidiFileImport mfi(filename);
transport.play(mfi);
while (transport.status() == Playing)
{
transport.poll();
// Delay for a bit here to prevent processor hogging
}
// Playback has now finished
}
</pre>
<p>
Of course, there are more elegant ways of waiting for playback to stop than a clumsy loop, and TSE3 provides them to you. (See the TransportListener class for details).
<p>
Perhaps you want to send the different channels of the MIDI file to different MIDI ports (perhaps one to an external MIDI device, and one to the internal soundcard). We can use the MidiMapper to do this easily. This is how you would set it up (baring in mind the MIDI file will by default play from port 0):
<pre>
void setUpMidiMapper(TSE3::Transport &transport)
{
// Set channel 0 port 0 to go to channel 1, port 2
transport.midiMapper()->setMap(0, 0, 1, 2);
// Set channel 1 port 0 to go to channel 0, port 1
transport.midiMapper()->setMap(1, 0, 0, 1);
}
</pre>
<p>
When you next play the MIDI file, the output will be routed accordingly. Facilities exist to find out what physical port is represented by each number. You can hide the numbers from the user and work with port names, too.
<p>
These are a few very simple examples of using TSE3 - it can do a whole lot more!
<body bgcolor=#ffffff text=#000000>
<table width=100% cellspacing=0 cellpadding=1 border=0 bgcolor=#000000><tr><td>
<table width=100% cellspacing=0 cellpadding=1 border=0><tr><td valign=center bgcolor=#c8d559>
<table width=100% cellspacing=0 cellpadding=0 border=0><tr>
<td align=left width=30%> © Pete Goodliffe, 2001-2003</td>
<td align=center width=30%><a href="Copyright.html">Copyright</a></td>
<td align=right width=30%><a href="Psalm150.html">Psalm 150</a> </td>
</tr></table>
</td></tr></table>
</td></tr></table>
</body>
</html>
|