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.
Files changed (124) hide show
  1. checksums.yaml +5 -5
  2. data/ChangeLog +2 -1
  3. data/Credits +39 -2
  4. data/README.rdoc +5 -6
  5. data/Rakefile +36 -49
  6. data/TODO.rdoc +13 -2
  7. data/examples/from_scratch.rb +1 -1
  8. data/examples/measures_mbt.rb +11 -11
  9. data/examples/print_program_changes.rb +2 -2
  10. data/examples/reader2text.rb +47 -47
  11. data/examples/seq2text.rb +1 -1
  12. data/examples/split.rb +4 -3
  13. data/examples/strings.rb +4 -4
  14. data/examples/transpose.rb +19 -20
  15. data/install.rb +21 -13
  16. data/lib/midilib/consts.rb +237 -239
  17. data/lib/midilib/event.rb +128 -100
  18. data/lib/midilib/info.rb +3 -5
  19. data/lib/midilib/io/midifile.rb +155 -182
  20. data/lib/midilib/io/seqreader.rb +80 -85
  21. data/lib/midilib/io/seqwriter.rb +93 -88
  22. data/lib/midilib/measure.rb +78 -80
  23. data/lib/midilib/mergesort.rb +39 -0
  24. data/lib/midilib/sequence.rb +40 -32
  25. data/lib/midilib/track.rb +16 -57
  26. data/lib/midilib/utils.rb +4 -7
  27. data/lib/midilib.rb +5 -5
  28. data/test/event_equality.rb +28 -30
  29. data/test/test_event.rb +9 -11
  30. data/test/test_io.rb +83 -3
  31. data/test/test_mergesort.rb +37 -0
  32. data/test/test_midifile.rb +6 -19
  33. data/test/test_sequence.rb +5 -4
  34. data/test/test_track.rb +9 -38
  35. data/test/test_varlen.rb +1 -3
  36. metadata +8 -95
  37. data/html/IO.html +0 -155
  38. data/html/MIDI/ActiveSense.html +0 -206
  39. data/html/MIDI/ChannelEvent.html +0 -231
  40. data/html/MIDI/ChannelPressure.html +0 -265
  41. data/html/MIDI/Clock.html +0 -206
  42. data/html/MIDI/Continue.html +0 -206
  43. data/html/MIDI/Controller.html +0 -280
  44. data/html/MIDI/Event.html +0 -489
  45. data/html/MIDI/IO/MIDIFile.html +0 -2024
  46. data/html/MIDI/IO/SeqReader.html +0 -904
  47. data/html/MIDI/IO/SeqWriter.html +0 -572
  48. data/html/MIDI/IO.html +0 -95
  49. data/html/MIDI/KeySig.html +0 -353
  50. data/html/MIDI/MIDI/MIDI/Array.html +0 -255
  51. data/html/MIDI/MIDI/MIDI.html +0 -95
  52. data/html/MIDI/MIDI.html +0 -95
  53. data/html/MIDI/Marker.html +0 -158
  54. data/html/MIDI/Measure.html +0 -328
  55. data/html/MIDI/Measures.html +0 -285
  56. data/html/MIDI/MetaEvent.html +0 -461
  57. data/html/MIDI/NoteEvent.html +0 -331
  58. data/html/MIDI/NoteOff.html +0 -228
  59. data/html/MIDI/NoteOn.html +0 -228
  60. data/html/MIDI/PitchBend.html +0 -266
  61. data/html/MIDI/PolyPressure.html +0 -277
  62. data/html/MIDI/ProgramChange.html +0 -265
  63. data/html/MIDI/Realtime.html +0 -242
  64. data/html/MIDI/Sequence.html +0 -896
  65. data/html/MIDI/SongPointer.html +0 -266
  66. data/html/MIDI/SongSelect.html +0 -265
  67. data/html/MIDI/Start.html +0 -206
  68. data/html/MIDI/Stop.html +0 -206
  69. data/html/MIDI/SystemCommon.html +0 -158
  70. data/html/MIDI/SystemExclusive.html +0 -268
  71. data/html/MIDI/SystemReset.html +0 -206
  72. data/html/MIDI/Tempo.html +0 -396
  73. data/html/MIDI/TimeSig.html +0 -388
  74. data/html/MIDI/Track.html +0 -695
  75. data/html/MIDI/TuneRequest.html +0 -242
  76. data/html/MIDI/Utils.html +0 -220
  77. data/html/MIDI.html +0 -547
  78. data/html/README_rdoc.html +0 -731
  79. data/html/TODO_rdoc.html +0 -125
  80. data/html/created.rid +0 -14
  81. data/html/css/fonts.css +0 -167
  82. data/html/css/rdoc.css +0 -590
  83. data/html/fonts/Lato-Light.ttf +0 -0
  84. data/html/fonts/Lato-LightItalic.ttf +0 -0
  85. data/html/fonts/Lato-Regular.ttf +0 -0
  86. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  87. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  88. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  89. data/html/images/add.png +0 -0
  90. data/html/images/arrow_up.png +0 -0
  91. data/html/images/brick.png +0 -0
  92. data/html/images/brick_link.png +0 -0
  93. data/html/images/bug.png +0 -0
  94. data/html/images/bullet_black.png +0 -0
  95. data/html/images/bullet_toggle_minus.png +0 -0
  96. data/html/images/bullet_toggle_plus.png +0 -0
  97. data/html/images/date.png +0 -0
  98. data/html/images/delete.png +0 -0
  99. data/html/images/find.png +0 -0
  100. data/html/images/loadingAnimation.gif +0 -0
  101. data/html/images/macFFBgHack.png +0 -0
  102. data/html/images/package.png +0 -0
  103. data/html/images/page_green.png +0 -0
  104. data/html/images/page_white_text.png +0 -0
  105. data/html/images/page_white_width.png +0 -0
  106. data/html/images/plugin.png +0 -0
  107. data/html/images/ruby.png +0 -0
  108. data/html/images/tag_blue.png +0 -0
  109. data/html/images/tag_green.png +0 -0
  110. data/html/images/transparent.png +0 -0
  111. data/html/images/wrench.png +0 -0
  112. data/html/images/wrench_orange.png +0 -0
  113. data/html/images/zoom.png +0 -0
  114. data/html/index.html +0 -768
  115. data/html/js/darkfish.js +0 -161
  116. data/html/js/jquery.js +0 -4
  117. data/html/js/navigation.js +0 -142
  118. data/html/js/navigation.js.gz +0 -0
  119. data/html/js/search.js +0 -109
  120. data/html/js/search_index.js +0 -1
  121. data/html/js/search_index.js.gz +0 -0
  122. data/html/js/searcher.js +0 -228
  123. data/html/js/searcher.js.gz +0 -0
  124. data/html/table_of_contents.html +0 -1265
data/html/MIDI/Event.html DELETED
@@ -1,489 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class MIDI::Event - 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
-
66
-
67
- <!-- Method Quickref -->
68
- <div id="method-list-section" class="nav-section">
69
- <h3>Methods</h3>
70
-
71
- <ul class="link-list" role="directory">
72
-
73
- <li ><a href="#method-c-new">::new</a>
74
-
75
- <li ><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
76
-
77
- <li ><a href="#method-i-channel_to_s">#channel_to_s</a>
78
-
79
- <li ><a href="#method-i-data_as_bytes">#data_as_bytes</a>
80
-
81
- <li ><a href="#method-i-number_to_s">#number_to_s</a>
82
-
83
- <li ><a href="#method-i-quantize_to">#quantize_to</a>
84
-
85
- <li ><a href="#method-i-to_s">#to_s</a>
86
-
87
- </ul>
88
- </div>
89
-
90
- </div>
91
- </nav>
92
-
93
- <main role="main" aria-labelledby="class-MIDI::Event">
94
- <h1 id="class-MIDI::Event" class="class">
95
- class MIDI::Event
96
- </h1>
97
-
98
- <section class="description">
99
-
100
- <p>The abstract superclass of all <a href="MIDI.html">MIDI</a> events.</p>
101
-
102
- </section>
103
-
104
-
105
-
106
-
107
- <section id="5Buntitled-5D" class="documentation-section">
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
- <section class="attribute-method-details" class="method-section">
116
- <header>
117
- <h3>Attributes</h3>
118
- </header>
119
-
120
-
121
- <div id="attribute-i-delta_time" class="method-detail">
122
- <div class="method-heading attribute-method-heading">
123
- <span class="method-name">delta_time</span><span
124
- class="attribute-access-type">[RW]</span>
125
- </div>
126
-
127
- <div class="method-description">
128
-
129
- <p>Modifying <a href="Event.html#attribute-i-delta_time">#delta_time</a> does
130
- not affect time_from_start. You need to call the event&#39;s track&#39;s
131
- <code>recalc_time</code> method.</p>
132
-
133
- </div>
134
- </div>
135
-
136
- <div id="attribute-i-print_channel_numbers_from_one" class="method-detail">
137
- <div class="method-heading attribute-method-heading">
138
- <span class="method-name">print_channel_numbers_from_one</span><span
139
- class="attribute-access-type">[RW]</span>
140
- </div>
141
-
142
- <div class="method-description">
143
-
144
- <p>Determines if <a href="Event.html#method-i-to_s">#to_s</a> outputs <a
145
- href="MIDI.html">MIDI</a> channel numbers from 1-16 instead of the default
146
- 0-15.</p>
147
-
148
- </div>
149
- </div>
150
-
151
- <div id="attribute-i-print_decimal_numbers" class="method-detail">
152
- <div class="method-heading attribute-method-heading">
153
- <span class="method-name">print_decimal_numbers</span><span
154
- class="attribute-access-type">[RW]</span>
155
- </div>
156
-
157
- <div class="method-description">
158
-
159
- <p>Determines if <a href="Event.html#method-i-to_s">#to_s</a> outputs numbers
160
- as hex (false, the default) or decimal # (true). Delta times are always
161
- printed as decimal.</p>
162
-
163
- </div>
164
- </div>
165
-
166
- <div id="attribute-i-print_note_names" class="method-detail">
167
- <div class="method-heading attribute-method-heading">
168
- <span class="method-name">print_note_names</span><span
169
- class="attribute-access-type">[RW]</span>
170
- </div>
171
-
172
- <div class="method-description">
173
-
174
- <p>Determines if <a href="Event.html#method-i-to_s">#to_s</a> outputs hex note
175
- numbers (false, the default) or decimal note names (true).</p>
176
-
177
- </div>
178
- </div>
179
-
180
- <div id="attribute-i-status" class="method-detail">
181
- <div class="method-heading attribute-method-heading">
182
- <span class="method-name">status</span><span
183
- class="attribute-access-type">[R]</span>
184
- </div>
185
-
186
- <div class="method-description">
187
-
188
- <p>The <a href="MIDI.html">MIDI</a> status byte. Never includes the channel,
189
- which is held separately by <a
190
- href="ChannelEvent.html">MIDI::ChannelEvent</a>.</p>
191
-
192
- </div>
193
- </div>
194
-
195
- <div id="attribute-i-time_from_start" class="method-detail">
196
- <div class="method-heading attribute-method-heading">
197
- <span class="method-name">time_from_start</span><span
198
- class="attribute-access-type">[RW]</span>
199
- </div>
200
-
201
- <div class="method-description">
202
-
203
- <p>The start time of this event from the beginning of the track. This value is
204
- held here but is maintained by the track.</p>
205
-
206
- </div>
207
- </div>
208
-
209
- </section>
210
-
211
-
212
-
213
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
214
- <header>
215
- <h3>Public Class Methods</h3>
216
- </header>
217
-
218
-
219
- <div id="method-c-new" class="method-detail ">
220
-
221
- <div class="method-heading">
222
- <span class="method-name">new</span><span
223
- class="method-args">(status = 0, delta_time = 0)</span>
224
-
225
- <span class="method-click-advice">click to toggle source</span>
226
-
227
- </div>
228
-
229
-
230
- <div class="method-description">
231
-
232
-
233
-
234
-
235
-
236
-
237
- <div class="method-source-code" id="new-source">
238
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 31</span>
239
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">status</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">delta_time</span> = <span class="ruby-value">0</span>)
240
- <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>
241
- <span class="ruby-ivar">@delta_time</span> = <span class="ruby-identifier">delta_time</span>
242
- <span class="ruby-ivar">@time_from_start</span> = <span class="ruby-value">0</span> <span class="ruby-comment"># maintained by tracks</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-3C-3D-3E" class="method-detail ">
263
-
264
- <div class="method-heading">
265
- <span class="method-name">&lt;=&gt;</span><span
266
- class="method-args">(an_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>For sorting. Uses @time_from_start, which is maintained by this event&#39;s
276
- track. I&#39;m not sure this is necessary, since each track has to maintain
277
- its events&#39; time-from-start values anyway.</p>
278
-
279
-
280
-
281
-
282
- <div class="method-source-code" id="3C-3D-3E-source">
283
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 60</span>
284
- <span class="ruby-keyword">def</span> <span class="ruby-operator">&lt;=&gt;</span>(<span class="ruby-identifier">an_event</span>)
285
- <span class="ruby-keyword">return</span> <span class="ruby-ivar">@time_from_start</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">an_event</span>.<span class="ruby-identifier">time_from_start</span>
286
- <span class="ruby-keyword">end</span></pre>
287
- </div>
288
-
289
- </div>
290
-
291
-
292
-
293
-
294
- </div>
295
-
296
-
297
- <div id="method-i-channel_to_s" class="method-detail ">
298
-
299
- <div class="method-heading">
300
- <span class="method-name">channel_to_s</span><span
301
- class="method-args">(val)</span>
302
-
303
- <span class="method-click-advice">click to toggle source</span>
304
-
305
- </div>
306
-
307
-
308
- <div class="method-description">
309
-
310
- <p>Returns <code>val</code> as a decimal or hex string, depending upon the
311
- value of @print_decimal_numbers.</p>
312
-
313
-
314
-
315
-
316
- <div class="method-source-code" id="channel_to_s-source">
317
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 72</span>
318
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">channel_to_s</span>(<span class="ruby-identifier">val</span>)
319
- <span class="ruby-identifier">val</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@print_channel_numbers_from_one</span>
320
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">number_to_s</span>(<span class="ruby-identifier">val</span>)
321
- <span class="ruby-keyword">end</span></pre>
322
- </div>
323
-
324
- </div>
325
-
326
-
327
-
328
-
329
- </div>
330
-
331
-
332
- <div id="method-i-data_as_bytes" class="method-detail ">
333
-
334
- <div class="method-heading">
335
- <span class="method-name">data_as_bytes</span><span
336
- class="method-args">()</span>
337
-
338
- <span class="method-click-advice">click to toggle source</span>
339
-
340
- </div>
341
-
342
-
343
- <div class="method-description">
344
-
345
- <p>Returns the raw bytes that are written to a <a href="MIDI.html">MIDI</a>
346
- file or output to a <a href="MIDI.html">MIDI</a> stream. In MIDI::EVENT
347
- this raises a “subclass responsibility” exception.</p>
348
-
349
-
350
-
351
-
352
- <div class="method-source-code" id="data_as_bytes-source">
353
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 41</span>
354
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">data_as_bytes</span>
355
- <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;subclass responsibility&quot;</span>
356
- <span class="ruby-keyword">end</span></pre>
357
- </div>
358
-
359
- </div>
360
-
361
-
362
-
363
-
364
- </div>
365
-
366
-
367
- <div id="method-i-number_to_s" class="method-detail ">
368
-
369
- <div class="method-heading">
370
- <span class="method-name">number_to_s</span><span
371
- class="method-args">(val)</span>
372
-
373
- <span class="method-click-advice">click to toggle source</span>
374
-
375
- </div>
376
-
377
-
378
- <div class="method-description">
379
-
380
- <p>Returns <code>val</code> as a decimal or hex string, depending upon the
381
- value of @print_decimal_numbers.</p>
382
-
383
-
384
-
385
-
386
- <div class="method-source-code" id="number_to_s-source">
387
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 66</span>
388
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">number_to_s</span>(<span class="ruby-identifier">val</span>)
389
- <span class="ruby-keyword">return</span> <span class="ruby-ivar">@print_decimal_numbers</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> (<span class="ruby-string">&#39;%02x&#39;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">val</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-quantize_to" class="method-detail ">
402
-
403
- <div class="method-heading">
404
- <span class="method-name">quantize_to</span><span
405
- class="method-args">(boundary)</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>Quantize this event&#39;s <a
415
- href="Event.html#attribute-i-time_from_start">#time_from_start</a> by
416
- moving it to the nearest multiple of <code>boundary</code>. See <a
417
- href="Track.html#method-i-quantize">MIDI::Track#quantize</a>.
418
- <strong>Note</strong>: does not modify the event&#39;s <a
419
- href="Event.html#attribute-i-delta_time">#delta_time</a>, though <a
420
- href="Track.html#method-i-quantize">MIDI::Track#quantize</a> calls
421
- recalc_delta_from_times after it asks each event to quantize itself.</p>
422
-
423
-
424
-
425
-
426
- <div class="method-source-code" id="quantize_to-source">
427
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 49</span>
428
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">quantize_to</span>(<span class="ruby-identifier">boundary</span>)
429
- <span class="ruby-identifier">diff</span> = <span class="ruby-ivar">@time_from_start</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">boundary</span>
430
- <span class="ruby-ivar">@time_from_start</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">diff</span>
431
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">diff</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">boundary</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span>
432
- <span class="ruby-ivar">@time_from_start</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">boundary</span>
433
- <span class="ruby-keyword">end</span>
434
- <span class="ruby-keyword">end</span></pre>
435
- </div>
436
-
437
- </div>
438
-
439
-
440
-
441
-
442
- </div>
443
-
444
-
445
- <div id="method-i-to_s" class="method-detail ">
446
-
447
- <div class="method-heading">
448
- <span class="method-name">to_s</span><span
449
- class="method-args">()</span>
450
-
451
- <span class="method-click-advice">click to toggle source</span>
452
-
453
- </div>
454
-
455
-
456
- <div class="method-description">
457
-
458
-
459
-
460
-
461
-
462
-
463
- <div class="method-source-code" id="to_s-source">
464
- <pre><span class="ruby-comment"># File lib/midilib/event.rb, line 77</span>
465
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">to_s</span>
466
- <span class="ruby-node">&quot;#{@delta_time}: &quot;</span>
467
- <span class="ruby-keyword">end</span></pre>
468
- </div>
469
-
470
- </div>
471
-
472
-
473
-
474
-
475
- </div>
476
-
477
-
478
- </section>
479
-
480
- </section>
481
- </main>
482
-
483
-
484
- <footer id="validator-badges" role="contentinfo">
485
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
486
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
487
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
488
- </footer>
489
-