midilib 2.0.5 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog +2 -1
- data/Credits +39 -2
- data/README.rdoc +5 -6
- data/Rakefile +36 -49
- data/TODO.rdoc +13 -2
- data/examples/from_scratch.rb +1 -1
- data/examples/measures_mbt.rb +11 -11
- data/examples/print_program_changes.rb +2 -2
- data/examples/reader2text.rb +47 -47
- data/examples/seq2text.rb +1 -1
- data/examples/split.rb +4 -3
- data/examples/strings.rb +4 -4
- data/examples/transpose.rb +19 -20
- data/install.rb +21 -13
- data/lib/midilib/consts.rb +237 -239
- data/lib/midilib/event.rb +128 -100
- data/lib/midilib/info.rb +3 -5
- data/lib/midilib/io/midifile.rb +155 -182
- data/lib/midilib/io/seqreader.rb +80 -85
- data/lib/midilib/io/seqwriter.rb +93 -88
- data/lib/midilib/measure.rb +78 -80
- data/lib/midilib/mergesort.rb +39 -0
- data/lib/midilib/sequence.rb +40 -32
- data/lib/midilib/track.rb +16 -57
- data/lib/midilib/utils.rb +4 -7
- data/lib/midilib.rb +5 -5
- data/test/event_equality.rb +28 -30
- data/test/test_event.rb +9 -11
- data/test/test_io.rb +83 -3
- data/test/test_mergesort.rb +37 -0
- data/test/test_midifile.rb +6 -19
- data/test/test_sequence.rb +5 -4
- data/test/test_track.rb +9 -38
- data/test/test_varlen.rb +1 -3
- metadata +8 -95
- data/html/IO.html +0 -155
- data/html/MIDI/ActiveSense.html +0 -206
- data/html/MIDI/ChannelEvent.html +0 -231
- data/html/MIDI/ChannelPressure.html +0 -265
- data/html/MIDI/Clock.html +0 -206
- data/html/MIDI/Continue.html +0 -206
- data/html/MIDI/Controller.html +0 -280
- data/html/MIDI/Event.html +0 -489
- data/html/MIDI/IO/MIDIFile.html +0 -2024
- data/html/MIDI/IO/SeqReader.html +0 -904
- data/html/MIDI/IO/SeqWriter.html +0 -572
- data/html/MIDI/IO.html +0 -95
- data/html/MIDI/KeySig.html +0 -353
- data/html/MIDI/MIDI/MIDI/Array.html +0 -255
- data/html/MIDI/MIDI/MIDI.html +0 -95
- data/html/MIDI/MIDI.html +0 -95
- data/html/MIDI/Marker.html +0 -158
- data/html/MIDI/Measure.html +0 -328
- data/html/MIDI/Measures.html +0 -285
- data/html/MIDI/MetaEvent.html +0 -461
- data/html/MIDI/NoteEvent.html +0 -331
- data/html/MIDI/NoteOff.html +0 -228
- data/html/MIDI/NoteOn.html +0 -228
- data/html/MIDI/PitchBend.html +0 -266
- data/html/MIDI/PolyPressure.html +0 -277
- data/html/MIDI/ProgramChange.html +0 -265
- data/html/MIDI/Realtime.html +0 -242
- data/html/MIDI/Sequence.html +0 -896
- data/html/MIDI/SongPointer.html +0 -266
- data/html/MIDI/SongSelect.html +0 -265
- data/html/MIDI/Start.html +0 -206
- data/html/MIDI/Stop.html +0 -206
- data/html/MIDI/SystemCommon.html +0 -158
- data/html/MIDI/SystemExclusive.html +0 -268
- data/html/MIDI/SystemReset.html +0 -206
- data/html/MIDI/Tempo.html +0 -396
- data/html/MIDI/TimeSig.html +0 -388
- data/html/MIDI/Track.html +0 -695
- data/html/MIDI/TuneRequest.html +0 -242
- data/html/MIDI/Utils.html +0 -220
- data/html/MIDI.html +0 -547
- data/html/README_rdoc.html +0 -731
- data/html/TODO_rdoc.html +0 -125
- data/html/created.rid +0 -14
- data/html/css/fonts.css +0 -167
- data/html/css/rdoc.css +0 -590
- 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 +0 -768
- data/html/js/darkfish.js +0 -161
- data/html/js/jquery.js +0 -4
- data/html/js/navigation.js +0 -142
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +0 -109
- data/html/js/search_index.js +0 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +0 -228
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +0 -1265
data/html/index.html
DELETED
@@ -1,768 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>midilib</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
</script>
|
12
|
-
|
13
|
-
<script src="./js/jquery.js"></script>
|
14
|
-
<script src="./js/darkfish.js"></script>
|
15
|
-
|
16
|
-
<link href="./css/fonts.css" rel="stylesheet">
|
17
|
-
<link href="./css/rdoc.css" rel="stylesheet">
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
<body id="top" role="document" class="file">
|
22
|
-
<nav role="navigation">
|
23
|
-
<div id="project-navigation">
|
24
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
25
|
-
<h2>
|
26
|
-
<a href="./index.html" rel="home">Home</a>
|
27
|
-
</h2>
|
28
|
-
|
29
|
-
<div id="table-of-contents-navigation">
|
30
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
31
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
32
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
33
|
-
</div>
|
34
|
-
</div>
|
35
|
-
|
36
|
-
|
37
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
-
<form action="#" method="get" accept-charset="utf-8">
|
39
|
-
<div id="search-field-wrapper">
|
40
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
-
aria-autocomplete="list" aria-controls="search-results"
|
42
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<ul id="search-results" aria-label="Search Results"
|
47
|
-
aria-busy="false" aria-expanded="false"
|
48
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
-
</form>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
<div id="project-metadata">
|
55
|
-
<div id="fileindex-section" class="nav-section">
|
56
|
-
<h3>Pages</h3>
|
57
|
-
|
58
|
-
<ul class="link-list">
|
59
|
-
|
60
|
-
<li><a href="./README_rdoc.html">README</a>
|
61
|
-
|
62
|
-
<li><a href="./TODO_rdoc.html">TODO</a>
|
63
|
-
|
64
|
-
</ul>
|
65
|
-
</div>
|
66
|
-
|
67
|
-
<div id="classindex-section" class="nav-section">
|
68
|
-
<h3>Class and Module Index</h3>
|
69
|
-
|
70
|
-
<ul class="link-list">
|
71
|
-
|
72
|
-
<li><a href="./IO.html">IO</a>
|
73
|
-
|
74
|
-
<li><a href="./MIDI.html">MIDI</a>
|
75
|
-
|
76
|
-
<li><a href="./MIDI/ActiveSense.html">MIDI::ActiveSense</a>
|
77
|
-
|
78
|
-
<li><a href="./MIDI/ChannelEvent.html">MIDI::ChannelEvent</a>
|
79
|
-
|
80
|
-
<li><a href="./MIDI/ChannelPressure.html">MIDI::ChannelPressure</a>
|
81
|
-
|
82
|
-
<li><a href="./MIDI/Clock.html">MIDI::Clock</a>
|
83
|
-
|
84
|
-
<li><a href="./MIDI/Continue.html">MIDI::Continue</a>
|
85
|
-
|
86
|
-
<li><a href="./MIDI/Controller.html">MIDI::Controller</a>
|
87
|
-
|
88
|
-
<li><a href="./MIDI/Event.html">MIDI::Event</a>
|
89
|
-
|
90
|
-
<li><a href="./MIDI/IO.html">MIDI::IO</a>
|
91
|
-
|
92
|
-
<li><a href="./MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a>
|
93
|
-
|
94
|
-
<li><a href="./MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a>
|
95
|
-
|
96
|
-
<li><a href="./MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a>
|
97
|
-
|
98
|
-
<li><a href="./MIDI/KeySig.html">MIDI::KeySig</a>
|
99
|
-
|
100
|
-
<li><a href="./MIDI/MIDI.html">MIDI::MIDI</a>
|
101
|
-
|
102
|
-
<li><a href="./MIDI/MIDI/MIDI.html">MIDI::MIDI::MIDI</a>
|
103
|
-
|
104
|
-
<li><a href="./MIDI/MIDI/MIDI/Array.html">MIDI::MIDI::MIDI::Array</a>
|
105
|
-
|
106
|
-
<li><a href="./MIDI/Marker.html">MIDI::Marker</a>
|
107
|
-
|
108
|
-
<li><a href="./MIDI/Measure.html">MIDI::Measure</a>
|
109
|
-
|
110
|
-
<li><a href="./MIDI/Measures.html">MIDI::Measures</a>
|
111
|
-
|
112
|
-
<li><a href="./MIDI/MetaEvent.html">MIDI::MetaEvent</a>
|
113
|
-
|
114
|
-
<li><a href="./MIDI/NoteEvent.html">MIDI::NoteEvent</a>
|
115
|
-
|
116
|
-
<li><a href="./MIDI/NoteOff.html">MIDI::NoteOff</a>
|
117
|
-
|
118
|
-
<li><a href="./MIDI/NoteOff.html">MIDI::NoteOffEvent</a>
|
119
|
-
|
120
|
-
<li><a href="./MIDI/NoteOn.html">MIDI::NoteOn</a>
|
121
|
-
|
122
|
-
<li><a href="./MIDI/NoteOn.html">MIDI::NoteOnEvent</a>
|
123
|
-
|
124
|
-
<li><a href="./MIDI/PitchBend.html">MIDI::PitchBend</a>
|
125
|
-
|
126
|
-
<li><a href="./MIDI/PolyPressure.html">MIDI::PolyPressure</a>
|
127
|
-
|
128
|
-
<li><a href="./MIDI/ProgramChange.html">MIDI::ProgramChange</a>
|
129
|
-
|
130
|
-
<li><a href="./MIDI/Realtime.html">MIDI::Realtime</a>
|
131
|
-
|
132
|
-
<li><a href="./MIDI/Sequence.html">MIDI::Sequence</a>
|
133
|
-
|
134
|
-
<li><a href="./MIDI/SongPointer.html">MIDI::SongPointer</a>
|
135
|
-
|
136
|
-
<li><a href="./MIDI/SongSelect.html">MIDI::SongSelect</a>
|
137
|
-
|
138
|
-
<li><a href="./MIDI/Start.html">MIDI::Start</a>
|
139
|
-
|
140
|
-
<li><a href="./MIDI/Stop.html">MIDI::Stop</a>
|
141
|
-
|
142
|
-
<li><a href="./MIDI/SystemCommon.html">MIDI::SystemCommon</a>
|
143
|
-
|
144
|
-
<li><a href="./MIDI/SystemExclusive.html">MIDI::SystemExclusive</a>
|
145
|
-
|
146
|
-
<li><a href="./MIDI/SystemReset.html">MIDI::SystemReset</a>
|
147
|
-
|
148
|
-
<li><a href="./MIDI/Tempo.html">MIDI::Tempo</a>
|
149
|
-
|
150
|
-
<li><a href="./MIDI/TimeSig.html">MIDI::TimeSig</a>
|
151
|
-
|
152
|
-
<li><a href="./MIDI/Track.html">MIDI::Track</a>
|
153
|
-
|
154
|
-
<li><a href="./MIDI/TuneRequest.html">MIDI::TuneRequest</a>
|
155
|
-
|
156
|
-
<li><a href="./MIDI/Utils.html">MIDI::Utils</a>
|
157
|
-
|
158
|
-
</ul>
|
159
|
-
</div>
|
160
|
-
|
161
|
-
</div>
|
162
|
-
</nav>
|
163
|
-
|
164
|
-
<main role="main">
|
165
|
-
|
166
|
-
|
167
|
-
<h1 id="label-midilib">midilib<span><a href="#label-midilib">¶</a> <a href="#top">↑</a></span></h1>
|
168
|
-
|
169
|
-
<p>midilib is a pure Ruby <a href="MIDI.html">MIDI</a> library useful for
|
170
|
-
reading and writing standard <a href="MIDI.html">MIDI</a> files and
|
171
|
-
manipulating <a href="MIDI.html">MIDI</a> event data.</p>
|
172
|
-
|
173
|
-
<p>The GitHub project page and Web site of midilib is <a
|
174
|
-
href="http://github.com/jimm/midilib">github.com/jimm/midilib</a> and the
|
175
|
-
RubyGems.org page is <a
|
176
|
-
href="http://rubygems.org/gems/midilib">rubygems.org/gems/midilib</a>,
|
177
|
-
where you can also find all the RDoc documentation.</p>
|
178
|
-
|
179
|
-
<p>midilib is compatible with Ruby 1.8.x 1.9.x, and 2.x.</p>
|
180
|
-
|
181
|
-
<h2 id="label-Dependencies">Dependencies<span><a href="#label-Dependencies">¶</a> <a href="#top">↑</a></span></h2>
|
182
|
-
|
183
|
-
<p>midilib does not require any other packages. The test suite in the tests
|
184
|
-
directory requires the testing framework TestUnit, which comes with Ruby
|
185
|
-
1.8 and later and can also be found in the Ruby Application Archive (<a
|
186
|
-
href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>).</p>
|
187
|
-
|
188
|
-
<p>To rebuild the gem or RDocs or run the tests easily, you can use the
|
189
|
-
Rakefile which requires Rake (<a
|
190
|
-
href="http://rake.rubyforge.org">rake.rubyforge.org</a>).</p>
|
191
|
-
|
192
|
-
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
193
|
-
|
194
|
-
<h3 id="label-RubyGems+Installation">RubyGems Installation<span><a href="#label-RubyGems+Installation">¶</a> <a href="#top">↑</a></span></h3>
|
195
|
-
|
196
|
-
<p>To install midilib as a gem, type</p>
|
197
|
-
|
198
|
-
<pre>% gem install midilib</pre>
|
199
|
-
|
200
|
-
<p>or, if you already have a previous version, use</p>
|
201
|
-
|
202
|
-
<pre>% gem update midilib</pre>
|
203
|
-
|
204
|
-
<p>You may need root privileges to install or update the gem.</p>
|
205
|
-
|
206
|
-
<h3 id="label-Manual+Installation">Manual Installation<span><a href="#label-Manual+Installation">¶</a> <a href="#top">↑</a></span></h3>
|
207
|
-
|
208
|
-
<p>After downloading and expanding the archive, you can install midilib with
|
209
|
-
the command</p>
|
210
|
-
|
211
|
-
<pre>% ruby install.rb</pre>
|
212
|
-
|
213
|
-
<p>(or)</p>
|
214
|
-
|
215
|
-
<pre>% ruby install.rb --install-dir=my_directory</pre>
|
216
|
-
|
217
|
-
<p>You may need root privileges to install.</p>
|
218
|
-
|
219
|
-
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
220
|
-
|
221
|
-
<pre>% rake test</pre>
|
222
|
-
|
223
|
-
<p>runs all of the tests in the test directory.</p>
|
224
|
-
|
225
|
-
<h2 id="label-Overview">Overview<span><a href="#label-Overview">¶</a> <a href="#top">↑</a></span></h2>
|
226
|
-
|
227
|
-
<p>The midilib <a href="MIDI.html">MIDI</a> file reader only understands <a
|
228
|
-
href="MIDI.html">MIDI</a> file format 1, where a sequence is made up of
|
229
|
-
multiple tracks. It doesn't yet understand format 0 (a single track
|
230
|
-
containing all events) or format 2 (a collection of format 0 files in one
|
231
|
-
file).</p>
|
232
|
-
|
233
|
-
<h3 id="label-MIDI-3A-3ASequence"><a href="MIDI/Sequence.html">MIDI::Sequence</a><span><a href="#label-MIDI-3A-3ASequence">¶</a> <a href="#top">↑</a></span></h3>
|
234
|
-
|
235
|
-
<p>A sequence contains a collection of tracks and global information like the
|
236
|
-
sequence's pulses per quarter note (ppqn) and time signature.</p>
|
237
|
-
|
238
|
-
<p>The first track in a sequence is special; it holds meta-events like tempo
|
239
|
-
and sequence name. Don't put any notes in this track.</p>
|
240
|
-
|
241
|
-
<p><a href="MIDI/Sequence.html">MIDI::Sequence</a> also contains some
|
242
|
-
convenience methods that let you set and retrieve the sequence's name,
|
243
|
-
the time signature, and to retrieve the first tempo event's
|
244
|
-
beats-per-minute value.</p>
|
245
|
-
|
246
|
-
<p>Normally instances of <a
|
247
|
-
href="MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a> and <a
|
248
|
-
href="MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a> are used when a
|
249
|
-
sequence reads itself from or writes itself to a <a
|
250
|
-
href="MIDI.html">MIDI</a> file. You can change that by setting a
|
251
|
-
sequence's reader_class or writer_class attributes. Instances of the
|
252
|
-
classes contained in those attributes are created and used whenever the
|
253
|
-
sequence reads or writes itself.</p>
|
254
|
-
|
255
|
-
<h3 id="label-MIDI-3A-3ATrack"><a href="MIDI/Track.html">MIDI::Track</a><span><a href="#label-MIDI-3A-3ATrack">¶</a> <a href="#top">↑</a></span></h3>
|
256
|
-
|
257
|
-
<p>A track contains an array of events.</p>
|
258
|
-
|
259
|
-
<p>When you modify the <code>events</code> array, make sure to call
|
260
|
-
recalc_times so each event gets its <code>time_from_start</code>
|
261
|
-
recalculated. You don't have to do that after every event you add; just
|
262
|
-
remember to do so before using the track in a way that expects the list of
|
263
|
-
events to be ordered correctly.</p>
|
264
|
-
|
265
|
-
<p>A Track also holds a bit mask that specifies the channels used by the
|
266
|
-
track. This bit mask is set when the track is read from the <a
|
267
|
-
href="MIDI.html">MIDI</a> file by a SeqReader but is <em>not</em> kept up
|
268
|
-
to date by any other methods. Specifically, if you add events to a track at
|
269
|
-
any other time, the bit mask will not be updated.</p>
|
270
|
-
|
271
|
-
<h3 id="label-MIDI-3A-3AMeasure"><a href="MIDI/Measure.html">MIDI::Measure</a><span><a href="#label-MIDI-3A-3AMeasure">¶</a> <a href="#top">↑</a></span></h3>
|
272
|
-
|
273
|
-
<p>This class contains information about a measure from the sequence. Measure
|
274
|
-
data is based on the time signature information from the sequence and is
|
275
|
-
not stored in the sequence itself.</p>
|
276
|
-
|
277
|
-
<h3 id="label-MIDI-3A-3AMeasures"><a href="MIDI/Measures.html">MIDI::Measures</a><span><a href="#label-MIDI-3A-3AMeasures">¶</a> <a href="#top">↑</a></span></h3>
|
278
|
-
|
279
|
-
<p>The class <a href="MIDI/Sequence.html">MIDI::Sequence</a> method
|
280
|
-
get_measures returns a <a href="MIDI/Measures.html">MIDI::Measures</a>
|
281
|
-
object. <a href="MIDI/Measures.html">MIDI::Measures</a> is a subclass of
|
282
|
-
Array. It is a specialized container for <a
|
283
|
-
href="MIDI/Measure.html">MIDI::Measure</a> objects, which can be use to map
|
284
|
-
event times to measure numbers. Please note that this object has to be
|
285
|
-
remade when events are deleted/added in the sequence.</p>
|
286
|
-
|
287
|
-
<p><a href="MIDI/Measure.html">MIDI::Measure</a> and <a
|
288
|
-
href="MIDI/Measures.html">MIDI::Measures</a> are brought to us by Jari
|
289
|
-
Williamsson <jari.williamsson@mailbox.swipnet.se>, who also
|
290
|
-
contributed some improvements to the <a
|
291
|
-
href="MIDI/Event.html">MIDI::Event</a> and <a
|
292
|
-
href="MIDI/Track.html">MIDI::Track</a> classes.</p>
|
293
|
-
|
294
|
-
<h3 id="label-MIDI-3A-3AEvent"><a href="MIDI/Event.html">MIDI::Event</a><span><a href="#label-MIDI-3A-3AEvent">¶</a> <a href="#top">↑</a></span></h3>
|
295
|
-
|
296
|
-
<p>Each event holds not only its delta time but also its time from the start
|
297
|
-
of the track. The track is responsible for recalculating its events'
|
298
|
-
start times. You can call <a
|
299
|
-
href="MIDI/Track.html#method-i-recalc_times">MIDI::Track#recalc_times</a>
|
300
|
-
to do so.</p>
|
301
|
-
|
302
|
-
<p>Subclasses of <a href="MIDI/Event.html">MIDI::Event</a> implement the
|
303
|
-
various <a href="MIDI.html">MIDI</a> messages such as note on and off,
|
304
|
-
controller values, system exclusive data, and realtime bytes.</p>
|
305
|
-
|
306
|
-
<p><a href="MIDI/Realtime.html">MIDI::Realtime</a> events have delta values
|
307
|
-
and start times, just like all the other midilib event types do. (MIDI real
|
308
|
-
time status bytes don't have delta times, but this way we can record
|
309
|
-
when in a track the realtime byte was received and should be sent. This is
|
310
|
-
useful for start/continue/stop events that control other devices, for
|
311
|
-
example.) Note that when a <a href="MIDI/Realtime.html">MIDI::Realtime</a>
|
312
|
-
event is written out to a <a href="MIDI.html">MIDI</a> file, the delta time
|
313
|
-
is not written.</p>
|
314
|
-
|
315
|
-
<p><a href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> events hold an array of
|
316
|
-
bytes named 'data'. Many meta events are string holders (text,
|
317
|
-
lyric, marker, etc.) Though the 'data' value is always an array of
|
318
|
-
bytes, <a href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> helps with saving
|
319
|
-
and accessing string. The <a
|
320
|
-
href="MIDI/MetaEvent.html#method-i-data_as_str">MIDI::MetaEvent#data_as_str</a>
|
321
|
-
method returns the data bytes as a string. When assigning to a meta
|
322
|
-
event's data, if you pass in a string it will get converted to an array
|
323
|
-
of bytes.</p>
|
324
|
-
|
325
|
-
<h2 id="label-How+To+Use">How To Use<span><a href="#label-How+To+Use">¶</a> <a href="#top">↑</a></span></h2>
|
326
|
-
|
327
|
-
<p>The following examples show you how to use midilib to read, write, and
|
328
|
-
manipulate <a href="MIDI.html">MIDI</a> files and modify track events. See
|
329
|
-
also the files in the examples directory, which are described below.</p>
|
330
|
-
|
331
|
-
<h3 id="label-Reading+a+MIDI+File">Reading a <a href="MIDI.html">MIDI</a> File<span><a href="#label-Reading+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
332
|
-
|
333
|
-
<p>To read a <a href="MIDI.html">MIDI</a> file, create a <a
|
334
|
-
href="MIDI/Sequence.html">MIDI::Sequence</a> object and call its read
|
335
|
-
method, passing in an <a href="IO.html">IO</a> object.</p>
|
336
|
-
|
337
|
-
<p>The read method takes an optional block. If present, the block is called
|
338
|
-
once after each track has finished being read. Each time, it is passed the
|
339
|
-
track object, the total number of tracks and the number of the current
|
340
|
-
track that has just been read. This is useful for notifying the user of
|
341
|
-
progress, for example by updating a GUI progress bar.</p>
|
342
|
-
|
343
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqreader'</span>
|
344
|
-
|
345
|
-
<span class="ruby-comment"># Create a new, empty sequence.</span>
|
346
|
-
<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>()
|
347
|
-
|
348
|
-
<span class="ruby-comment"># Read the contents of a MIDI file into the sequence.</span>
|
349
|
-
<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>
|
350
|
-
<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>
|
351
|
-
<span class="ruby-comment"># Print something when each track is read.</span>
|
352
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-node">"read track #{i} of #{num_tracks}"</span>
|
353
|
-
}
|
354
|
-
}
|
355
|
-
</pre>
|
356
|
-
|
357
|
-
<h3 id="label-Writing+a+MIDI+File">Writing a <a href="MIDI.html">MIDI</a> File<span><a href="#label-Writing+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
358
|
-
|
359
|
-
<p>To write a <a href="MIDI.html">MIDI</a> file, call the write method,
|
360
|
-
passing in an <a href="IO.html">IO</a> object.</p>
|
361
|
-
|
362
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqwriter'</span>
|
363
|
-
|
364
|
-
<span class="ruby-comment"># Start with a sequence that has something worth saving.</span>
|
365
|
-
<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">read_or_create_seq_we_care_not_how</span>()
|
366
|
-
|
367
|
-
<span class="ruby-comment"># Write the sequence to a MIDI file.</span>
|
368
|
-
<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>) }
|
369
|
-
</pre>
|
370
|
-
|
371
|
-
<h3 id="label-Editing+a+MIDI+File">Editing a <a href="MIDI.html">MIDI</a> File<span><a href="#label-Editing+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
372
|
-
|
373
|
-
<p>Combining the last two examples, here is a script that reads a <a
|
374
|
-
href="MIDI.html">MIDI</a> file, transposes some events, and writes the
|
375
|
-
sequence out to a different file. This is a useful template for
|
376
|
-
programatically manipulating <a href="MIDI.html">MIDI</a> data.</p>
|
377
|
-
|
378
|
-
<p>This code transposes all of the note events (note on, note off, and poly
|
379
|
-
pressure) on channel 5 down one octave.</p>
|
380
|
-
|
381
|
-
<h4 id="label-Transposing+One+Channel">Transposing One Channel<span><a href="#label-Transposing+One+Channel">¶</a> <a href="#top">↑</a></span></h4>
|
382
|
-
|
383
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqreader'</span>
|
384
|
-
<span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqwriter'</span>
|
385
|
-
|
386
|
-
<span class="ruby-comment"># Create a new, empty sequence.</span>
|
387
|
-
<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>()
|
388
|
-
|
389
|
-
<span class="ruby-comment"># Read the contents of a MIDI file into the sequence.</span>
|
390
|
-
<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>
|
391
|
-
<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>
|
392
|
-
<span class="ruby-comment"># Print something when each track is read.</span>
|
393
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-node">"read track #{i} of #{num_tracks}"</span>
|
394
|
-
}
|
395
|
-
}
|
396
|
-
|
397
|
-
<span class="ruby-comment"># Iterate over every event in every track.</span>
|
398
|
-
<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>
|
399
|
-
<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>
|
400
|
-
<span class="ruby-comment"># If the event is a note event (note on, note off, or poly</span>
|
401
|
-
<span class="ruby-comment"># pressure) and it is on MIDI channel 5 (channels start at</span>
|
402
|
-
<span class="ruby-comment"># 0, so we use 4), then transpose the event down one octave.</span>
|
403
|
-
<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>
|
404
|
-
<span class="ruby-identifier">event</span>.<span class="ruby-identifier">note</span> <span class="ruby-operator">-=</span> <span class="ruby-value">12</span>
|
405
|
-
<span class="ruby-keyword">end</span>
|
406
|
-
}
|
407
|
-
}
|
408
|
-
|
409
|
-
<span class="ruby-comment"># Write the sequence to a MIDI file.</span>
|
410
|
-
<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>) }
|
411
|
-
</pre>
|
412
|
-
|
413
|
-
<h3 id="label-Manipulating+tracks">Manipulating tracks<span><a href="#label-Manipulating+tracks">¶</a> <a href="#top">↑</a></span></h3>
|
414
|
-
|
415
|
-
<p>If you modify a track's list of events directly, don't forget to
|
416
|
-
call <a
|
417
|
-
href="MIDI/Track.html#method-i-recalc_times">MIDI::Track#recalc_times</a>
|
418
|
-
when you are done.</p>
|
419
|
-
|
420
|
-
<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>
|
421
|
-
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">events</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">an_event</span>
|
422
|
-
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">array_of_events</span>)
|
423
|
-
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">recalc_times</span>
|
424
|
-
</pre>
|
425
|
-
|
426
|
-
<h3 id="label-Calculating+delta+times">Calculating delta times<span><a href="#label-Calculating+delta+times">¶</a> <a href="#top">↑</a></span></h3>
|
427
|
-
|
428
|
-
<p>A few methods in <a href="MIDI/Sequence.html">MIDI::Sequence</a> make it
|
429
|
-
easier to calculate the delta times that represent note lengths. <a
|
430
|
-
href="MIDI/Sequence.html#method-i-length_to_delta">MIDI::Sequence#length_to_delta</a>
|
431
|
-
takes a note length (a multiple of a quarter note) and returns the delta
|
432
|
-
time given the sequence's current ppqn (pulses per quarter note)
|
433
|
-
setting. 1 is a quarter note, 1.0/32.0 is a 32nd note (use floating-point
|
434
|
-
numbers to avoid integer rounding), 1.5 is a dotted quarter, etc. See the
|
435
|
-
documentation for that method for more information.</p>
|
436
|
-
|
437
|
-
<p><a
|
438
|
-
href="MIDI/Sequence.html#method-i-note_to_length">MIDI::Sequence#note_to_length</a>
|
439
|
-
takes a note name and returns a length value (again, as a multiple of a
|
440
|
-
quarter note). Legal note names are those found in
|
441
|
-
MIDI::Sequence::NOTE_TO_LENGTH, and may begin with “dotted” and/or end with
|
442
|
-
“triplet”. For example, “whole”, “sixteenth”, “32nd”, “quarter triplet”,
|
443
|
-
“dotted 16th”, and “dotted 8th triplet” are all legal note names.</p>
|
444
|
-
|
445
|
-
<p>Finally, <a
|
446
|
-
href="MIDI/Sequence.html#method-i-note_to_delta">MIDI::Sequence#note_to_delta</a>
|
447
|
-
takes a note name and returns a delta time. It does this by calling
|
448
|
-
note_to_length, then passing the result to length_to_delta.</p>
|
449
|
-
|
450
|
-
<h3 id="label-Example+Scripts">Example Scripts<span><a href="#label-Example+Scripts">¶</a> <a href="#top">↑</a></span></h3>
|
451
|
-
|
452
|
-
<p>Here are short descriptions of each of the examples found in the examples
|
453
|
-
directory.</p>
|
454
|
-
<ul><li>
|
455
|
-
<p>examples/from_scratch.rb shows you how to create a new sequence from
|
456
|
-
scratch and save it to a <a href="MIDI.html">MIDI</a> file. It creates a
|
457
|
-
file called 'from_scratch.mid'.</p>
|
458
|
-
</li><li>
|
459
|
-
<p>examples/seq2text.rb dumps a <a href="MIDI.html">MIDI</a> file as text. It
|
460
|
-
reads in a sequence and uses the to_s method of each event.</p>
|
461
|
-
</li><li>
|
462
|
-
<p>examples/reader2text.rb dumps a <a href="MIDI.html">MIDI</a> file as text.
|
463
|
-
It subclasses MIDI::SeqReader instead of creating a sequence containing
|
464
|
-
tracks and events.</p>
|
465
|
-
</li><li>
|
466
|
-
<p>examples/transpose.rb transposes all note events (note on, note off, poly
|
467
|
-
pressure) on a specified channel by a specified amount.</p>
|
468
|
-
</li><li>
|
469
|
-
<p>There is also one <a href="MIDI.html">MIDI</a> file, examples/NoFences.mid.
|
470
|
-
It is a little pop ditty I wrote. The instruments in this file use General
|
471
|
-
<a href="MIDI.html">MIDI</a> patch numbers and drum note assignments. Since
|
472
|
-
I don't normally use GM patches, the sounds used here are at best
|
473
|
-
approximations of the sounds I use.</p>
|
474
|
-
</li></ul>
|
475
|
-
|
476
|
-
<h2 id="label-Resources">Resources<span><a href="#label-Resources">¶</a> <a href="#top">↑</a></span></h2>
|
477
|
-
|
478
|
-
<p>The Ruby Web site (<a
|
479
|
-
href="http://www.ruby-lang.org/en/index.html">www.ruby-lang.org/en/index.html</a>)
|
480
|
-
contains an introduction to Ruby, the Ruby Application Archive (RAA) at <a
|
481
|
-
href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>, and pointers to more
|
482
|
-
information.</p>
|
483
|
-
|
484
|
-
<p><cite>Programming Ruby, The Pragmatic Programmer's
|
485
|
-
Guide</cite>, by David Thomas and Andrew Hunt, is a well-written and
|
486
|
-
practical introduction to Ruby. Its Web page at <a
|
487
|
-
href="http://www.rubycentral.com/book">www.rubycentral.com/book</a> also
|
488
|
-
contains a wealth of Ruby information. Though the first edition book is
|
489
|
-
available online, I encourage you to purchase a copy of the latest edition.</p>
|
490
|
-
|
491
|
-
<p>A description of the <a href="MIDI.html">MIDI</a> file format can be found
|
492
|
-
in a few places such as <a
|
493
|
-
href="http://www.borg.com/~jglatt/tech/midifile.htm">www.borg.com/~jglatt/tech/midifile.htm</a>.</p>
|
494
|
-
|
495
|
-
<p>The <a href="MIDI.html">MIDI</a> message reference at <a
|
496
|
-
href="http://www.jimmenard.com/midi_ref.html">www.jimmenard.com/midi_ref.html</a>
|
497
|
-
describes the format of <a href="MIDI.html">MIDI</a> commands.</p>
|
498
|
-
|
499
|
-
<h1 id="label-To+Do">To Do<span><a href="#label-To+Do">¶</a> <a href="#top">↑</a></span></h1>
|
500
|
-
|
501
|
-
<h2 id="label-Bugs">Bugs<span><a href="#label-Bugs">¶</a> <a href="#top">↑</a></span></h2>
|
502
|
-
|
503
|
-
<p>No known bugs. (If that's not a challenge, I don't know what is.)</p>
|
504
|
-
|
505
|
-
<h2 id="label-Features">Features<span><a href="#label-Features">¶</a> <a href="#top">↑</a></span></h2>
|
506
|
-
<ul><li>
|
507
|
-
<p><code>print_decimal_numbers</code> and
|
508
|
-
<code>print_channel_numbers_from_one</code> should be associated with
|
509
|
-
sequence, or perhaps track, not event.</p>
|
510
|
-
</li><li>
|
511
|
-
<p>Method to translate event's time_from_start to number of milliseconds
|
512
|
-
from start.</p>
|
513
|
-
</li><li>
|
514
|
-
<p>Swing quantizing. (Implied by list email from Carl Youngblood
|
515
|
-
<carl.youngblood@gmail.com>)</p>
|
516
|
-
</li><li>
|
517
|
-
<p>Implement key signature in SeqReader.</p>
|
518
|
-
</li><li>
|
519
|
-
<p>Format 0 files.</p>
|
520
|
-
</li><li>
|
521
|
-
<p>Format 2 files(?).</p>
|
522
|
-
</li></ul>
|
523
|
-
|
524
|
-
<h2 id="label-Documentation">Documentation<span><a href="#label-Documentation">¶</a> <a href="#top">↑</a></span></h2>
|
525
|
-
<ul><li>
|
526
|
-
<p>Write better docs.</p>
|
527
|
-
</li></ul>
|
528
|
-
|
529
|
-
<h2 id="label-Tests">Tests<span><a href="#label-Tests">¶</a> <a href="#top">↑</a></span></h2>
|
530
|
-
<ul><li>
|
531
|
-
<p>Tests for Noah Thorp's midilib bug fixes.</p>
|
532
|
-
</li></ul>
|
533
|
-
|
534
|
-
<h1 id="label-Support">Support<span><a href="#label-Support">¶</a> <a href="#top">↑</a></span></h1>
|
535
|
-
<ul><li>
|
536
|
-
<p>Visit the forums, bug list, and mailing list pages at <a
|
537
|
-
href="http://rubyforge.org/projects/midilib">rubyforge.org/projects/midilib</a></p>
|
538
|
-
</li><li>
|
539
|
-
<p>Send email to Jim Menard at <a
|
540
|
-
href="mailto:jim@jimmenard.com">jim@jimmenard.com</a></p>
|
541
|
-
</li><li>
|
542
|
-
<p>Ask on the ruby-talk mailing list</p>
|
543
|
-
</li></ul>
|
544
|
-
|
545
|
-
<h1 id="label-Administrivia">Administrivia<span><a href="#label-Administrivia">¶</a> <a href="#top">↑</a></span></h1>
|
546
|
-
<dl class="rdoc-list note-list"><dt>Author
|
547
|
-
<dd>
|
548
|
-
<p>Jim Menard (<a href="mailto:jim@jimmenard.com">jim@jimmenard.com</a>)</p>
|
549
|
-
</dd><dt>Copyright
|
550
|
-
<dd>
|
551
|
-
<p>Copyright © 2003-2013 Jim Menard</p>
|
552
|
-
</dd><dt>License
|
553
|
-
<dd>
|
554
|
-
<p>Distributed under the same license as Ruby.</p>
|
555
|
-
</dd></dl>
|
556
|
-
|
557
|
-
<h2 id="label-Copying">Copying<span><a href="#label-Copying">¶</a> <a href="#top">↑</a></span></h2>
|
558
|
-
|
559
|
-
<p>midilib is copyrighted free software by Jim Menard and is released under
|
560
|
-
the same license as Ruby. See the Ruby license at <a
|
561
|
-
href="http://www.ruby-lang.org/en/LICENSE.txt">www.ruby-lang.org/en/LICENSE.txt</a>.</p>
|
562
|
-
|
563
|
-
<p>midilib may be freely copied in its entirety providing this notice, all
|
564
|
-
source code, all documentation, and all other files are included.</p>
|
565
|
-
|
566
|
-
<p>midilib is Copyright © 2003-2013 by Jim Menard.</p>
|
567
|
-
|
568
|
-
<p>The song “No Fences” contained in the <a href="MIDI.html">MIDI</a> file
|
569
|
-
examples/NoFences.mid is Copyright © 1992 by Jim Menard
|
570
|
-
(jim@jimmenard.com). It may be freely used for non-commercial purposes as
|
571
|
-
long as the author is given credit.</p>
|
572
|
-
|
573
|
-
<h2 id="label-Recent+Changes">Recent Changes<span><a href="#label-Recent+Changes">¶</a> <a href="#top">↑</a></span></h2>
|
574
|
-
|
575
|
-
<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>
|
576
|
-
|
577
|
-
<p>Updated <code>install.rb</code> to work with newer versions of Ruby by
|
578
|
-
using <code>fileutils</code> instead of <code>ftools</code>.</p>
|
579
|
-
|
580
|
-
<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>
|
581
|
-
|
582
|
-
<p>New <a
|
583
|
-
href="MIDI/Sequence.html#method-i-pulses_to_seconds">MIDI::Sequence#pulses_to_seconds</a>
|
584
|
-
method.</p>
|
585
|
-
|
586
|
-
<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>
|
587
|
-
|
588
|
-
<p>Stop monkeypatching Array in <a href="MIDI/Track.html">MIDI::Track</a>.</p>
|
589
|
-
|
590
|
-
<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>
|
591
|
-
|
592
|
-
<p><a href="MIDI/NoteOn.html">MIDI::NoteOnEvent</a> and <a
|
593
|
-
href="MIDI/NoteOff.html">MIDI::NoteOffEvent</a> renamed to <a
|
594
|
-
href="MIDI/NoteOn.html">MIDI::NoteOn</a> and <a
|
595
|
-
href="MIDI/NoteOff.html">MIDI::NoteOff</a>. The old names will still work
|
596
|
-
for a while.</p>
|
597
|
-
|
598
|
-
<p>The <a href="MIDI/Event.html">MIDI::Event</a> boolean methods like meta?
|
599
|
-
and note? have been removed. Use the event classes themselves (for example,
|
600
|
-
<a href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> === my_event or
|
601
|
-
my_event.kind_of?(MIDI::MetaEvent)). Case statements that use classes work,
|
602
|
-
too:</p>
|
603
|
-
|
604
|
-
<pre class="ruby"><span class="ruby-keyword">case</span> <span class="ruby-identifier">my_event</span>
|
605
|
-
<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>
|
606
|
-
<span class="ruby-identifier">do_this</span>()
|
607
|
-
<span class="ruby-keyword">when</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Controller</span>
|
608
|
-
<span class="ruby-identifier">do_that</span>()
|
609
|
-
<span class="ruby-keyword">end</span>
|
610
|
-
</pre>
|
611
|
-
|
612
|
-
<p>Introduced Adam Murray's stable sorting code for <a
|
613
|
-
href="MIDI/Track.html#method-i-recalc_delta_from_times">MIDI::Track#recalc_delta_from_times</a>.
|
614
|
-
See <a
|
615
|
-
href="http://wiki.github.com/adamjmurray/cosy/midilib-notes">wiki.github.com/adamjmurray/cosy/midilib-notes</a>
|
616
|
-
and <a
|
617
|
-
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>
|
618
|
-
for details.</p>
|
619
|
-
|
620
|
-
<p>Aliased <a href="MIDI/Track.html#method-i-sort">MIDI::Track#sort</a> to <a
|
621
|
-
href="MIDI/Track.html#method-i-recalc_delta_from_times">MIDI::Track#recalc_delta_from_times</a>,
|
622
|
-
since all sort did was sort the events then call recalc_delta_from_times,
|
623
|
-
and recalc_delta_from_times sorts the events before doing anything else.</p>
|
624
|
-
|
625
|
-
<p>MIDI::Tempo#mpq_to_bpm now returns a float.</p>
|
626
|
-
|
627
|
-
<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>
|
628
|
-
|
629
|
-
<p>Use byte arrays instead of strings for passing around data. All tests now
|
630
|
-
pass for both Ruby 1.8.X and 1.9.X.</p>
|
631
|
-
|
632
|
-
<h3 id="label-New+code+repository">New code repository<span><a href="#label-New+code+repository">¶</a> <a href="#top">↑</a></span></h3>
|
633
|
-
|
634
|
-
<p>The midilib code is now hosted at Github (<a
|
635
|
-
href="http://github.com/jimm/midilib">github.com/jimm/midilib</a>).</p>
|
636
|
-
|
637
|
-
<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>
|
638
|
-
<ul><li>
|
639
|
-
<p>Fixed a bug in KeySig.data_as_bytes. Thanks to Noah Thorp for finding this
|
640
|
-
and the bug fixed in 1.1.3.</p>
|
641
|
-
</li></ul>
|
642
|
-
|
643
|
-
<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>
|
644
|
-
<ul><li>
|
645
|
-
<p>Fixed the way midilib detects the behavior of IO.getc.</p>
|
646
|
-
</li></ul>
|
647
|
-
|
648
|
-
<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>
|
649
|
-
<ul><li>
|
650
|
-
<p>Define <a
|
651
|
-
href="MIDI/IO/MIDIFile.html#method-i-getc">MIDI::IO::MIDIFile#getc</a>
|
652
|
-
differently for different Ruby versions, instead of checking for
|
653
|
-
String.bytes every time we read a byte.</p>
|
654
|
-
</li></ul>
|
655
|
-
|
656
|
-
<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>
|
657
|
-
<ul><li>
|
658
|
-
<p>Make <a
|
659
|
-
href="MIDI/IO/MIDIFile.html#method-i-getc">MIDI::IO::MIDIFile#getc</a> do
|
660
|
-
the right thing for both Ruby 1.8 and 1.9.</p>
|
661
|
-
</li></ul>
|
662
|
-
|
663
|
-
<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>
|
664
|
-
<ul><li>
|
665
|
-
<p>Added test/test.mid to list of files to be included when packaging midifile
|
666
|
-
for distribution.</p>
|
667
|
-
</li></ul>
|
668
|
-
|
669
|
-
<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>
|
670
|
-
<ul><li>
|
671
|
-
<p>Fixed the bug in Track#recalc_delta_from_times found by Christopher Rose.</p>
|
672
|
-
</li></ul>
|
673
|
-
|
674
|
-
<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>
|
675
|
-
<ul><li>
|
676
|
-
<p>Fixed the misspelled POLY_PRESSURE constant, thanks to Mario Pehle.</p>
|
677
|
-
</li></ul>
|
678
|
-
|
679
|
-
<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>
|
680
|
-
<ul><li>
|
681
|
-
<p>Added missing test/test.mid.</p>
|
682
|
-
</li></ul>
|
683
|
-
|
684
|
-
<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>
|
685
|
-
<ul><li>
|
686
|
-
<p>Fixed bugs in <a href="MIDI/PitchBend.html">MIDI::PitchBend</a> reading and
|
687
|
-
writing, thanks to Emanuel Borsboom.</p>
|
688
|
-
</li><li>
|
689
|
-
<p>Fixed a bug in <a
|
690
|
-
href="MIDI/Track.html#method-i-quantize">MIDI::Track#quantize</a>.</p>
|
691
|
-
</li><li>
|
692
|
-
<p>The argument to <a
|
693
|
-
href="MIDI/Track.html#method-i-quantize">MIDI::Track#quantize</a> has
|
694
|
-
changed: it is now either a note name (“sixteenth”, “32nd”, “8th triplet”)
|
695
|
-
or a length (1 = quarter, 0.25 = sixteenth). This is a drastic change that
|
696
|
-
will break all previous calls to quantize. However, since that method was
|
697
|
-
broken already, I don't feel it's a burden to anybody to change the
|
698
|
-
arguments.</p>
|
699
|
-
</li></ul>
|
700
|
-
|
701
|
-
<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>
|
702
|
-
<ul><li>
|
703
|
-
<p>Realtime status bytes now set @is_realtime to true and return true when
|
704
|
-
realtime? is called.</p>
|
705
|
-
</li><li>
|
706
|
-
<p>All system common events now set @is_system to true and return true when
|
707
|
-
system? is called, not just system exclusive events.</p>
|
708
|
-
</li><li>
|
709
|
-
<p>Added examples/from_scratch.rb, which shows how to create a sequence
|
710
|
-
manually.</p>
|
711
|
-
</li><li>
|
712
|
-
<p>New <a href="MIDI/Sequence.html">MIDI::Sequence</a> methods that turn note
|
713
|
-
length names like “32nd”, “dotted quarter”, and “16th triplet” into delta
|
714
|
-
times. See the docs below and MIDI::Sequence::length_to_delta,
|
715
|
-
MIDI::Sequence::note_to_length, and MIDI::Sequence::note_to_delta.</p>
|
716
|
-
</li></ul>
|
717
|
-
|
718
|
-
<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>
|
719
|
-
<ul><li>
|
720
|
-
<p>Added <a
|
721
|
-
href="MIDI/NoteEvent.html#method-i-note_to_s">MIDI::NoteEvent#note_to_s</a>,
|
722
|
-
which returns note name as a string like “C4” or “F#6”.</p>
|
723
|
-
</li><li>
|
724
|
-
<p>Added new boolean attributes to MIDI::Event: @print_decimal_numbers and
|
725
|
-
@print_note_names. These are used by all Event to_s methods. See
|
726
|
-
examples/seq2text.rb for an example.</p>
|
727
|
-
</li></ul>
|
728
|
-
|
729
|
-
<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>
|
730
|
-
<ul><li>
|
731
|
-
<p>Changed MIDI::MetaEvent.type to MIDI::MetaEvent.event_type to avoid runtime
|
732
|
-
complaints about Object#type calls.</p>
|
733
|
-
</li><li>
|
734
|
-
<p>Added 'b' binary flag to file open modes for Windows.</p>
|
735
|
-
</li><li>
|
736
|
-
<p>Fixed $LOAD_PATH in example files.</p>
|
737
|
-
</li><li>
|
738
|
-
<p>Fixed read and write block arguments.</p>
|
739
|
-
</li><li>
|
740
|
-
<p>Fixed other example script bugs.</p>
|
741
|
-
</li></ul>
|
742
|
-
|
743
|
-
<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>
|
744
|
-
<ul><li>
|
745
|
-
<p>Fixed track sorting.</p>
|
746
|
-
</li><li>
|
747
|
-
<p>Fixed track's recalc_delta_from_times method.</p>
|
748
|
-
</li><li>
|
749
|
-
<p>Fixed event quantization.</p>
|
750
|
-
</li><li>
|
751
|
-
<p>More tests and documentation.</p>
|
752
|
-
</li></ul>
|
753
|
-
|
754
|
-
<h2 id="label-Warranty">Warranty<span><a href="#label-Warranty">¶</a> <a href="#top">↑</a></span></h2>
|
755
|
-
|
756
|
-
<p>This software is provided “as is” and without any express or implied
|
757
|
-
warranties, including, without limitation, the implied warranties of
|
758
|
-
merchantability and fitness for a particular purpose.</p>
|
759
|
-
</main>
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
<footer id="validator-badges" role="contentinfo">
|
764
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
765
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
766
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
767
|
-
</footer>
|
768
|
-
|