midilib 1.2.1 → 2.0.0

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