midilib 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Credits +5 -0
- data/html/MIDI/ActiveSense.html +171 -0
- data/html/MIDI/ChannelEvent.html +190 -0
- data/html/MIDI/ChannelPressure.html +212 -0
- data/html/MIDI/Clock.html +171 -0
- data/html/MIDI/Continue.html +171 -0
- data/html/MIDI/Controller.html +224 -0
- data/html/MIDI/Event.html +349 -0
- data/html/MIDI/IO/MIDIFile.html +1392 -0
- data/html/MIDI/IO/SeqReader.html +642 -0
- data/html/MIDI/IO/SeqWriter.html +442 -0
- data/html/MIDI/IO.html +91 -0
- data/html/MIDI/KeySig.html +292 -0
- data/html/MIDI/Marker.html +138 -0
- data/html/MIDI/Measure.html +260 -0
- data/html/MIDI/Measures.html +222 -0
- data/html/MIDI/MetaEvent.html +353 -0
- data/html/MIDI/NoteEvent.html +255 -0
- data/html/MIDI/NoteOff.html +188 -0
- data/html/MIDI/NoteOn.html +188 -0
- data/html/MIDI/PitchBend.html +213 -0
- data/html/MIDI/PolyPressure.html +216 -0
- data/html/MIDI/ProgramChange.html +212 -0
- data/html/MIDI/Realtime.html +194 -0
- data/html/MIDI/Sequence.html +641 -0
- data/html/MIDI/SongPointer.html +213 -0
- data/html/MIDI/SongSelect.html +212 -0
- data/html/MIDI/Start.html +171 -0
- data/html/MIDI/Stop.html +171 -0
- data/html/MIDI/SystemCommon.html +138 -0
- data/html/MIDI/SystemExclusive.html +215 -0
- data/html/MIDI/SystemReset.html +171 -0
- data/html/MIDI/Tempo.html +292 -0
- data/html/MIDI/TimeSig.html +286 -0
- data/html/MIDI/Track.html +489 -0
- data/html/MIDI/TuneRequest.html +194 -0
- data/html/MIDI/Utils.html +178 -0
- data/html/MIDI.html +281 -0
- data/html/Object.html +197 -0
- data/html/README_rdoc.html +545 -0
- data/html/TODO_rdoc.html +123 -0
- data/html/created.rid +15 -0
- data/html/css/fonts.css +167 -0
- data/html/css/rdoc.css +639 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +534 -0
- data/html/js/darkfish.js +84 -0
- data/html/js/navigation.js +105 -0
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +110 -0
- data/html/js/search_index.js +1 -0
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +229 -0
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +1258 -0
- data/lib/midilib/info.rb +2 -2
- data/lib/midilib/io/seqreader.rb +18 -5
- data/test/test_io.rb +18 -5
- metadata +85 -1
@@ -0,0 +1,545 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>README - midilib</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="file">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="./index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
<div class="nav-section">
|
58
|
+
<h3>Table of Contents</h3>
|
59
|
+
|
60
|
+
<ul class="link-list" role="directory">
|
61
|
+
<li><a href="#label-midilib">midilib</a>
|
62
|
+
<li><a href="#label-Dependencies">Dependencies</a>
|
63
|
+
<li><a href="#label-Installation">Installation</a>
|
64
|
+
<li><a href="#label-RubyGems+Installation">RubyGems Installation</a>
|
65
|
+
<li><a href="#label-Manual+Installation">Manual Installation</a>
|
66
|
+
<li><a href="#label-Testing">Testing</a>
|
67
|
+
<li><a href="#label-Overview">Overview</a>
|
68
|
+
<li><a href="#label-MIDI-3A-3ASequence">MIDI::Sequence</a>
|
69
|
+
<li><a href="#label-MIDI-3A-3ATrack">MIDI::Track</a>
|
70
|
+
<li><a href="#label-MIDI-3A-3AMeasure">MIDI::Measure</a>
|
71
|
+
<li><a href="#label-MIDI-3A-3AMeasures">MIDI::Measures</a>
|
72
|
+
<li><a href="#label-MIDI-3A-3AEvent">MIDI::Event</a>
|
73
|
+
<li><a href="#label-How+To+Use">How To Use</a>
|
74
|
+
<li><a href="#label-Reading+a+MIDI+File">Reading a MIDI File</a>
|
75
|
+
<li><a href="#label-Writing+a+MIDI+File">Writing a MIDI File</a>
|
76
|
+
<li><a href="#label-Editing+a+MIDI+File">Editing a MIDI File</a>
|
77
|
+
<li><a href="#label-Transposing+One+Channel">Transposing One Channel</a>
|
78
|
+
<li><a href="#label-Manipulating+tracks">Manipulating tracks</a>
|
79
|
+
<li><a href="#label-Calculating+delta+times">Calculating delta times</a>
|
80
|
+
<li><a href="#label-Example+Scripts">Example Scripts</a>
|
81
|
+
<li><a href="#label-Resources">Resources</a>
|
82
|
+
<li><a href="#label-To+Do">To Do</a>
|
83
|
+
<li><a href="#label-Bugs">Bugs</a>
|
84
|
+
<li><a href="#label-Features">Features</a>
|
85
|
+
<li><a href="#label-Documentation">Documentation</a>
|
86
|
+
<li><a href="#label-Tests">Tests</a>
|
87
|
+
<li><a href="#label-Support">Support</a>
|
88
|
+
<li><a href="#label-Administrivia">Administrivia</a>
|
89
|
+
<li><a href="#label-Copying">Copying</a>
|
90
|
+
<li><a href="#label-Recent+Changes">Recent Changes</a>
|
91
|
+
<li><a href="#label-Changes+for+2.0.5-3A">Changes for 2.0.5:</a>
|
92
|
+
<li><a href="#label-Changes+for+2.0.3-3A">Changes for 2.0.3:</a>
|
93
|
+
<li><a href="#label-Changes+for+2.0.2-3A">Changes for 2.0.2:</a>
|
94
|
+
<li><a href="#label-Changes+for+2.0.0-3A">Changes for 2.0.0:</a>
|
95
|
+
<li><a href="#label-Changes+for+1.2.0-3A">Changes for 1.2.0:</a>
|
96
|
+
<li><a href="#label-New+code+repository">New code repository</a>
|
97
|
+
<li><a href="#label-Changes+for+1.1.4-3A">Changes for 1.1.4:</a>
|
98
|
+
<li><a href="#label-Changes+for+1.1.3-3A">Changes for 1.1.3:</a>
|
99
|
+
<li><a href="#label-Changes+for+1.1.2-3A">Changes for 1.1.2:</a>
|
100
|
+
<li><a href="#label-Changes+for+1.1.1-3A">Changes for 1.1.1:</a>
|
101
|
+
<li><a href="#label-Changes+for+1.1.0-3A">Changes for 1.1.0:</a>
|
102
|
+
<li><a href="#label-Changes+for+1.0.0-3A">Changes for 1.0.0:</a>
|
103
|
+
<li><a href="#label-Changes+for+0.8.7-3A">Changes for 0.8.7:</a>
|
104
|
+
<li><a href="#label-Changes+for+0.8.6-3A">Changes for 0.8.6:</a>
|
105
|
+
<li><a href="#label-Changes+for+0.8.5-3A">Changes for 0.8.5:</a>
|
106
|
+
<li><a href="#label-Changes+for+0.8.4-3A">Changes for 0.8.4:</a>
|
107
|
+
<li><a href="#label-Changes+for+0.8.3-3A">Changes for 0.8.3:</a>
|
108
|
+
<li><a href="#label-Changes+for+0.8.2-3A">Changes for 0.8.2:</a>
|
109
|
+
<li><a href="#label-Changes+for+0.8.1-3A">Changes for 0.8.1:</a>
|
110
|
+
<li><a href="#label-Warranty">Warranty</a>
|
111
|
+
</ul>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
|
115
|
+
<div id="project-metadata">
|
116
|
+
|
117
|
+
<div id="fileindex-section" class="nav-section">
|
118
|
+
<h3>Pages</h3>
|
119
|
+
|
120
|
+
<ul class="link-list">
|
121
|
+
<li><a href="./README_rdoc.html">README</a>
|
122
|
+
<li><a href="./TODO_rdoc.html">TODO</a>
|
123
|
+
</ul>
|
124
|
+
</div>
|
125
|
+
|
126
|
+
</div>
|
127
|
+
</nav>
|
128
|
+
|
129
|
+
<main role="main" aria-label="Page README.rdoc">
|
130
|
+
|
131
|
+
<h1 id="label-midilib">midilib<span><a href="#label-midilib">¶</a> <a href="#top">↑</a></span></h1>
|
132
|
+
|
133
|
+
<p>midilib is a pure Ruby <a href="MIDI.html"><code>MIDI</code></a> library useful for reading and writing standard <a href="MIDI.html"><code>MIDI</code></a> files and manipulating <a href="MIDI.html"><code>MIDI</code></a> event data.</p>
|
134
|
+
|
135
|
+
<p>The GitHub project page and Web site of midilib is <a href="http://github.com/jimm/midilib">github.com/jimm/midilib</a> and the RubyGems.org page is <a href="http://rubygems.org/gems/midilib">rubygems.org/gems/midilib</a>, where you can also find all the RDoc documentation.</p>
|
136
|
+
|
137
|
+
<p>midilib is compatible with Ruby 2.6 and higher.</p>
|
138
|
+
|
139
|
+
<h2 id="label-Dependencies">Dependencies<span><a href="#label-Dependencies">¶</a> <a href="#top">↑</a></span></h2>
|
140
|
+
|
141
|
+
<p>midilib does not require any other packages. The test suite in the tests directory requires the testing framework TestUnit, which comes with Ruby 1.8 and later and can also be found in the Ruby Application Archive (<a href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>).</p>
|
142
|
+
|
143
|
+
<p>To rebuild the gem or RDocs or run the tests easily, you can use the Rakefile which requires Rake (<a href="http://rake.rubyforge.org">rake.rubyforge.org</a>).</p>
|
144
|
+
|
145
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
146
|
+
|
147
|
+
<h3 id="label-RubyGems+Installation">RubyGems Installation<span><a href="#label-RubyGems+Installation">¶</a> <a href="#top">↑</a></span></h3>
|
148
|
+
|
149
|
+
<p>To install midilib as a gem, type</p>
|
150
|
+
|
151
|
+
<pre>% gem install midilib</pre>
|
152
|
+
|
153
|
+
<p>or, if you already have a previous version, use</p>
|
154
|
+
|
155
|
+
<pre>% gem update midilib</pre>
|
156
|
+
|
157
|
+
<p>You may need root privileges to install or update the gem.</p>
|
158
|
+
|
159
|
+
<h3 id="label-Manual+Installation">Manual Installation<span><a href="#label-Manual+Installation">¶</a> <a href="#top">↑</a></span></h3>
|
160
|
+
|
161
|
+
<p>After downloading and expanding the archive, you can install midilib with the command</p>
|
162
|
+
|
163
|
+
<pre>% ruby install.rb</pre>
|
164
|
+
|
165
|
+
<p>(or)</p>
|
166
|
+
|
167
|
+
<pre>% ruby install.rb --install-dir=my_directory</pre>
|
168
|
+
|
169
|
+
<p>You may need root privileges to install.</p>
|
170
|
+
|
171
|
+
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
172
|
+
|
173
|
+
<pre>% rake test</pre>
|
174
|
+
|
175
|
+
<p>runs all of the tests in the test directory.</p>
|
176
|
+
|
177
|
+
<h2 id="label-Overview">Overview<span><a href="#label-Overview">¶</a> <a href="#top">↑</a></span></h2>
|
178
|
+
|
179
|
+
<p>midilib can read and write <a href="MIDI.html"><code>MIDI</code></a> file formats 0 (one single track) or 1 multiple tracks. By default, it writes format 1 which is the most common format. <a href="MIDI.html"><code>MIDI</code></a> file format 2 is not yet supported.</p>
|
180
|
+
|
181
|
+
<h3 id="label-MIDI-3A-3ASequence"><a href="MIDI/Sequence.html"><code>MIDI::Sequence</code></a><span><a href="#label-MIDI-3A-3ASequence">¶</a> <a href="#top">↑</a></span></h3>
|
182
|
+
|
183
|
+
<p>A sequence contains a collection of tracks and global information like the sequence’s pulses per quarter note (ppqn) and time signature.</p>
|
184
|
+
|
185
|
+
<p>The first track in a sequence is special; it holds meta-events like tempo and sequence name. Don’t put any notes in this track.</p>
|
186
|
+
|
187
|
+
<p><a href="MIDI/Sequence.html"><code>MIDI::Sequence</code></a> also contains some convenience methods that let you set and retrieve the sequence’s name, the time signature, and to retrieve the first tempo event’s beats-per-minute value.</p>
|
188
|
+
|
189
|
+
<p>Normally instances of <a href="MIDI/IO/SeqReader.html"><code>MIDI::IO::SeqReader</code></a> and <a href="MIDI/IO/SeqWriter.html"><code>MIDI::IO::SeqWriter</code></a> are used when a sequence reads itself from or writes itself to a <a href="MIDI.html"><code>MIDI</code></a> file. You can change that by setting a sequence’s reader_class or writer_class attributes. Instances of the classes contained in those attributes are created and used whenever the sequence reads or writes itself.</p>
|
190
|
+
|
191
|
+
<h3 id="label-MIDI-3A-3ATrack"><a href="MIDI/Track.html"><code>MIDI::Track</code></a><span><a href="#label-MIDI-3A-3ATrack">¶</a> <a href="#top">↑</a></span></h3>
|
192
|
+
|
193
|
+
<p>A track contains an array of events.</p>
|
194
|
+
|
195
|
+
<p>When you modify the <code>events</code> array, make sure to call recalc_times so each event gets its <code>time_from_start</code> recalculated. You don’t have to do that after every event you add; just remember to do so before using the track in a way that expects the list of events to be ordered correctly.</p>
|
196
|
+
|
197
|
+
<p>A Track also holds a bit mask that specifies the channels used by the track. This bit mask is set when the track is read from the <a href="MIDI.html"><code>MIDI</code></a> file by a SeqReader but is <em>not</em> kept up to date by any other methods. Specifically, if you add events to a track at any other time, the bit mask will not be updated.</p>
|
198
|
+
|
199
|
+
<h3 id="label-MIDI-3A-3AMeasure"><a href="MIDI/Measure.html"><code>MIDI::Measure</code></a><span><a href="#label-MIDI-3A-3AMeasure">¶</a> <a href="#top">↑</a></span></h3>
|
200
|
+
|
201
|
+
<p>This class contains information about a measure from the sequence. Measure data is based on the time signature information from the sequence and is not stored in the sequence itself.</p>
|
202
|
+
|
203
|
+
<h3 id="label-MIDI-3A-3AMeasures"><a href="MIDI/Measures.html"><code>MIDI::Measures</code></a><span><a href="#label-MIDI-3A-3AMeasures">¶</a> <a href="#top">↑</a></span></h3>
|
204
|
+
|
205
|
+
<p>The class <a href="MIDI/Sequence.html"><code>MIDI::Sequence</code></a> method get_measures returns a <a href="MIDI/Measures.html"><code>MIDI::Measures</code></a> object. <a href="MIDI/Measures.html"><code>MIDI::Measures</code></a> is a subclass of Array. It is a specialized container for <a href="MIDI/Measure.html"><code>MIDI::Measure</code></a> objects, which can be use to map event times to measure numbers. Please note that this object has to be remade when events are deleted/added in the sequence.</p>
|
206
|
+
|
207
|
+
<p><a href="MIDI/Measure.html"><code>MIDI::Measure</code></a> and <a href="MIDI/Measures.html"><code>MIDI::Measures</code></a> are brought to us by Jari Williamsson <jari.williamsson@mailbox.swipnet.se>, who also contributed some improvements to the <a href="MIDI/Event.html"><code>MIDI::Event</code></a> and <a href="MIDI/Track.html"><code>MIDI::Track</code></a> classes.</p>
|
208
|
+
|
209
|
+
<h3 id="label-MIDI-3A-3AEvent"><a href="MIDI/Event.html"><code>MIDI::Event</code></a><span><a href="#label-MIDI-3A-3AEvent">¶</a> <a href="#top">↑</a></span></h3>
|
210
|
+
|
211
|
+
<p>Each event holds not only its delta time but also its time from the start of the track. The track is responsible for recalculating its events’ start times. You can call <a href="MIDI/Track.html#method-i-recalc_times"><code>MIDI::Track#recalc_times</code></a> to do so.</p>
|
212
|
+
|
213
|
+
<p>Subclasses of <a href="MIDI/Event.html"><code>MIDI::Event</code></a> implement the various <a href="MIDI.html"><code>MIDI</code></a> messages such as note on and off, controller values, system exclusive data, and realtime bytes.</p>
|
214
|
+
|
215
|
+
<p><a href="MIDI/Realtime.html"><code>MIDI::Realtime</code></a> events have delta values and start times, just like all the other midilib event types do. (<a href="MIDI.html"><code>MIDI</code></a> real time status bytes don’t have delta times, but this way we can record when in a track the realtime byte was received and should be sent. This is useful for start/continue/stop events that control other devices, for example.) Note that when a <a href="MIDI/Realtime.html"><code>MIDI::Realtime</code></a> event is written out to a <a href="MIDI.html"><code>MIDI</code></a> file, the delta time is not written.</p>
|
216
|
+
|
217
|
+
<p><a href="MIDI/MetaEvent.html"><code>MIDI::MetaEvent</code></a> events hold an array of bytes named ‘data’. Many meta events are string holders (text, lyric, marker, etc.) Though the ‘data’ value is always an array of bytes, <a href="MIDI/MetaEvent.html"><code>MIDI::MetaEvent</code></a> helps with saving and accessing string. The <a href="MIDI/MetaEvent.html#method-i-data_as_str"><code>MIDI::MetaEvent#data_as_str</code></a> method returns the data bytes as a string. When assigning to a meta event’s data, if you pass in a string it will get converted to an array of bytes.</p>
|
218
|
+
|
219
|
+
<h2 id="label-How+To+Use">How To Use<span><a href="#label-How+To+Use">¶</a> <a href="#top">↑</a></span></h2>
|
220
|
+
|
221
|
+
<p>The following examples show you how to use midilib to read, write, and manipulate <a href="MIDI.html"><code>MIDI</code></a> files and modify track events. See also the files in the examples directory, which are described below.</p>
|
222
|
+
|
223
|
+
<h3 id="label-Reading+a+MIDI+File">Reading a <a href="MIDI.html"><code>MIDI</code></a> File<span><a href="#label-Reading+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
224
|
+
|
225
|
+
<p>To read a <a href="MIDI.html"><code>MIDI</code></a> file, create a <a href="MIDI/Sequence.html"><code>MIDI::Sequence</code></a> object and call its read method, passing in an IO object.</p>
|
226
|
+
|
227
|
+
<p>The read method takes an optional block. If present, the block is called once after each track has finished being read. Each time, it is passed the track object, the total number of tracks and the number of the current track that has just been read. This is useful for notifying the user of progress, for example by updating a GUI progress bar.</p>
|
228
|
+
|
229
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqreader'</span>
|
230
|
+
|
231
|
+
<span class="ruby-comment"># Create a new, empty sequence.</span>
|
232
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>.<span class="ruby-identifier">new</span>()
|
233
|
+
|
234
|
+
<span class="ruby-comment"># Read the contents of a MIDI file into the sequence.</span>
|
235
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_midi_file.mid'</span>, <span class="ruby-string">'rb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
236
|
+
<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">track</span>, <span class="ruby-identifier">num_tracks</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">|</span>
|
237
|
+
<span class="ruby-comment"># Print something when each track is read.</span>
|
238
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"read track #{i} of #{num_tracks}"</span>
|
239
|
+
}
|
240
|
+
}
|
241
|
+
</pre>
|
242
|
+
|
243
|
+
<h3 id="label-Writing+a+MIDI+File">Writing a <a href="MIDI.html"><code>MIDI</code></a> File<span><a href="#label-Writing+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
244
|
+
|
245
|
+
<p>To write a <a href="MIDI.html"><code>MIDI</code></a> file, call the write method, passing in an IO object.</p>
|
246
|
+
|
247
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqwriter'</span>
|
248
|
+
|
249
|
+
<span class="ruby-comment"># Start with a sequence that has something worth saving.</span>
|
250
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">read_or_create_seq_we_care_not_how</span>()
|
251
|
+
|
252
|
+
<span class="ruby-comment"># Write the sequence to a MIDI file.</span>
|
253
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_output_file.mid'</span>, <span class="ruby-string">'wb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">file</span>) }
|
254
|
+
</pre>
|
255
|
+
|
256
|
+
<h3 id="label-Editing+a+MIDI+File">Editing a <a href="MIDI.html"><code>MIDI</code></a> File<span><a href="#label-Editing+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
257
|
+
|
258
|
+
<p>Combining the last two examples, here is a script that reads a <a href="MIDI.html"><code>MIDI</code></a> file, transposes some events, and writes the sequence out to a different file. This is a useful template for programatically manipulating <a href="MIDI.html"><code>MIDI</code></a> data.</p>
|
259
|
+
|
260
|
+
<p>This code transposes all of the note events (note on, note off, and poly pressure) on channel 5 down one octave.</p>
|
261
|
+
|
262
|
+
<h4 id="label-Transposing+One+Channel">Transposing One Channel<span><a href="#label-Transposing+One+Channel">¶</a> <a href="#top">↑</a></span></h4>
|
263
|
+
|
264
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqreader'</span>
|
265
|
+
<span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqwriter'</span>
|
266
|
+
|
267
|
+
<span class="ruby-comment"># Create a new, empty sequence.</span>
|
268
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>.<span class="ruby-identifier">new</span>()
|
269
|
+
|
270
|
+
<span class="ruby-comment"># Read the contents of a MIDI file into the sequence.</span>
|
271
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_input_file.mid'</span>, <span class="ruby-string">'rb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
272
|
+
<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">track</span>, <span class="ruby-identifier">num_tracks</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">|</span>
|
273
|
+
<span class="ruby-comment"># Print something when each track is read.</span>
|
274
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"read track #{i} of #{num_tracks}"</span>
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
<span class="ruby-comment"># Iterate over every event in every track.</span>
|
279
|
+
<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">track</span> <span class="ruby-operator">|</span>
|
280
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">|</span>
|
281
|
+
<span class="ruby-comment"># If the event is a note event (note on, note off, or poly</span>
|
282
|
+
<span class="ruby-comment"># pressure) and it is on MIDI channel 5 (channels start at</span>
|
283
|
+
<span class="ruby-comment"># 0, so we use 4), then transpose the event down one octave.</span>
|
284
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">NoteEvent</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">channel</span> <span class="ruby-operator">==</span> <span class="ruby-value">4</span>
|
285
|
+
<span class="ruby-identifier">event</span>.<span class="ruby-identifier">note</span> <span class="ruby-operator">-=</span> <span class="ruby-value">12</span>
|
286
|
+
<span class="ruby-keyword">end</span>
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
<span class="ruby-comment"># Write the sequence to a MIDI file.</span>
|
291
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_output_file.mid'</span>, <span class="ruby-string">'wb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">file</span>) }
|
292
|
+
</pre>
|
293
|
+
|
294
|
+
<h3 id="label-Manipulating+tracks">Manipulating tracks<span><a href="#label-Manipulating+tracks">¶</a> <a href="#top">↑</a></span></h3>
|
295
|
+
|
296
|
+
<p>If you modify a track’s list of events directly, don’t forget to call <a href="MIDI/Track.html#method-i-recalc_times"><code>MIDI::Track#recalc_times</code></a> when you are done.</p>
|
297
|
+
|
298
|
+
<pre class="ruby"><span class="ruby-identifier">track</span>.<span class="ruby-identifier">events</span>[<span class="ruby-value">42</span>, <span class="ruby-value">1</span>] = <span class="ruby-identifier">array_of_events</span>
|
299
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">events</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">an_event</span>
|
300
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">array_of_events</span>)
|
301
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">recalc_times</span>
|
302
|
+
</pre>
|
303
|
+
|
304
|
+
<h3 id="label-Calculating+delta+times">Calculating delta times<span><a href="#label-Calculating+delta+times">¶</a> <a href="#top">↑</a></span></h3>
|
305
|
+
|
306
|
+
<p>A few methods in <a href="MIDI/Sequence.html"><code>MIDI::Sequence</code></a> make it easier to calculate the delta times that represent note lengths. <a href="MIDI/Sequence.html#method-i-length_to_delta"><code>MIDI::Sequence#length_to_delta</code></a> takes a note length (a multiple of a quarter note) and returns the delta time given the sequence’s current ppqn (pulses per quarter note) setting. 1 is a quarter note, 1.0/32.0 is a 32nd note (use floating-point numbers to avoid integer rounding), 1.5 is a dotted quarter, etc. See the documentation for that method for more information.</p>
|
307
|
+
|
308
|
+
<p><a href="MIDI/Sequence.html#method-i-note_to_length"><code>MIDI::Sequence#note_to_length</code></a> takes a note name and returns a length value (again, as a multiple of a quarter note). Legal note names are those found in MIDI::Sequence::NOTE_TO_LENGTH, and may begin with “dotted” and/or end with “triplet”. For example, “whole”, “sixteenth”, “32nd”, “quarter triplet”, “dotted 16th”, and “dotted 8th triplet” are all legal note names.</p>
|
309
|
+
|
310
|
+
<p>Finally, <a href="MIDI/Sequence.html#method-i-note_to_delta"><code>MIDI::Sequence#note_to_delta</code></a> takes a note name and returns a delta time. It does this by calling note_to_length, then passing the result to length_to_delta.</p>
|
311
|
+
|
312
|
+
<h3 id="label-Example+Scripts">Example Scripts<span><a href="#label-Example+Scripts">¶</a> <a href="#top">↑</a></span></h3>
|
313
|
+
|
314
|
+
<p>Here are short descriptions of each of the examples found in the examples directory.</p>
|
315
|
+
<ul><li>
|
316
|
+
<p>examples/from_scratch.rb shows you how to create a new sequence from scratch and save it to a <a href="MIDI.html"><code>MIDI</code></a> file. It creates a file called ‘from_scratch.mid’.</p>
|
317
|
+
</li><li>
|
318
|
+
<p>examples/seq2text.rb dumps a <a href="MIDI.html"><code>MIDI</code></a> file as text. It reads in a sequence and uses the to_s method of each event.</p>
|
319
|
+
</li><li>
|
320
|
+
<p>examples/reader2text.rb dumps a <a href="MIDI.html"><code>MIDI</code></a> file as text. It subclasses MIDI::SeqReader instead of creating a sequence containing tracks and events.</p>
|
321
|
+
</li><li>
|
322
|
+
<p>examples/transpose.rb transposes all note events (note on, note off, poly pressure) on a specified channel by a specified amount.</p>
|
323
|
+
</li><li>
|
324
|
+
<p>There is also one <a href="MIDI.html"><code>MIDI</code></a> file, examples/NoFences.mid. It is a little pop ditty I wrote. The instruments in this file use General <a href="MIDI.html"><code>MIDI</code></a> patch numbers and drum note assignments. Since I don’t normally use GM patches, the sounds used here are at best approximations of the sounds I use.</p>
|
325
|
+
</li></ul>
|
326
|
+
|
327
|
+
<h2 id="label-Resources">Resources<span><a href="#label-Resources">¶</a> <a href="#top">↑</a></span></h2>
|
328
|
+
|
329
|
+
<p>The Ruby Web site (<a href="http://www.ruby-lang.org/en/index.html">www.ruby-lang.org/en/index.html</a>) contains an introduction to Ruby, the Ruby Application Archive (RAA) at <a href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>, and pointers to more information.</p>
|
330
|
+
|
331
|
+
<p><cite>Programming Ruby, The Pragmatic Programmer’s Guide</cite>, by David Thomas and Andrew Hunt, is a well-written and practical introduction to Ruby. Its Web page at <a href="http://www.rubycentral.com/book">www.rubycentral.com/book</a> also contains a wealth of Ruby information. Though the first edition book is available online, I encourage you to purchase a copy of the latest edition.</p>
|
332
|
+
|
333
|
+
<p>A description of the <a href="MIDI.html"><code>MIDI</code></a> file format can be found in a few places such as <a href="https://www.csie.ntu.edu.tw/~r92092/ref/midi">www.csie.ntu.edu.tw/~r92092/ref/midi</a>/.</p>
|
334
|
+
|
335
|
+
<p>The <a href="MIDI.html"><code>MIDI</code></a> message reference at <a href="http://www.jimmenard.com/midi_ref.html">www.jimmenard.com/midi_ref.html</a> describes the format of <a href="MIDI.html"><code>MIDI</code></a> commands.</p>
|
336
|
+
|
337
|
+
<h1 id="label-To+Do">To Do<span><a href="#label-To+Do">¶</a> <a href="#top">↑</a></span></h1>
|
338
|
+
|
339
|
+
<h2 id="label-Bugs">Bugs<span><a href="#label-Bugs">¶</a> <a href="#top">↑</a></span></h2>
|
340
|
+
|
341
|
+
<p>midilib does not handle tempo changes when calculating <code>beats_per_minute</code>. The tempo events are correctly handled when reading/writing/moving them around, it’s just the functions that answer questions about the current tempo that are wrong. See <a href="https://github.com/jimm/midilib/issues/8">github.com/jimm/midilib/issues/8</a>. The method <code>beats_per_minute</code> and related methods like <code>pulses_to_seconds</code> will have to take into account the possibility of more than one tempo event. They will probably have to take new arguments specifying where in the sequence the beats or pulses are being requested. For example we could have +beats_per_minute(at_seconds: 0.0, at_beat: 0.0)+ (where the two keyword args are mutually exclusive). Perhaps there should be separately named public methods like <code>beats_per_minute_at_seconds</code> and <code>beats_per_minute_at_beat</code> as well.</p>
|
342
|
+
|
343
|
+
<h2 id="label-Features">Features<span><a href="#label-Features">¶</a> <a href="#top">↑</a></span></h2>
|
344
|
+
<ul><li>
|
345
|
+
<p><code>print_decimal_numbers</code> and <code>print_channel_numbers_from_one</code> should be associated with sequence, or perhaps track, not event.</p>
|
346
|
+
</li><li>
|
347
|
+
<p>Method to translate event’s time_from_start to number of milliseconds from start.</p>
|
348
|
+
</li><li>
|
349
|
+
<p>Swing quantizing. (Implied by list email from Carl Youngblood <carl.youngblood@gmail.com>)</p>
|
350
|
+
</li><li>
|
351
|
+
<p>Implement key signature in SeqReader.</p>
|
352
|
+
</li><li>
|
353
|
+
<p>Ignore unknown chunks in <a href="MIDI.html"><code>MIDI</code></a> files. See the <a href="MIDI.html"><code>MIDI</code></a> file spec.</p>
|
354
|
+
</li><li>
|
355
|
+
<p>Format 2 files(?).</p>
|
356
|
+
</li></ul>
|
357
|
+
|
358
|
+
<h2 id="label-Documentation">Documentation<span><a href="#label-Documentation">¶</a> <a href="#top">↑</a></span></h2>
|
359
|
+
<ul><li>
|
360
|
+
<p>Write better docs.</p>
|
361
|
+
</li></ul>
|
362
|
+
|
363
|
+
<h2 id="label-Tests">Tests<span><a href="#label-Tests">¶</a> <a href="#top">↑</a></span></h2>
|
364
|
+
<ul><li>
|
365
|
+
<p>Tests for Noah Thorp’s midilib bug fixes.</p>
|
366
|
+
</li></ul>
|
367
|
+
|
368
|
+
<h1 id="label-Support">Support<span><a href="#label-Support">¶</a> <a href="#top">↑</a></span></h1>
|
369
|
+
<ul><li>
|
370
|
+
<p>Visit the forums, bug list, and mailing list pages at <a href="http://rubyforge.org/projects/midilib">rubyforge.org/projects/midilib</a></p>
|
371
|
+
</li><li>
|
372
|
+
<p>Send email to Jim Menard at <a href="mailto:jim@jimmenard.com">jim@jimmenard.com</a></p>
|
373
|
+
</li><li>
|
374
|
+
<p>Ask on the ruby-talk mailing list</p>
|
375
|
+
</li></ul>
|
376
|
+
|
377
|
+
<h1 id="label-Administrivia">Administrivia<span><a href="#label-Administrivia">¶</a> <a href="#top">↑</a></span></h1>
|
378
|
+
<dl class="rdoc-list note-list"><dt>Author
|
379
|
+
<dd>
|
380
|
+
<p>Jim Menard (<a href="mailto:jim@jimmenard.com">jim@jimmenard.com</a>)</p>
|
381
|
+
</dd><dt>Copyright
|
382
|
+
<dd>
|
383
|
+
<p>Copyright © 2003-2013 Jim Menard</p>
|
384
|
+
</dd><dt>License
|
385
|
+
<dd>
|
386
|
+
<p>Distributed under the same license as Ruby.</p>
|
387
|
+
</dd></dl>
|
388
|
+
|
389
|
+
<h2 id="label-Copying">Copying<span><a href="#label-Copying">¶</a> <a href="#top">↑</a></span></h2>
|
390
|
+
|
391
|
+
<p>midilib is copyrighted free software by Jim Menard and is released under the same license as Ruby. See the Ruby license at <a href="http://www.ruby-lang.org/en/LICENSE.txt">www.ruby-lang.org/en/LICENSE.txt</a>.</p>
|
392
|
+
|
393
|
+
<p>midilib may be freely copied in its entirety providing this notice, all source code, all documentation, and all other files are included.</p>
|
394
|
+
|
395
|
+
<p>midilib is Copyright © 2003-2013 by Jim Menard.</p>
|
396
|
+
|
397
|
+
<p>The song “No Fences” contained in the <a href="MIDI.html"><code>MIDI</code></a> file examples/NoFences.mid is Copyright © 1992 by Jim Menard (jim@jimmenard.com). It may be freely used for non-commercial purposes as long as the author is given credit.</p>
|
398
|
+
|
399
|
+
<h2 id="label-Recent+Changes">Recent Changes<span><a href="#label-Recent+Changes">¶</a> <a href="#top">↑</a></span></h2>
|
400
|
+
|
401
|
+
<h3 id="label-Changes+for+2.0.5-3A">Changes for 2.0.5:<span><a href="#label-Changes+for+2.0.5-3A">¶</a> <a href="#top">↑</a></span></h3>
|
402
|
+
|
403
|
+
<p>Updated <code>install.rb</code> to work with newer versions of Ruby by using <code>fileutils</code> instead of <code>ftools</code>.</p>
|
404
|
+
|
405
|
+
<h3 id="label-Changes+for+2.0.3-3A">Changes for 2.0.3:<span><a href="#label-Changes+for+2.0.3-3A">¶</a> <a href="#top">↑</a></span></h3>
|
406
|
+
|
407
|
+
<p>New <a href="MIDI/Sequence.html#method-i-pulses_to_seconds"><code>MIDI::Sequence.pulses_to_seconds</code></a> method.</p>
|
408
|
+
|
409
|
+
<h3 id="label-Changes+for+2.0.2-3A">Changes for 2.0.2:<span><a href="#label-Changes+for+2.0.2-3A">¶</a> <a href="#top">↑</a></span></h3>
|
410
|
+
|
411
|
+
<p>Stop monkeypatching Array in <a href="MIDI/Track.html"><code>MIDI::Track</code></a>.</p>
|
412
|
+
|
413
|
+
<h3 id="label-Changes+for+2.0.0-3A">Changes for 2.0.0:<span><a href="#label-Changes+for+2.0.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
414
|
+
|
415
|
+
<p><a href="MIDI/NoteOn.html"><code>MIDI::NoteOnEvent</code></a> and <a href="MIDI/NoteOff.html"><code>MIDI::NoteOffEvent</code></a> renamed to <a href="MIDI/NoteOn.html"><code>MIDI::NoteOn</code></a> and <a href="MIDI/NoteOff.html"><code>MIDI::NoteOff</code></a>. The old names will still work for a while.</p>
|
416
|
+
|
417
|
+
<p>The <a href="MIDI/Event.html"><code>MIDI::Event</code></a> boolean methods like meta? and note? have been removed. Use the event classes themselves (for example, <a href="MIDI/MetaEvent.html"><code>MIDI::MetaEvent</code></a> === my_event or my_event.kind_of?(<a href="MIDI/MetaEvent.html"><code>MIDI::MetaEvent</code></a>)). Case statements that use classes work, too:</p>
|
418
|
+
|
419
|
+
<pre class="ruby"><span class="ruby-keyword">case</span> <span class="ruby-identifier">my_event</span>
|
420
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">NoteEvent</span> <span class="ruby-comment"># superclass of note on, note off, poly press</span>
|
421
|
+
<span class="ruby-identifier">do_this</span>()
|
422
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Controller</span>
|
423
|
+
<span class="ruby-identifier">do_that</span>()
|
424
|
+
<span class="ruby-keyword">end</span>
|
425
|
+
</pre>
|
426
|
+
|
427
|
+
<p>Introduced Adam Murray’s stable sorting code for <a href="MIDI/Track.html#method-i-recalc_delta_from_times"><code>MIDI::Track#recalc_delta_from_times</code></a>. See <a href="http://wiki.github.com/adamjmurray/cosy/midilib-notes">wiki.github.com/adamjmurray/cosy/midilib-notes</a> and <a href="http://github.com/adamjmurray/cosy/blob/master/lib/cosy/helper/midi_file_renderer_helper.rb">github.com/adamjmurray/cosy/blob/master/lib/cosy/helper/midi_file_renderer_helper.rb</a> for details.</p>
|
428
|
+
|
429
|
+
<p>Aliased <a href="MIDI/Track.html#method-i-sort"><code>MIDI::Track#sort</code></a> to <a href="MIDI/Track.html#method-i-recalc_delta_from_times"><code>MIDI::Track#recalc_delta_from_times</code></a>, since all sort did was sort the events then call recalc_delta_from_times, and recalc_delta_from_times sorts the events before doing anything else.</p>
|
430
|
+
|
431
|
+
<p>MIDI::Tempo#mpq_to_bpm now returns a float.</p>
|
432
|
+
|
433
|
+
<h3 id="label-Changes+for+1.2.0-3A">Changes for 1.2.0:<span><a href="#label-Changes+for+1.2.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
434
|
+
|
435
|
+
<p>Use byte arrays instead of strings for passing around data. All tests now pass for both Ruby 1.8.X and 1.9.X.</p>
|
436
|
+
|
437
|
+
<h3 id="label-New+code+repository">New code repository<span><a href="#label-New+code+repository">¶</a> <a href="#top">↑</a></span></h3>
|
438
|
+
|
439
|
+
<p>The midilib code is now hosted at Github (<a href="http://github.com/jimm/midilib">github.com/jimm/midilib</a>).</p>
|
440
|
+
|
441
|
+
<h3 id="label-Changes+for+1.1.4-3A">Changes for 1.1.4:<span><a href="#label-Changes+for+1.1.4-3A">¶</a> <a href="#top">↑</a></span></h3>
|
442
|
+
<ul><li>
|
443
|
+
<p>Fixed a bug in KeySig.data_as_bytes. Thanks to Noah Thorp for finding this and the bug fixed in 1.1.3.</p>
|
444
|
+
</li></ul>
|
445
|
+
|
446
|
+
<h3 id="label-Changes+for+1.1.3-3A">Changes for 1.1.3:<span><a href="#label-Changes+for+1.1.3-3A">¶</a> <a href="#top">↑</a></span></h3>
|
447
|
+
<ul><li>
|
448
|
+
<p>Fixed the way midilib detects the behavior of IO.getc.</p>
|
449
|
+
</li></ul>
|
450
|
+
|
451
|
+
<h3 id="label-Changes+for+1.1.2-3A">Changes for 1.1.2:<span><a href="#label-Changes+for+1.1.2-3A">¶</a> <a href="#top">↑</a></span></h3>
|
452
|
+
<ul><li>
|
453
|
+
<p>Define <a href="MIDI/IO/MIDIFile.html#method-i-getc"><code>MIDI::IO::MIDIFile.getc</code></a> differently for different Ruby versions, instead of checking for String.bytes every time we read a byte.</p>
|
454
|
+
</li></ul>
|
455
|
+
|
456
|
+
<h3 id="label-Changes+for+1.1.1-3A">Changes for 1.1.1:<span><a href="#label-Changes+for+1.1.1-3A">¶</a> <a href="#top">↑</a></span></h3>
|
457
|
+
<ul><li>
|
458
|
+
<p>Make <a href="MIDI/IO/MIDIFile.html#method-i-getc"><code>MIDI::IO::MIDIFile.getc</code></a> do the right thing for both Ruby 1.8 and 1.9.</p>
|
459
|
+
</li></ul>
|
460
|
+
|
461
|
+
<h3 id="label-Changes+for+1.1.0-3A">Changes for 1.1.0:<span><a href="#label-Changes+for+1.1.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
462
|
+
<ul><li>
|
463
|
+
<p>Added test/test.mid to list of files to be included when packaging midifile for distribution.</p>
|
464
|
+
</li></ul>
|
465
|
+
|
466
|
+
<h3 id="label-Changes+for+1.0.0-3A">Changes for 1.0.0:<span><a href="#label-Changes+for+1.0.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
467
|
+
<ul><li>
|
468
|
+
<p>Fixed the bug in Track#recalc_delta_from_times found by Christopher Rose.</p>
|
469
|
+
</li></ul>
|
470
|
+
|
471
|
+
<h3 id="label-Changes+for+0.8.7-3A">Changes for 0.8.7:<span><a href="#label-Changes+for+0.8.7-3A">¶</a> <a href="#top">↑</a></span></h3>
|
472
|
+
<ul><li>
|
473
|
+
<p>Fixed the misspelled POLY_PRESSURE constant, thanks to Mario Pehle.</p>
|
474
|
+
</li></ul>
|
475
|
+
|
476
|
+
<h3 id="label-Changes+for+0.8.6-3A">Changes for 0.8.6:<span><a href="#label-Changes+for+0.8.6-3A">¶</a> <a href="#top">↑</a></span></h3>
|
477
|
+
<ul><li>
|
478
|
+
<p>Added missing test/test.mid.</p>
|
479
|
+
</li></ul>
|
480
|
+
|
481
|
+
<h3 id="label-Changes+for+0.8.5-3A">Changes for 0.8.5:<span><a href="#label-Changes+for+0.8.5-3A">¶</a> <a href="#top">↑</a></span></h3>
|
482
|
+
<ul><li>
|
483
|
+
<p>Fixed bugs in <a href="MIDI/PitchBend.html"><code>MIDI::PitchBend</code></a> reading and writing, thanks to Emanuel Borsboom.</p>
|
484
|
+
</li><li>
|
485
|
+
<p>Fixed a bug in <a href="MIDI/Track.html#method-i-quantize"><code>MIDI::Track#quantize</code></a>.</p>
|
486
|
+
</li><li>
|
487
|
+
<p>The argument to <a href="MIDI/Track.html#method-i-quantize"><code>MIDI::Track#quantize</code></a> has changed: it is now either a note name (“sixteenth”, “32nd”, “8th triplet”) or a length (1 = quarter, 0.25 = sixteenth). This is a drastic change that will break all previous calls to quantize. However, since that method was broken already, I don’t feel it’s a burden to anybody to change the arguments.</p>
|
488
|
+
</li></ul>
|
489
|
+
|
490
|
+
<h3 id="label-Changes+for+0.8.4-3A">Changes for 0.8.4:<span><a href="#label-Changes+for+0.8.4-3A">¶</a> <a href="#top">↑</a></span></h3>
|
491
|
+
<ul><li>
|
492
|
+
<p>Realtime status bytes now set @is_realtime to true and return true when realtime? is called.</p>
|
493
|
+
</li><li>
|
494
|
+
<p>All system common events now set @is_system to true and return true when system? is called, not just system exclusive events.</p>
|
495
|
+
</li><li>
|
496
|
+
<p>Added examples/from_scratch.rb, which shows how to create a sequence manually.</p>
|
497
|
+
</li><li>
|
498
|
+
<p>New <a href="MIDI/Sequence.html"><code>MIDI::Sequence</code></a> methods that turn note length names like “32nd”, “dotted quarter”, and “16th triplet” into delta times. See the docs below and MIDI::Sequence::length_to_delta, MIDI::Sequence::note_to_length, and MIDI::Sequence::note_to_delta.</p>
|
499
|
+
</li></ul>
|
500
|
+
|
501
|
+
<h3 id="label-Changes+for+0.8.3-3A">Changes for 0.8.3:<span><a href="#label-Changes+for+0.8.3-3A">¶</a> <a href="#top">↑</a></span></h3>
|
502
|
+
<ul><li>
|
503
|
+
<p>Added <a href="MIDI/NoteEvent.html#method-i-note_to_s"><code>MIDI::NoteEvent.note_to_s</code></a>, which returns note name as a string like “C4” or “F#6”.</p>
|
504
|
+
</li><li>
|
505
|
+
<p>Added new boolean attributes to <a href="MIDI/Event.html"><code>MIDI::Event</code></a>: @print_decimal_numbers and @print_note_names. These are used by all Event to_s methods. See examples/seq2text.rb for an example.</p>
|
506
|
+
</li></ul>
|
507
|
+
|
508
|
+
<h3 id="label-Changes+for+0.8.2-3A">Changes for 0.8.2:<span><a href="#label-Changes+for+0.8.2-3A">¶</a> <a href="#top">↑</a></span></h3>
|
509
|
+
<ul><li>
|
510
|
+
<p>Changed MIDI::MetaEvent.type to MIDI::MetaEvent.event_type to avoid runtime complaints about Object#type calls.</p>
|
511
|
+
</li><li>
|
512
|
+
<p>Added ‘b’ binary flag to file open modes for Windows.</p>
|
513
|
+
</li><li>
|
514
|
+
<p>Fixed $LOAD_PATH in example files.</p>
|
515
|
+
</li><li>
|
516
|
+
<p>Fixed read and write block arguments.</p>
|
517
|
+
</li><li>
|
518
|
+
<p>Fixed other example script bugs.</p>
|
519
|
+
</li></ul>
|
520
|
+
|
521
|
+
<h3 id="label-Changes+for+0.8.1-3A">Changes for 0.8.1:<span><a href="#label-Changes+for+0.8.1-3A">¶</a> <a href="#top">↑</a></span></h3>
|
522
|
+
<ul><li>
|
523
|
+
<p>Fixed track sorting.</p>
|
524
|
+
</li><li>
|
525
|
+
<p>Fixed track’s recalc_delta_from_times method.</p>
|
526
|
+
</li><li>
|
527
|
+
<p>Fixed event quantization.</p>
|
528
|
+
</li><li>
|
529
|
+
<p>More tests and documentation.</p>
|
530
|
+
</li></ul>
|
531
|
+
|
532
|
+
<h2 id="label-Warranty">Warranty<span><a href="#label-Warranty">¶</a> <a href="#top">↑</a></span></h2>
|
533
|
+
|
534
|
+
<p>This software is provided “as is” and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.</p>
|
535
|
+
|
536
|
+
</main>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
<footer id="validator-badges" role="contentinfo">
|
541
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
542
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.
|
543
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
544
|
+
</footer>
|
545
|
+
|