midilib 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Credits +5 -0
- data/README.rdoc +35 -30
- data/examples/reader2text.rb +1 -0
- data/html/IO.html +259 -0
- data/html/MIDI.html +665 -0
- data/html/MIDI/ActiveSense.html +295 -0
- data/html/MIDI/ChannelEvent.html +319 -0
- data/html/MIDI/ChannelPressure.html +350 -0
- data/html/MIDI/Clock.html +295 -0
- data/html/MIDI/Continue.html +295 -0
- data/html/MIDI/Controller.html +365 -0
- data/html/MIDI/Event.html +573 -0
- data/html/MIDI/IO.html +207 -0
- data/html/MIDI/IO/MIDIFile.html +1996 -0
- data/html/MIDI/IO/SeqReader.html +946 -0
- data/html/MIDI/IO/SeqWriter.html +648 -0
- data/html/MIDI/KeySig.html +435 -0
- data/html/MIDI/MIDI.html +204 -0
- data/html/MIDI/MIDI/MIDI.html +204 -0
- data/html/MIDI/MIDI/MIDI/Array.html +353 -0
- data/html/MIDI/Marker.html +257 -0
- data/html/MIDI/Measure.html +423 -0
- data/html/MIDI/Measures.html +375 -0
- data/html/MIDI/MetaEvent.html +534 -0
- data/html/MIDI/NoteEvent.html +417 -0
- data/html/MIDI/NoteOff.html +316 -0
- data/html/MIDI/NoteOn.html +316 -0
- data/html/MIDI/PitchBend.html +351 -0
- data/html/MIDI/PolyPressure.html +360 -0
- data/html/MIDI/ProgramChange.html +350 -0
- data/html/MIDI/Realtime.html +328 -0
- data/html/MIDI/Sequence.html +961 -0
- data/html/MIDI/SongPointer.html +351 -0
- data/html/MIDI/SongSelect.html +350 -0
- data/html/MIDI/Start.html +295 -0
- data/html/MIDI/Stop.html +295 -0
- data/html/MIDI/SystemCommon.html +257 -0
- data/html/MIDI/SystemExclusive.html +353 -0
- data/html/MIDI/SystemReset.html +295 -0
- data/html/MIDI/Tempo.html +474 -0
- data/html/MIDI/TimeSig.html +467 -0
- data/html/MIDI/Track.html +769 -0
- data/html/MIDI/TuneRequest.html +328 -0
- data/html/MIDI/Utils.html +320 -0
- data/html/README_rdoc.html +751 -0
- data/html/TODO_rdoc.html +200 -0
- data/html/created.rid +14 -0
- data/html/images/add.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 +750 -0
- data/html/js/darkfish.js +153 -0
- data/html/js/jquery.js +18 -0
- data/html/js/navigation.js +142 -0
- data/html/js/search.js +94 -0
- data/html/js/search_index.js +1 -0
- data/html/js/searcher.js +228 -0
- data/html/rdoc.css +543 -0
- data/html/table_of_contents.html +652 -0
- data/lib/midilib/info.rb +1 -1
- data/lib/midilib/io/seqreader.rb +1 -1
- data/lib/midilib/sequence.rb +7 -0
- data/test/test_sequence.rb +11 -0
- metadata +80 -3
@@ -0,0 +1,769 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class MIDI::Track - midilib</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../index.html">Home</a>
|
28
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
<div id="file-metadata">
|
47
|
+
<nav id="file-list-section" class="section">
|
48
|
+
<h3 class="section-header">Defined In</h3>
|
49
|
+
<ul>
|
50
|
+
<li>lib/midilib/track.rb
|
51
|
+
</ul>
|
52
|
+
</nav>
|
53
|
+
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div id="class-metadata">
|
58
|
+
|
59
|
+
<nav id="parent-class-section" class="section">
|
60
|
+
<h3 class="section-header">Parent</h3>
|
61
|
+
|
62
|
+
<p class="link">Object
|
63
|
+
|
64
|
+
</nav>
|
65
|
+
|
66
|
+
<!-- Included Modules -->
|
67
|
+
<nav id="includes-section" class="section">
|
68
|
+
<h3 class="section-header">Included Modules</h3>
|
69
|
+
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
|
73
|
+
<li><span class="include">Enumerable</span>
|
74
|
+
|
75
|
+
|
76
|
+
</ul>
|
77
|
+
</nav>
|
78
|
+
|
79
|
+
<!-- Method Quickref -->
|
80
|
+
<nav id="method-list-section" class="section">
|
81
|
+
<h3 class="section-header">Methods</h3>
|
82
|
+
|
83
|
+
<ul class="link-list">
|
84
|
+
|
85
|
+
<li><a href="#method-c-new">::new</a>
|
86
|
+
|
87
|
+
<li><a href="#method-i-each">#each</a>
|
88
|
+
|
89
|
+
<li><a href="#method-i-instrument">#instrument</a>
|
90
|
+
|
91
|
+
<li><a href="#method-i-instrument-3D">#instrument=</a>
|
92
|
+
|
93
|
+
<li><a href="#method-i-merge">#merge</a>
|
94
|
+
|
95
|
+
<li><a href="#method-i-merge_event_lists">#merge_event_lists</a>
|
96
|
+
|
97
|
+
<li><a href="#method-i-name">#name</a>
|
98
|
+
|
99
|
+
<li><a href="#method-i-name-3D">#name=</a>
|
100
|
+
|
101
|
+
<li><a href="#method-i-quantize">#quantize</a>
|
102
|
+
|
103
|
+
<li><a href="#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
104
|
+
|
105
|
+
<li><a href="#method-i-recalc_times">#recalc_times</a>
|
106
|
+
|
107
|
+
<li><a href="#method-i-sort">#sort</a>
|
108
|
+
|
109
|
+
</ul>
|
110
|
+
</nav>
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<div id="project-metadata">
|
115
|
+
<nav id="fileindex-section" class="section project-section">
|
116
|
+
<h3 class="section-header">Pages</h3>
|
117
|
+
|
118
|
+
<ul>
|
119
|
+
|
120
|
+
<li class="file"><a href="../README_rdoc.html">README</a>
|
121
|
+
|
122
|
+
<li class="file"><a href="../TODO_rdoc.html">TODO</a>
|
123
|
+
|
124
|
+
</ul>
|
125
|
+
</nav>
|
126
|
+
|
127
|
+
<nav id="classindex-section" class="section project-section">
|
128
|
+
<h3 class="section-header">Class and Module Index</h3>
|
129
|
+
|
130
|
+
<ul class="link-list">
|
131
|
+
|
132
|
+
<li><a href="../MIDI.html">MIDI</a>
|
133
|
+
|
134
|
+
<li><a href="../MIDI/ActiveSense.html">MIDI::ActiveSense</a>
|
135
|
+
|
136
|
+
<li><a href="../MIDI/ChannelEvent.html">MIDI::ChannelEvent</a>
|
137
|
+
|
138
|
+
<li><a href="../MIDI/ChannelPressure.html">MIDI::ChannelPressure</a>
|
139
|
+
|
140
|
+
<li><a href="../MIDI/Clock.html">MIDI::Clock</a>
|
141
|
+
|
142
|
+
<li><a href="../MIDI/Continue.html">MIDI::Continue</a>
|
143
|
+
|
144
|
+
<li><a href="../MIDI/Controller.html">MIDI::Controller</a>
|
145
|
+
|
146
|
+
<li><a href="../MIDI/Event.html">MIDI::Event</a>
|
147
|
+
|
148
|
+
<li><a href="../MIDI/IO.html">MIDI::IO</a>
|
149
|
+
|
150
|
+
<li><a href="../MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a>
|
151
|
+
|
152
|
+
<li><a href="../MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a>
|
153
|
+
|
154
|
+
<li><a href="../MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a>
|
155
|
+
|
156
|
+
<li><a href="../MIDI/KeySig.html">MIDI::KeySig</a>
|
157
|
+
|
158
|
+
<li><a href="../MIDI/MIDI.html">MIDI::MIDI</a>
|
159
|
+
|
160
|
+
<li><a href="../MIDI/MIDI/MIDI.html">MIDI::MIDI::MIDI</a>
|
161
|
+
|
162
|
+
<li><a href="../MIDI/MIDI/MIDI/Array.html">MIDI::MIDI::MIDI::Array</a>
|
163
|
+
|
164
|
+
<li><a href="../MIDI/Marker.html">MIDI::Marker</a>
|
165
|
+
|
166
|
+
<li><a href="../MIDI/Measure.html">MIDI::Measure</a>
|
167
|
+
|
168
|
+
<li><a href="../MIDI/Measures.html">MIDI::Measures</a>
|
169
|
+
|
170
|
+
<li><a href="../MIDI/MetaEvent.html">MIDI::MetaEvent</a>
|
171
|
+
|
172
|
+
<li><a href="../MIDI/NoteEvent.html">MIDI::NoteEvent</a>
|
173
|
+
|
174
|
+
<li><a href="../MIDI/NoteOff.html">MIDI::NoteOff</a>
|
175
|
+
|
176
|
+
<li><a href="../MIDI/NoteOff.html">MIDI::NoteOffEvent</a>
|
177
|
+
|
178
|
+
<li><a href="../MIDI/NoteOn.html">MIDI::NoteOn</a>
|
179
|
+
|
180
|
+
<li><a href="../MIDI/NoteOn.html">MIDI::NoteOnEvent</a>
|
181
|
+
|
182
|
+
<li><a href="../MIDI/PitchBend.html">MIDI::PitchBend</a>
|
183
|
+
|
184
|
+
<li><a href="../MIDI/PolyPressure.html">MIDI::PolyPressure</a>
|
185
|
+
|
186
|
+
<li><a href="../MIDI/ProgramChange.html">MIDI::ProgramChange</a>
|
187
|
+
|
188
|
+
<li><a href="../MIDI/Realtime.html">MIDI::Realtime</a>
|
189
|
+
|
190
|
+
<li><a href="../MIDI/Sequence.html">MIDI::Sequence</a>
|
191
|
+
|
192
|
+
<li><a href="../MIDI/SongPointer.html">MIDI::SongPointer</a>
|
193
|
+
|
194
|
+
<li><a href="../MIDI/SongSelect.html">MIDI::SongSelect</a>
|
195
|
+
|
196
|
+
<li><a href="../MIDI/Start.html">MIDI::Start</a>
|
197
|
+
|
198
|
+
<li><a href="../MIDI/Stop.html">MIDI::Stop</a>
|
199
|
+
|
200
|
+
<li><a href="../MIDI/SystemCommon.html">MIDI::SystemCommon</a>
|
201
|
+
|
202
|
+
<li><a href="../MIDI/SystemExclusive.html">MIDI::SystemExclusive</a>
|
203
|
+
|
204
|
+
<li><a href="../MIDI/SystemReset.html">MIDI::SystemReset</a>
|
205
|
+
|
206
|
+
<li><a href="../MIDI/Tempo.html">MIDI::Tempo</a>
|
207
|
+
|
208
|
+
<li><a href="../MIDI/TimeSig.html">MIDI::TimeSig</a>
|
209
|
+
|
210
|
+
<li><a href="../MIDI/Track.html">MIDI::Track</a>
|
211
|
+
|
212
|
+
<li><a href="../MIDI/TuneRequest.html">MIDI::TuneRequest</a>
|
213
|
+
|
214
|
+
<li><a href="../MIDI/Utils.html">MIDI::Utils</a>
|
215
|
+
|
216
|
+
<li><a href="../IO.html">IO</a>
|
217
|
+
|
218
|
+
</ul>
|
219
|
+
</nav>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
</nav>
|
223
|
+
|
224
|
+
<div id="documentation">
|
225
|
+
<h1 class="class">class MIDI::Track</h1>
|
226
|
+
|
227
|
+
<div id="description" class="description">
|
228
|
+
|
229
|
+
<p>A <a href="Track.html">Track</a> is a list of events.</p>
|
230
|
+
|
231
|
+
<p>When you modify the <code>events</code> array, make sure to call <a
|
232
|
+
href="Track.html#method-i-recalc_times">#recalc_times</a> so each <a
|
233
|
+
href="Event.html">Event</a> gets its <code>time_from_start</code>
|
234
|
+
recalculated.</p>
|
235
|
+
|
236
|
+
<p>A <a href="Track.html">Track</a> also holds a bitmask that specifies the
|
237
|
+
channels used by the track. This bitmask is set when the track is read from
|
238
|
+
the <a href="MIDI.html">MIDI</a> file by an <a
|
239
|
+
href="IO/SeqReader.html">IO::SeqReader</a> but is <em>not</em> kept up to
|
240
|
+
date by any other methods.</p>
|
241
|
+
|
242
|
+
</div><!-- description -->
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
<!-- Constants -->
|
254
|
+
<section id="constants-list" class="section">
|
255
|
+
<h3 class="section-header">Constants</h3>
|
256
|
+
<dl>
|
257
|
+
|
258
|
+
<dt id="UNNAMED">UNNAMED
|
259
|
+
|
260
|
+
<dd class="description">
|
261
|
+
|
262
|
+
|
263
|
+
</dl>
|
264
|
+
</section>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
<!-- Attributes -->
|
269
|
+
<section id="attribute-method-details" class="method-section section">
|
270
|
+
<h3 class="section-header">Attributes</h3>
|
271
|
+
|
272
|
+
|
273
|
+
<div id="attribute-i-channels_used" class="method-detail">
|
274
|
+
<div class="method-heading attribute-method-heading">
|
275
|
+
<span class="method-name">channels_used</span><span
|
276
|
+
class="attribute-access-type">[RW]</span>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
<div class="method-description">
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
</div>
|
284
|
+
</div>
|
285
|
+
|
286
|
+
<div id="attribute-i-events" class="method-detail">
|
287
|
+
<div class="method-heading attribute-method-heading">
|
288
|
+
<span class="method-name">events</span><span
|
289
|
+
class="attribute-access-type">[RW]</span>
|
290
|
+
</div>
|
291
|
+
|
292
|
+
<div class="method-description">
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
</div>
|
297
|
+
</div>
|
298
|
+
|
299
|
+
<div id="attribute-i-sequence" class="method-detail">
|
300
|
+
<div class="method-heading attribute-method-heading">
|
301
|
+
<span class="method-name">sequence</span><span
|
302
|
+
class="attribute-access-type">[R]</span>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
<div class="method-description">
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
</div>
|
310
|
+
</div>
|
311
|
+
|
312
|
+
</section><!-- attribute-method-details -->
|
313
|
+
|
314
|
+
|
315
|
+
<!-- Methods -->
|
316
|
+
|
317
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
318
|
+
<h3 class="section-header">Public Class Methods</h3>
|
319
|
+
|
320
|
+
|
321
|
+
<div id="method-c-new" class="method-detail ">
|
322
|
+
|
323
|
+
<div class="method-heading">
|
324
|
+
<span class="method-name">new</span><span
|
325
|
+
class="method-args">(sequence)</span>
|
326
|
+
<span class="method-click-advice">click to toggle source</span>
|
327
|
+
</div>
|
328
|
+
|
329
|
+
|
330
|
+
<div class="method-description">
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
<div class="method-source-code" id="new-source">
|
337
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 65</span>
|
338
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">sequence</span>)
|
339
|
+
<span class="ruby-ivar">@sequence</span> = <span class="ruby-identifier">sequence</span>
|
340
|
+
<span class="ruby-ivar">@events</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>()
|
341
|
+
|
342
|
+
<span class="ruby-comment"># Bitmask of all channels used. Set when track is read in from</span>
|
343
|
+
<span class="ruby-comment"># a MIDI file.</span>
|
344
|
+
<span class="ruby-ivar">@channels_used</span> = <span class="ruby-value">0</span>
|
345
|
+
<span class="ruby-keyword">end</span></pre>
|
346
|
+
</div><!-- new-source -->
|
347
|
+
|
348
|
+
</div>
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
</div><!-- new-method -->
|
354
|
+
|
355
|
+
|
356
|
+
</section><!-- public-class-method-details -->
|
357
|
+
|
358
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
359
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
360
|
+
|
361
|
+
|
362
|
+
<div id="method-i-each" class="method-detail ">
|
363
|
+
|
364
|
+
<div class="method-heading">
|
365
|
+
<span class="method-name">each</span><span
|
366
|
+
class="method-args">() { |event| ... }</span>
|
367
|
+
<span class="method-click-advice">click to toggle source</span>
|
368
|
+
</div>
|
369
|
+
|
370
|
+
|
371
|
+
<div class="method-description">
|
372
|
+
|
373
|
+
<p>Iterate over events.</p>
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
<div class="method-source-code" id="each-source">
|
378
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 171</span>
|
379
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">each</span> <span class="ruby-comment"># :yields: event</span>
|
380
|
+
<span class="ruby-ivar">@events</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">event</span> }
|
381
|
+
<span class="ruby-keyword">end</span></pre>
|
382
|
+
</div><!-- each-source -->
|
383
|
+
|
384
|
+
</div>
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
</div><!-- each-method -->
|
390
|
+
|
391
|
+
|
392
|
+
<div id="method-i-instrument" class="method-detail ">
|
393
|
+
|
394
|
+
<div class="method-heading">
|
395
|
+
<span class="method-name">instrument</span><span
|
396
|
+
class="method-args">()</span>
|
397
|
+
<span class="method-click-advice">click to toggle source</span>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
|
401
|
+
<div class="method-description">
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
<div class="method-source-code" id="instrument-source">
|
408
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 95</span>
|
409
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">instrument</span>
|
410
|
+
<span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">bytes_as_str</span>(<span class="ruby-ivar">@instrument</span>)
|
411
|
+
<span class="ruby-keyword">end</span></pre>
|
412
|
+
</div><!-- instrument-source -->
|
413
|
+
|
414
|
+
</div>
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
</div><!-- instrument-method -->
|
420
|
+
|
421
|
+
|
422
|
+
<div id="method-i-instrument-3D" class="method-detail ">
|
423
|
+
|
424
|
+
<div class="method-heading">
|
425
|
+
<span class="method-name">instrument=</span><span
|
426
|
+
class="method-args">(str_or_bytes)</span>
|
427
|
+
<span class="method-click-advice">click to toggle source</span>
|
428
|
+
</div>
|
429
|
+
|
430
|
+
|
431
|
+
<div class="method-description">
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
<div class="method-source-code" id="instrument-3D-source">
|
438
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 99</span>
|
439
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">instrument=</span>(<span class="ruby-identifier">str_or_bytes</span>)
|
440
|
+
<span class="ruby-ivar">@instrument</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">str_or_bytes</span>
|
441
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
|
442
|
+
<span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">str_as_bytes</span>(<span class="ruby-identifier">str_or_bytes</span>)
|
443
|
+
<span class="ruby-keyword">else</span>
|
444
|
+
<span class="ruby-identifier">str_or_bytes</span>
|
445
|
+
<span class="ruby-keyword">end</span>
|
446
|
+
<span class="ruby-keyword">end</span></pre>
|
447
|
+
</div><!-- instrument-3D-source -->
|
448
|
+
|
449
|
+
</div>
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
</div><!-- instrument-3D-method -->
|
455
|
+
|
456
|
+
|
457
|
+
<div id="method-i-merge" class="method-detail ">
|
458
|
+
|
459
|
+
<div class="method-heading">
|
460
|
+
<span class="method-name">merge</span><span
|
461
|
+
class="method-args">(event_list)</span>
|
462
|
+
<span class="method-click-advice">click to toggle source</span>
|
463
|
+
</div>
|
464
|
+
|
465
|
+
|
466
|
+
<div class="method-description">
|
467
|
+
|
468
|
+
<p>Merges an array of events into our event list. After merging, the events'
|
469
|
+
time_from_start values are correct so you don't need to worry about calling
|
470
|
+
recalc_times.</p>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
<div class="method-source-code" id="merge-source">
|
475
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 111</span>
|
476
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">event_list</span>)
|
477
|
+
<span class="ruby-ivar">@events</span> = <span class="ruby-identifier">merge_event_lists</span>(<span class="ruby-ivar">@events</span>, <span class="ruby-identifier">event_list</span>)
|
478
|
+
<span class="ruby-keyword">end</span></pre>
|
479
|
+
</div><!-- merge-source -->
|
480
|
+
|
481
|
+
</div>
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
</div><!-- merge-method -->
|
487
|
+
|
488
|
+
|
489
|
+
<div id="method-i-merge_event_lists" class="method-detail ">
|
490
|
+
|
491
|
+
<div class="method-heading">
|
492
|
+
<span class="method-name">merge_event_lists</span><span
|
493
|
+
class="method-args">(list1, list2)</span>
|
494
|
+
<span class="method-click-advice">click to toggle source</span>
|
495
|
+
</div>
|
496
|
+
|
497
|
+
|
498
|
+
<div class="method-description">
|
499
|
+
|
500
|
+
<p>Merges two event arrays together. Does not modify this track.</p>
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
<div class="method-source-code" id="merge_event_lists-source">
|
505
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 116</span>
|
506
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">merge_event_lists</span>(<span class="ruby-identifier">list1</span>, <span class="ruby-identifier">list2</span>)
|
507
|
+
<span class="ruby-identifier">recalc_times</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">list1</span>)
|
508
|
+
<span class="ruby-identifier">recalc_times</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">list2</span>)
|
509
|
+
<span class="ruby-identifier">list</span> = <span class="ruby-identifier">list1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">list2</span>
|
510
|
+
<span class="ruby-identifier">recalc_delta_from_times</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">list</span>)
|
511
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">list</span>
|
512
|
+
<span class="ruby-keyword">end</span></pre>
|
513
|
+
</div><!-- merge_event_lists-source -->
|
514
|
+
|
515
|
+
</div>
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
</div><!-- merge_event_lists-method -->
|
521
|
+
|
522
|
+
|
523
|
+
<div id="method-i-name" class="method-detail ">
|
524
|
+
|
525
|
+
<div class="method-heading">
|
526
|
+
<span class="method-name">name</span><span
|
527
|
+
class="method-args">()</span>
|
528
|
+
<span class="method-click-advice">click to toggle source</span>
|
529
|
+
</div>
|
530
|
+
|
531
|
+
|
532
|
+
<div class="method-description">
|
533
|
+
|
534
|
+
<p>Return track name. If there is no name, return <a
|
535
|
+
href="Track.html#UNNAMED">UNNAMED</a>.</p>
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
<div class="method-source-code" id="name-source">
|
540
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 75</span>
|
541
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">name</span>
|
542
|
+
<span class="ruby-identifier">event</span> = <span class="ruby-ivar">@events</span>.<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">|</span>
|
543
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">MetaEvent</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">meta_type</span> <span class="ruby-operator">==</span> <span class="ruby-constant">META_SEQ_NAME</span>
|
544
|
+
}
|
545
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">data_as_str</span> <span class="ruby-operator">:</span> <span class="ruby-constant">UNNAMED</span>
|
546
|
+
<span class="ruby-keyword">end</span></pre>
|
547
|
+
</div><!-- name-source -->
|
548
|
+
|
549
|
+
</div>
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
</div><!-- name-method -->
|
555
|
+
|
556
|
+
|
557
|
+
<div id="method-i-name-3D" class="method-detail ">
|
558
|
+
|
559
|
+
<div class="method-heading">
|
560
|
+
<span class="method-name">name=</span><span
|
561
|
+
class="method-args">(name)</span>
|
562
|
+
<span class="method-click-advice">click to toggle source</span>
|
563
|
+
</div>
|
564
|
+
|
565
|
+
|
566
|
+
<div class="method-description">
|
567
|
+
|
568
|
+
<p>Set track name. Replaces or creates a name meta-event.</p>
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
<div class="method-source-code" id="name-3D-source">
|
573
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 83</span>
|
574
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">name=</span>(<span class="ruby-identifier">name</span>)
|
575
|
+
<span class="ruby-identifier">event</span> = <span class="ruby-ivar">@events</span>.<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">|</span>
|
576
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">MetaEvent</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">meta_type</span> <span class="ruby-operator">==</span> <span class="ruby-constant">META_SEQ_NAME</span>
|
577
|
+
}
|
578
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">event</span>
|
579
|
+
<span class="ruby-identifier">event</span>.<span class="ruby-identifier">data</span> = <span class="ruby-identifier">name</span>
|
580
|
+
<span class="ruby-keyword">else</span>
|
581
|
+
<span class="ruby-identifier">event</span> = <span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">META_SEQ_NAME</span>, <span class="ruby-identifier">name</span>, <span class="ruby-value">0</span>)
|
582
|
+
<span class="ruby-ivar">@events</span>[<span class="ruby-value">0</span>, <span class="ruby-value">0</span>] = <span class="ruby-identifier">event</span>
|
583
|
+
<span class="ruby-keyword">end</span>
|
584
|
+
<span class="ruby-keyword">end</span></pre>
|
585
|
+
</div><!-- name-3D-source -->
|
586
|
+
|
587
|
+
</div>
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
</div><!-- name-3D-method -->
|
593
|
+
|
594
|
+
|
595
|
+
<div id="method-i-quantize" class="method-detail ">
|
596
|
+
|
597
|
+
<div class="method-heading">
|
598
|
+
<span class="method-name">quantize</span><span
|
599
|
+
class="method-args">(length_or_note)</span>
|
600
|
+
<span class="method-click-advice">click to toggle source</span>
|
601
|
+
</div>
|
602
|
+
|
603
|
+
|
604
|
+
<div class="method-description">
|
605
|
+
|
606
|
+
<p>Quantize every event. length_or_note is either a length (1 = quarter, 0.25
|
607
|
+
= sixteenth, 4 = whole note) or a note name ("sixteenth", "32nd", "8th
|
608
|
+
triplet", "dotted quarter").</p>
|
609
|
+
|
610
|
+
<p>Since each event's time_from_start is modified, we call <a
|
611
|
+
href="Track.html#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
612
|
+
after each event quantizes itself.</p>
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
<div class="method-source-code" id="quantize-source">
|
617
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 130</span>
|
618
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">quantize</span>(<span class="ruby-identifier">length_or_note</span>)
|
619
|
+
<span class="ruby-identifier">delta</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">length_or_note</span>
|
620
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
|
621
|
+
<span class="ruby-ivar">@sequence</span>.<span class="ruby-identifier">note_to_delta</span>(<span class="ruby-identifier">length_or_note</span>)
|
622
|
+
<span class="ruby-keyword">else</span>
|
623
|
+
<span class="ruby-ivar">@sequence</span>.<span class="ruby-identifier">length_to_delta</span>(<span class="ruby-identifier">length_or_note</span>.<span class="ruby-identifier">to_i</span>)
|
624
|
+
<span class="ruby-keyword">end</span>
|
625
|
+
<span class="ruby-ivar">@events</span>.<span class="ruby-identifier">each</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">quantize_to</span>(<span class="ruby-identifier">delta</span>) }
|
626
|
+
<span class="ruby-identifier">recalc_delta_from_times</span>
|
627
|
+
<span class="ruby-keyword">end</span></pre>
|
628
|
+
</div><!-- quantize-source -->
|
629
|
+
|
630
|
+
</div>
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
</div><!-- quantize-method -->
|
636
|
+
|
637
|
+
|
638
|
+
<div id="method-i-recalc_delta_from_times" class="method-detail ">
|
639
|
+
|
640
|
+
<div class="method-heading">
|
641
|
+
<span class="method-name">recalc_delta_from_times</span><span
|
642
|
+
class="method-args">(starting_at=0, list=@events)</span>
|
643
|
+
<span class="method-click-advice">click to toggle source</span>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
|
647
|
+
<div class="method-description">
|
648
|
+
|
649
|
+
<p>The opposite of <a
|
650
|
+
href="Track.html#method-i-recalc_times">#recalc_times</a>: recalculates
|
651
|
+
delta_time for each event from each event's time_from_start. This is
|
652
|
+
useful, for example, when merging two event lists. As a side-effect,
|
653
|
+
elements from starting_at are sorted by time_from_start.</p>
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
<div class="method-source-code" id="recalc_delta_from_times-source">
|
658
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 155</span>
|
659
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">recalc_delta_from_times</span>(<span class="ruby-identifier">starting_at</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">list</span>=<span class="ruby-ivar">@events</span>)
|
660
|
+
<span class="ruby-identifier">prev_time_from_start</span> = <span class="ruby-value">0</span>
|
661
|
+
<span class="ruby-comment"># We need to sort the sublist. sublist.sort! does not do what we want.</span>
|
662
|
+
<span class="ruby-comment"># We call mergesort instead of Array.sort because sort is not stable</span>
|
663
|
+
<span class="ruby-comment"># (it can mix up the order of events that have the same start time).</span>
|
664
|
+
<span class="ruby-comment"># See http://wiki.github.com/adamjmurray/cosy/midilib-notes for details.</span>
|
665
|
+
<span class="ruby-identifier">list</span>[<span class="ruby-identifier">starting_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>] = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">list</span>[<span class="ruby-identifier">starting_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>]).<span class="ruby-identifier">mergesort</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">e1</span>, <span class="ruby-identifier">e2</span> <span class="ruby-operator">|</span>
|
666
|
+
<span class="ruby-identifier">e1</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">e2</span>.<span class="ruby-identifier">time_from_start</span>
|
667
|
+
}
|
668
|
+
<span class="ruby-identifier">list</span>[<span class="ruby-identifier">starting_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">|</span>
|
669
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">delta_time</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">prev_time_from_start</span>
|
670
|
+
<span class="ruby-identifier">prev_time_from_start</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span>
|
671
|
+
}
|
672
|
+
<span class="ruby-keyword">end</span></pre>
|
673
|
+
</div><!-- recalc_delta_from_times-source -->
|
674
|
+
|
675
|
+
</div>
|
676
|
+
|
677
|
+
|
678
|
+
<div class="aliases">
|
679
|
+
Also aliased as: <a href="Track.html#method-i-sort">sort</a>
|
680
|
+
</div>
|
681
|
+
|
682
|
+
|
683
|
+
|
684
|
+
</div><!-- recalc_delta_from_times-method -->
|
685
|
+
|
686
|
+
|
687
|
+
<div id="method-i-recalc_times" class="method-detail ">
|
688
|
+
|
689
|
+
<div class="method-heading">
|
690
|
+
<span class="method-name">recalc_times</span><span
|
691
|
+
class="method-args">(starting_at=0, list=@events)</span>
|
692
|
+
<span class="method-click-advice">click to toggle source</span>
|
693
|
+
</div>
|
694
|
+
|
695
|
+
|
696
|
+
<div class="method-description">
|
697
|
+
|
698
|
+
<p>Recalculate start times for all events in <code>list</code> from
|
699
|
+
starting_at to end.</p>
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
<div class="method-source-code" id="recalc_times-source">
|
704
|
+
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 143</span>
|
705
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">recalc_times</span>(<span class="ruby-identifier">starting_at</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">list</span>=<span class="ruby-ivar">@events</span>)
|
706
|
+
<span class="ruby-identifier">t</span> = (<span class="ruby-identifier">starting_at</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">list</span>[<span class="ruby-identifier">starting_at</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>].<span class="ruby-identifier">time_from_start</span>
|
707
|
+
<span class="ruby-identifier">list</span>[<span class="ruby-identifier">starting_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">|</span>
|
708
|
+
<span class="ruby-identifier">t</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">delta_time</span>
|
709
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span> = <span class="ruby-identifier">t</span>
|
710
|
+
}
|
711
|
+
<span class="ruby-keyword">end</span></pre>
|
712
|
+
</div><!-- recalc_times-source -->
|
713
|
+
|
714
|
+
</div>
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
</div><!-- recalc_times-method -->
|
720
|
+
|
721
|
+
|
722
|
+
<div id="method-i-sort" class="method-detail method-alias">
|
723
|
+
|
724
|
+
<div class="method-heading">
|
725
|
+
<span class="method-name">sort</span><span
|
726
|
+
class="method-args">(starting_at=0, list=@events)</span>
|
727
|
+
<span class="method-click-advice">click to toggle source</span>
|
728
|
+
</div>
|
729
|
+
|
730
|
+
|
731
|
+
<div class="method-description">
|
732
|
+
|
733
|
+
<p>Sort events by their time_from_start. After sorting, <a
|
734
|
+
href="Track.html#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
735
|
+
is called to make sure that the delta times reflect the possibly new event
|
736
|
+
order.</p>
|
737
|
+
|
738
|
+
<p>Note: this method is redundant, since <a
|
739
|
+
href="Track.html#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
740
|
+
sorts the events first. This method may go away in a future release, or at
|
741
|
+
least be aliased to recalc_delta_from_times.</p>
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
</div>
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
<div class="aliases">
|
751
|
+
Alias for: <a href="Track.html#method-i-recalc_delta_from_times">recalc_delta_from_times</a>
|
752
|
+
</div>
|
753
|
+
|
754
|
+
</div><!-- sort-method -->
|
755
|
+
|
756
|
+
|
757
|
+
</section><!-- public-instance-method-details -->
|
758
|
+
|
759
|
+
</section><!-- 5Buntitled-5D -->
|
760
|
+
|
761
|
+
</div><!-- documentation -->
|
762
|
+
|
763
|
+
|
764
|
+
<footer id="validator-badges">
|
765
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
766
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
767
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
768
|
+
</footer>
|
769
|
+
|