midilib 2.0.5 → 3.0.1
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.
- 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/MIDI/Track.html
DELETED
|
@@ -1,695 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
|
|
7
|
-
<title>class MIDI::Track - 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="class">
|
|
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
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
37
|
-
<form action="#" method="get" accept-charset="utf-8">
|
|
38
|
-
<div id="search-field-wrapper">
|
|
39
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
|
40
|
-
aria-autocomplete="list" aria-controls="search-results"
|
|
41
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
42
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
<ul id="search-results" aria-label="Search Results"
|
|
46
|
-
aria-busy="false" aria-expanded="false"
|
|
47
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
|
48
|
-
</form>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<div id="class-metadata">
|
|
56
|
-
|
|
57
|
-
<div id="parent-class-section" class="nav-section">
|
|
58
|
-
<h3>Parent</h3>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<p class="link">Object
|
|
62
|
-
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<div id="includes-section" class="nav-section">
|
|
66
|
-
<h3>Included Modules</h3>
|
|
67
|
-
|
|
68
|
-
<ul class="link-list">
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<li><span class="include">Enumerable</span>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</ul>
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<!-- Method Quickref -->
|
|
79
|
-
<div id="method-list-section" class="nav-section">
|
|
80
|
-
<h3>Methods</h3>
|
|
81
|
-
|
|
82
|
-
<ul class="link-list" role="directory">
|
|
83
|
-
|
|
84
|
-
<li ><a href="#method-c-new">::new</a>
|
|
85
|
-
|
|
86
|
-
<li ><a href="#method-i-each">#each</a>
|
|
87
|
-
|
|
88
|
-
<li ><a href="#method-i-instrument">#instrument</a>
|
|
89
|
-
|
|
90
|
-
<li ><a href="#method-i-instrument-3D">#instrument=</a>
|
|
91
|
-
|
|
92
|
-
<li ><a href="#method-i-merge">#merge</a>
|
|
93
|
-
|
|
94
|
-
<li ><a href="#method-i-merge_event_lists">#merge_event_lists</a>
|
|
95
|
-
|
|
96
|
-
<li ><a href="#method-i-name">#name</a>
|
|
97
|
-
|
|
98
|
-
<li ><a href="#method-i-name-3D">#name=</a>
|
|
99
|
-
|
|
100
|
-
<li ><a href="#method-i-quantize">#quantize</a>
|
|
101
|
-
|
|
102
|
-
<li ><a href="#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
|
103
|
-
|
|
104
|
-
<li ><a href="#method-i-recalc_times">#recalc_times</a>
|
|
105
|
-
|
|
106
|
-
<li ><a href="#method-i-sort">#sort</a>
|
|
107
|
-
|
|
108
|
-
</ul>
|
|
109
|
-
</div>
|
|
110
|
-
|
|
111
|
-
</div>
|
|
112
|
-
</nav>
|
|
113
|
-
|
|
114
|
-
<main role="main" aria-labelledby="class-MIDI::Track">
|
|
115
|
-
<h1 id="class-MIDI::Track" class="class">
|
|
116
|
-
class MIDI::Track
|
|
117
|
-
</h1>
|
|
118
|
-
|
|
119
|
-
<section class="description">
|
|
120
|
-
|
|
121
|
-
<p>A <a href="Track.html">Track</a> is a list of events.</p>
|
|
122
|
-
|
|
123
|
-
<p>When you modify the <code>events</code> array, make sure to call <a
|
|
124
|
-
href="Track.html#method-i-recalc_times">#recalc_times</a> so each <a
|
|
125
|
-
href="Event.html">Event</a> gets its <code>time_from_start</code>
|
|
126
|
-
recalculated.</p>
|
|
127
|
-
|
|
128
|
-
<p>A <a href="Track.html">Track</a> also holds a bitmask that specifies the
|
|
129
|
-
channels used by the track. This bitmask is set when the track is read from
|
|
130
|
-
the <a href="MIDI.html">MIDI</a> file by an <a
|
|
131
|
-
href="IO/SeqReader.html">IO::SeqReader</a> but is <em>not</em> kept up to
|
|
132
|
-
date by any other methods.</p>
|
|
133
|
-
|
|
134
|
-
</section>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<section class="constants-list">
|
|
146
|
-
<header>
|
|
147
|
-
<h3>Constants</h3>
|
|
148
|
-
</header>
|
|
149
|
-
<dl>
|
|
150
|
-
|
|
151
|
-
<dt id="UNNAMED">UNNAMED
|
|
152
|
-
|
|
153
|
-
<dd>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
</dl>
|
|
157
|
-
</section>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
<section class="attribute-method-details" class="method-section">
|
|
162
|
-
<header>
|
|
163
|
-
<h3>Attributes</h3>
|
|
164
|
-
</header>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<div id="attribute-i-channels_used" class="method-detail">
|
|
168
|
-
<div class="method-heading attribute-method-heading">
|
|
169
|
-
<span class="method-name">channels_used</span><span
|
|
170
|
-
class="attribute-access-type">[RW]</span>
|
|
171
|
-
</div>
|
|
172
|
-
|
|
173
|
-
<div class="method-description">
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
</div>
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
<div id="attribute-i-events" class="method-detail">
|
|
181
|
-
<div class="method-heading attribute-method-heading">
|
|
182
|
-
<span class="method-name">events</span><span
|
|
183
|
-
class="attribute-access-type">[RW]</span>
|
|
184
|
-
</div>
|
|
185
|
-
|
|
186
|
-
<div class="method-description">
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
</div>
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
<div id="attribute-i-sequence" class="method-detail">
|
|
194
|
-
<div class="method-heading attribute-method-heading">
|
|
195
|
-
<span class="method-name">sequence</span><span
|
|
196
|
-
class="attribute-access-type">[R]</span>
|
|
197
|
-
</div>
|
|
198
|
-
|
|
199
|
-
<div class="method-description">
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
|
|
206
|
-
</section>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
|
211
|
-
<header>
|
|
212
|
-
<h3>Public Class Methods</h3>
|
|
213
|
-
</header>
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
<div id="method-c-new" class="method-detail ">
|
|
217
|
-
|
|
218
|
-
<div class="method-heading">
|
|
219
|
-
<span class="method-name">new</span><span
|
|
220
|
-
class="method-args">(sequence)</span>
|
|
221
|
-
|
|
222
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
223
|
-
|
|
224
|
-
</div>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
<div class="method-description">
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
<div class="method-source-code" id="new-source">
|
|
235
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 63</span>
|
|
236
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">sequence</span>)
|
|
237
|
-
<span class="ruby-ivar">@sequence</span> = <span class="ruby-identifier">sequence</span>
|
|
238
|
-
<span class="ruby-ivar">@events</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>()
|
|
239
|
-
|
|
240
|
-
<span class="ruby-comment"># Bitmask of all channels used. Set when track is read in from</span>
|
|
241
|
-
<span class="ruby-comment"># a MIDI file.</span>
|
|
242
|
-
<span class="ruby-ivar">@channels_used</span> = <span class="ruby-value">0</span>
|
|
243
|
-
<span class="ruby-keyword">end</span></pre>
|
|
244
|
-
</div>
|
|
245
|
-
|
|
246
|
-
</div>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
</div>
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
</section>
|
|
255
|
-
|
|
256
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
257
|
-
<header>
|
|
258
|
-
<h3>Public Instance Methods</h3>
|
|
259
|
-
</header>
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
<div id="method-i-each" class="method-detail ">
|
|
263
|
-
|
|
264
|
-
<div class="method-heading">
|
|
265
|
-
<span class="method-name">each</span><span
|
|
266
|
-
class="method-args">() { |event| ... }</span>
|
|
267
|
-
|
|
268
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
269
|
-
|
|
270
|
-
</div>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
<div class="method-description">
|
|
274
|
-
|
|
275
|
-
<p>Iterate over events.</p>
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
<div class="method-source-code" id="each-source">
|
|
281
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 165</span>
|
|
282
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">each</span> <span class="ruby-comment"># :yields: event</span>
|
|
283
|
-
<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> }
|
|
284
|
-
<span class="ruby-keyword">end</span></pre>
|
|
285
|
-
</div>
|
|
286
|
-
|
|
287
|
-
</div>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
</div>
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
<div id="method-i-instrument" class="method-detail ">
|
|
296
|
-
|
|
297
|
-
<div class="method-heading">
|
|
298
|
-
<span class="method-name">instrument</span><span
|
|
299
|
-
class="method-args">()</span>
|
|
300
|
-
|
|
301
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
302
|
-
|
|
303
|
-
</div>
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
<div class="method-description">
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
<div class="method-source-code" id="instrument-source">
|
|
314
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 89</span>
|
|
315
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">instrument</span>
|
|
316
|
-
<span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">bytes_as_str</span>(<span class="ruby-ivar">@instrument</span>)
|
|
317
|
-
<span class="ruby-keyword">end</span></pre>
|
|
318
|
-
</div>
|
|
319
|
-
|
|
320
|
-
</div>
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
</div>
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
<div id="method-i-instrument-3D" class="method-detail ">
|
|
329
|
-
|
|
330
|
-
<div class="method-heading">
|
|
331
|
-
<span class="method-name">instrument=</span><span
|
|
332
|
-
class="method-args">(str_or_bytes)</span>
|
|
333
|
-
|
|
334
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
335
|
-
|
|
336
|
-
</div>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
<div class="method-description">
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
<div class="method-source-code" id="instrument-3D-source">
|
|
347
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 93</span>
|
|
348
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">instrument=</span>(<span class="ruby-identifier">str_or_bytes</span>)
|
|
349
|
-
<span class="ruby-ivar">@instrument</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">str_or_bytes</span>
|
|
350
|
-
<span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
|
|
351
|
-
<span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">str_as_bytes</span>(<span class="ruby-identifier">str_or_bytes</span>)
|
|
352
|
-
<span class="ruby-keyword">else</span>
|
|
353
|
-
<span class="ruby-identifier">str_or_bytes</span>
|
|
354
|
-
<span class="ruby-keyword">end</span>
|
|
355
|
-
<span class="ruby-keyword">end</span></pre>
|
|
356
|
-
</div>
|
|
357
|
-
|
|
358
|
-
</div>
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
</div>
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
<div id="method-i-merge" class="method-detail ">
|
|
367
|
-
|
|
368
|
-
<div class="method-heading">
|
|
369
|
-
<span class="method-name">merge</span><span
|
|
370
|
-
class="method-args">(event_list)</span>
|
|
371
|
-
|
|
372
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
373
|
-
|
|
374
|
-
</div>
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
<div class="method-description">
|
|
378
|
-
|
|
379
|
-
<p>Merges an array of events into our event list. After merging, the
|
|
380
|
-
events' time_from_start values are correct so you don't need to
|
|
381
|
-
worry about calling recalc_times.</p>
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
<div class="method-source-code" id="merge-source">
|
|
387
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 105</span>
|
|
388
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">event_list</span>)
|
|
389
|
-
<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>)
|
|
390
|
-
<span class="ruby-keyword">end</span></pre>
|
|
391
|
-
</div>
|
|
392
|
-
|
|
393
|
-
</div>
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
</div>
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
<div id="method-i-merge_event_lists" class="method-detail ">
|
|
402
|
-
|
|
403
|
-
<div class="method-heading">
|
|
404
|
-
<span class="method-name">merge_event_lists</span><span
|
|
405
|
-
class="method-args">(list1, list2)</span>
|
|
406
|
-
|
|
407
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
408
|
-
|
|
409
|
-
</div>
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
<div class="method-description">
|
|
413
|
-
|
|
414
|
-
<p>Merges two event arrays together. Does not modify this track.</p>
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
<div class="method-source-code" id="merge_event_lists-source">
|
|
420
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 110</span>
|
|
421
|
-
<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>)
|
|
422
|
-
<span class="ruby-identifier">recalc_times</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">list1</span>)
|
|
423
|
-
<span class="ruby-identifier">recalc_times</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">list2</span>)
|
|
424
|
-
<span class="ruby-identifier">list</span> = <span class="ruby-identifier">list1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">list2</span>
|
|
425
|
-
<span class="ruby-identifier">recalc_delta_from_times</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">list</span>)
|
|
426
|
-
<span class="ruby-keyword">return</span> <span class="ruby-identifier">list</span>
|
|
427
|
-
<span class="ruby-keyword">end</span></pre>
|
|
428
|
-
</div>
|
|
429
|
-
|
|
430
|
-
</div>
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
</div>
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
<div id="method-i-name" class="method-detail ">
|
|
439
|
-
|
|
440
|
-
<div class="method-heading">
|
|
441
|
-
<span class="method-name">name</span><span
|
|
442
|
-
class="method-args">()</span>
|
|
443
|
-
|
|
444
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
445
|
-
|
|
446
|
-
</div>
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
<div class="method-description">
|
|
450
|
-
|
|
451
|
-
<p>Return track name. If there is no name, return <a
|
|
452
|
-
href="Track.html#UNNAMED">UNNAMED</a>.</p>
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
<div class="method-source-code" id="name-source">
|
|
458
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 73</span>
|
|
459
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">name</span>
|
|
460
|
-
<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> <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> }
|
|
461
|
-
<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>
|
|
462
|
-
<span class="ruby-keyword">end</span></pre>
|
|
463
|
-
</div>
|
|
464
|
-
|
|
465
|
-
</div>
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
</div>
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
<div id="method-i-name-3D" class="method-detail ">
|
|
474
|
-
|
|
475
|
-
<div class="method-heading">
|
|
476
|
-
<span class="method-name">name=</span><span
|
|
477
|
-
class="method-args">(name)</span>
|
|
478
|
-
|
|
479
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
480
|
-
|
|
481
|
-
</div>
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
<div class="method-description">
|
|
485
|
-
|
|
486
|
-
<p>Set track name. Replaces or creates a name meta-event.</p>
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
<div class="method-source-code" id="name-3D-source">
|
|
492
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 79</span>
|
|
493
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">name=</span>(<span class="ruby-identifier">name</span>)
|
|
494
|
-
<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> <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> }
|
|
495
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">event</span>
|
|
496
|
-
<span class="ruby-identifier">event</span>.<span class="ruby-identifier">data</span> = <span class="ruby-identifier">name</span>
|
|
497
|
-
<span class="ruby-keyword">else</span>
|
|
498
|
-
<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>)
|
|
499
|
-
<span class="ruby-ivar">@events</span>[<span class="ruby-value">0</span>, <span class="ruby-value">0</span>] = <span class="ruby-identifier">event</span>
|
|
500
|
-
<span class="ruby-keyword">end</span>
|
|
501
|
-
<span class="ruby-keyword">end</span></pre>
|
|
502
|
-
</div>
|
|
503
|
-
|
|
504
|
-
</div>
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
</div>
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
<div id="method-i-quantize" class="method-detail ">
|
|
513
|
-
|
|
514
|
-
<div class="method-heading">
|
|
515
|
-
<span class="method-name">quantize</span><span
|
|
516
|
-
class="method-args">(length_or_note)</span>
|
|
517
|
-
|
|
518
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
519
|
-
|
|
520
|
-
</div>
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
<div class="method-description">
|
|
524
|
-
|
|
525
|
-
<p>Quantize every event. length_or_note is either a length (1 = quarter, 0.25
|
|
526
|
-
= sixteenth, 4 = whole note) or a note name (“sixteenth”, “32nd”, “8th
|
|
527
|
-
triplet”, “dotted quarter”).</p>
|
|
528
|
-
|
|
529
|
-
<p>Since each event's time_from_start is modified, we call <a
|
|
530
|
-
href="Track.html#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
|
531
|
-
after each event quantizes itself.</p>
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
<div class="method-source-code" id="quantize-source">
|
|
537
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 124</span>
|
|
538
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">quantize</span>(<span class="ruby-identifier">length_or_note</span>)
|
|
539
|
-
<span class="ruby-identifier">delta</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">length_or_note</span>
|
|
540
|
-
<span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
|
|
541
|
-
<span class="ruby-ivar">@sequence</span>.<span class="ruby-identifier">note_to_delta</span>(<span class="ruby-identifier">length_or_note</span>)
|
|
542
|
-
<span class="ruby-keyword">else</span>
|
|
543
|
-
<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>)
|
|
544
|
-
<span class="ruby-keyword">end</span>
|
|
545
|
-
<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>) }
|
|
546
|
-
<span class="ruby-identifier">recalc_delta_from_times</span>
|
|
547
|
-
<span class="ruby-keyword">end</span></pre>
|
|
548
|
-
</div>
|
|
549
|
-
|
|
550
|
-
</div>
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
</div>
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
<div id="method-i-recalc_delta_from_times" class="method-detail ">
|
|
559
|
-
|
|
560
|
-
<div class="method-heading">
|
|
561
|
-
<span class="method-name">recalc_delta_from_times</span><span
|
|
562
|
-
class="method-args">(starting_at=0, list=@events)</span>
|
|
563
|
-
|
|
564
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
565
|
-
|
|
566
|
-
</div>
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
<div class="method-description">
|
|
570
|
-
|
|
571
|
-
<p>The opposite of <a
|
|
572
|
-
href="Track.html#method-i-recalc_times">#recalc_times</a>: recalculates
|
|
573
|
-
delta_time for each event from each event's time_from_start. This is
|
|
574
|
-
useful, for example, when merging two event lists. As a side-effect,
|
|
575
|
-
elements from starting_at are sorted by time_from_start.</p>
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
<div class="method-source-code" id="recalc_delta_from_times-source">
|
|
581
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 149</span>
|
|
582
|
-
<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>)
|
|
583
|
-
<span class="ruby-identifier">prev_time_from_start</span> = <span class="ruby-value">0</span>
|
|
584
|
-
<span class="ruby-comment"># We need to sort the sublist. sublist.sort! does not do what we want.</span>
|
|
585
|
-
<span class="ruby-comment"># We call mergesort instead of Array.sort because sort is not stable</span>
|
|
586
|
-
<span class="ruby-comment"># (it can mix up the order of events that have the same start time).</span>
|
|
587
|
-
<span class="ruby-comment"># See http://wiki.github.com/adamjmurray/cosy/midilib-notes for details.</span>
|
|
588
|
-
<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-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e1</span>, <span class="ruby-identifier">e2</span><span class="ruby-operator">|</span>
|
|
589
|
-
<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>
|
|
590
|
-
<span class="ruby-keyword">end</span>
|
|
591
|
-
<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-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
|
592
|
-
<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>
|
|
593
|
-
<span class="ruby-identifier">prev_time_from_start</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span>
|
|
594
|
-
<span class="ruby-keyword">end</span>
|
|
595
|
-
<span class="ruby-keyword">end</span></pre>
|
|
596
|
-
</div>
|
|
597
|
-
|
|
598
|
-
</div>
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
<div class="aliases">
|
|
602
|
-
Also aliased as: <a href="Track.html#method-i-sort">sort</a>
|
|
603
|
-
</div>
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
</div>
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
<div id="method-i-recalc_times" class="method-detail ">
|
|
611
|
-
|
|
612
|
-
<div class="method-heading">
|
|
613
|
-
<span class="method-name">recalc_times</span><span
|
|
614
|
-
class="method-args">(starting_at=0, list=@events)</span>
|
|
615
|
-
|
|
616
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
617
|
-
|
|
618
|
-
</div>
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
<div class="method-description">
|
|
622
|
-
|
|
623
|
-
<p>Recalculate start times for all events in <code>list</code> from
|
|
624
|
-
starting_at to end.</p>
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
<div class="method-source-code" id="recalc_times-source">
|
|
630
|
-
<pre><span class="ruby-comment"># File lib/midilib/track.rb, line 137</span>
|
|
631
|
-
<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>)
|
|
632
|
-
<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>
|
|
633
|
-
<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-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
|
634
|
-
<span class="ruby-identifier">t</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">delta_time</span>
|
|
635
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span> = <span class="ruby-identifier">t</span>
|
|
636
|
-
<span class="ruby-keyword">end</span>
|
|
637
|
-
<span class="ruby-keyword">end</span></pre>
|
|
638
|
-
</div>
|
|
639
|
-
|
|
640
|
-
</div>
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
</div>
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
<div id="method-i-sort" class="method-detail method-alias">
|
|
649
|
-
|
|
650
|
-
<div class="method-heading">
|
|
651
|
-
<span class="method-name">sort</span><span
|
|
652
|
-
class="method-args">(starting_at=0, list=@events)</span>
|
|
653
|
-
|
|
654
|
-
</div>
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
<div class="method-description">
|
|
658
|
-
|
|
659
|
-
<p>Sort events by their time_from_start. After sorting, <a
|
|
660
|
-
href="Track.html#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
|
661
|
-
is called to make sure that the delta times reflect the possibly new event
|
|
662
|
-
order.</p>
|
|
663
|
-
|
|
664
|
-
<p>Note: this method is redundant, since <a
|
|
665
|
-
href="Track.html#method-i-recalc_delta_from_times">#recalc_delta_from_times</a>
|
|
666
|
-
sorts the events first. This method may go away in a future release, or at
|
|
667
|
-
least be aliased to recalc_delta_from_times.</p>
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
</div>
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
<div class="aliases">
|
|
678
|
-
Alias for: <a href="Track.html#method-i-recalc_delta_from_times">recalc_delta_from_times</a>
|
|
679
|
-
</div>
|
|
680
|
-
|
|
681
|
-
</div>
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
</section>
|
|
685
|
-
|
|
686
|
-
</section>
|
|
687
|
-
</main>
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
<footer id="validator-badges" role="contentinfo">
|
|
691
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
692
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
|
693
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
694
|
-
</footer>
|
|
695
|
-
|