midilib 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/Credits +11 -2
  2. data/README.rdoc +17 -26
  3. data/Rakefile +34 -7
  4. data/install.rb +2 -2
  5. data/lib/midilib/info.rb +2 -2
  6. metadata +25 -119
  7. data/html/Array.html +0 -382
  8. data/html/IO.html +0 -277
  9. data/html/MIDI.html +0 -829
  10. data/html/MIDI/ActiveSense.html +0 -317
  11. data/html/MIDI/ChannelEvent.html +0 -347
  12. data/html/MIDI/ChannelPressure.html +0 -379
  13. data/html/MIDI/Clock.html +0 -317
  14. data/html/MIDI/Continue.html +0 -317
  15. data/html/MIDI/Controller.html +0 -398
  16. data/html/MIDI/Event.html +0 -659
  17. data/html/MIDI/IO.html +0 -238
  18. data/html/MIDI/IO/MIDIFile.html +0 -2269
  19. data/html/MIDI/IO/SeqReader.html +0 -1051
  20. data/html/MIDI/IO/SeqWriter.html +0 -706
  21. data/html/MIDI/KeySig.html +0 -487
  22. data/html/MIDI/Marker.html +0 -275
  23. data/html/MIDI/Measure.html +0 -479
  24. data/html/MIDI/Measures.html +0 -416
  25. data/html/MIDI/MetaEvent.html +0 -617
  26. data/html/MIDI/NoteEvent.html +0 -459
  27. data/html/MIDI/NoteOff.html +0 -341
  28. data/html/MIDI/NoteOn.html +0 -341
  29. data/html/MIDI/PitchBend.html +0 -380
  30. data/html/MIDI/PolyPressure.html +0 -390
  31. data/html/MIDI/ProgramChange.html +0 -379
  32. data/html/MIDI/Realtime.html +0 -354
  33. data/html/MIDI/Sequence.html +0 -1063
  34. data/html/MIDI/SongPointer.html +0 -380
  35. data/html/MIDI/SongSelect.html +0 -379
  36. data/html/MIDI/Start.html +0 -317
  37. data/html/MIDI/Stop.html +0 -317
  38. data/html/MIDI/SystemCommon.html +0 -275
  39. data/html/MIDI/SystemExclusive.html +0 -382
  40. data/html/MIDI/SystemReset.html +0 -317
  41. data/html/MIDI/Tempo.html +0 -519
  42. data/html/MIDI/TimeSig.html +0 -524
  43. data/html/MIDI/Track.html +0 -859
  44. data/html/MIDI/TuneRequest.html +0 -354
  45. data/html/MIDI/Utils.html +0 -350
  46. data/html/README_rdoc.html +0 -882
  47. data/html/TODO_rdoc.html +0 -215
  48. data/html/created.rid +0 -14
  49. data/html/images/brick.png +0 -0
  50. data/html/images/brick_link.png +0 -0
  51. data/html/images/bug.png +0 -0
  52. data/html/images/bullet_black.png +0 -0
  53. data/html/images/bullet_toggle_minus.png +0 -0
  54. data/html/images/bullet_toggle_plus.png +0 -0
  55. data/html/images/date.png +0 -0
  56. data/html/images/find.png +0 -0
  57. data/html/images/loadingAnimation.gif +0 -0
  58. data/html/images/macFFBgHack.png +0 -0
  59. data/html/images/package.png +0 -0
  60. data/html/images/page_green.png +0 -0
  61. data/html/images/page_white_text.png +0 -0
  62. data/html/images/page_white_width.png +0 -0
  63. data/html/images/plugin.png +0 -0
  64. data/html/images/ruby.png +0 -0
  65. data/html/images/tag_green.png +0 -0
  66. data/html/images/wrench.png +0 -0
  67. data/html/images/wrench_orange.png +0 -0
  68. data/html/images/zoom.png +0 -0
  69. data/html/index.html +0 -1266
  70. data/html/js/darkfish.js +0 -116
  71. data/html/js/jquery.js +0 -32
  72. data/html/js/quicksearch.js +0 -114
  73. data/html/js/thickbox-compressed.js +0 -10
  74. data/html/lib/midilib/consts_rb.html +0 -55
  75. data/html/lib/midilib/event_rb.html +0 -56
  76. data/html/lib/midilib/info_rb.html +0 -52
  77. data/html/lib/midilib/io/midifile_rb.html +0 -54
  78. data/html/lib/midilib/io/seqreader_rb.html +0 -58
  79. data/html/lib/midilib/io/seqwriter_rb.html +0 -59
  80. data/html/lib/midilib/measure_rb.html +0 -54
  81. data/html/lib/midilib/sequence_rb.html +0 -58
  82. data/html/lib/midilib/track_rb.html +0 -54
  83. data/html/lib/midilib/utils_rb.html +0 -52
  84. data/html/lib/midilib_rb.html +0 -71
  85. data/html/rdoc.css +0 -706
@@ -1,706 +0,0 @@
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::IO::SeqWriter</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/io/seqwriter_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
- class="thickbox" title="lib/midilib/io/seqwriter.rb">lib/midilib/io/seqwriter.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-possibly_munge_due_to_running_status_byte">#possibly_munge_due_to_running_status_byte</a></li>
75
-
76
- <li><a href="#method-i-write16">#write16</a></li>
77
-
78
- <li><a href="#method-i-write32">#write32</a></li>
79
-
80
- <li><a href="#method-i-write_bytes">#write_bytes</a></li>
81
-
82
- <li><a href="#method-i-write_header">#write_header</a></li>
83
-
84
- <li><a href="#method-i-write_instrument">#write_instrument</a></li>
85
-
86
- <li><a href="#method-i-write_to">#write_to</a></li>
87
-
88
- <li><a href="#method-i-write_track">#write_track</a></li>
89
-
90
- <li><a href="#method-i-write_var_len">#write_var_len</a></li>
91
-
92
- </ul>
93
- </div>
94
-
95
-
96
- <!-- Included Modules -->
97
-
98
- </div>
99
-
100
- <div id="project-metadata">
101
-
102
-
103
- <div id="fileindex-section" class="section project-section">
104
- <h3 class="section-header">Files</h3>
105
- <ul>
106
-
107
- <li class="file"><a href="../../README_rdoc.html">README.rdoc</a></li>
108
-
109
- <li class="file"><a href="../../TODO_rdoc.html">TODO.rdoc</a></li>
110
-
111
- </ul>
112
- </div>
113
-
114
-
115
- <div id="classindex-section" class="section project-section">
116
- <h3 class="section-header">Class Index
117
- <span class="search-toggle"><img src="../../images/find.png"
118
- height="16" width="16" alt="[+]"
119
- title="show/hide quicksearch" /></span></h3>
120
- <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
121
- <fieldset>
122
- <legend>Quicksearch</legend>
123
- <input type="text" name="quicksearch" value=""
124
- class="quicksearch-field" />
125
- </fieldset>
126
- </form>
127
-
128
- <ul class="link-list">
129
-
130
- <li><a href="../../MIDI.html">MIDI</a></li>
131
-
132
- <li><a href="../../MIDI/ActiveSense.html">MIDI::ActiveSense</a></li>
133
-
134
- <li><a href="../../MIDI/ChannelEvent.html">MIDI::ChannelEvent</a></li>
135
-
136
- <li><a href="../../MIDI/ChannelPressure.html">MIDI::ChannelPressure</a></li>
137
-
138
- <li><a href="../../MIDI/Clock.html">MIDI::Clock</a></li>
139
-
140
- <li><a href="../../MIDI/Continue.html">MIDI::Continue</a></li>
141
-
142
- <li><a href="../../MIDI/Controller.html">MIDI::Controller</a></li>
143
-
144
- <li><a href="../../MIDI/Event.html">MIDI::Event</a></li>
145
-
146
- <li><a href="../../MIDI/IO.html">MIDI::IO</a></li>
147
-
148
- <li><a href="../../MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a></li>
149
-
150
- <li><a href="../../MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a></li>
151
-
152
- <li><a href="../../MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a></li>
153
-
154
- <li><a href="../../MIDI/KeySig.html">MIDI::KeySig</a></li>
155
-
156
- <li><a href="../../MIDI/Marker.html">MIDI::Marker</a></li>
157
-
158
- <li><a href="../../MIDI/Measure.html">MIDI::Measure</a></li>
159
-
160
- <li><a href="../../MIDI/Measures.html">MIDI::Measures</a></li>
161
-
162
- <li><a href="../../MIDI/MetaEvent.html">MIDI::MetaEvent</a></li>
163
-
164
- <li><a href="../../MIDI/NoteEvent.html">MIDI::NoteEvent</a></li>
165
-
166
- <li><a href="../../MIDI/NoteOff.html">MIDI::NoteOff</a></li>
167
-
168
- <li><a href="../../MIDI/NoteOff.html">MIDI::NoteOff</a></li>
169
-
170
- <li><a href="../../MIDI/NoteOn.html">MIDI::NoteOn</a></li>
171
-
172
- <li><a href="../../MIDI/NoteOn.html">MIDI::NoteOn</a></li>
173
-
174
- <li><a href="../../MIDI/PitchBend.html">MIDI::PitchBend</a></li>
175
-
176
- <li><a href="../../MIDI/PolyPressure.html">MIDI::PolyPressure</a></li>
177
-
178
- <li><a href="../../MIDI/ProgramChange.html">MIDI::ProgramChange</a></li>
179
-
180
- <li><a href="../../MIDI/Realtime.html">MIDI::Realtime</a></li>
181
-
182
- <li><a href="../../MIDI/Sequence.html">MIDI::Sequence</a></li>
183
-
184
- <li><a href="../../MIDI/SongPointer.html">MIDI::SongPointer</a></li>
185
-
186
- <li><a href="../../MIDI/SongSelect.html">MIDI::SongSelect</a></li>
187
-
188
- <li><a href="../../MIDI/Start.html">MIDI::Start</a></li>
189
-
190
- <li><a href="../../MIDI/Stop.html">MIDI::Stop</a></li>
191
-
192
- <li><a href="../../MIDI/SystemCommon.html">MIDI::SystemCommon</a></li>
193
-
194
- <li><a href="../../MIDI/SystemExclusive.html">MIDI::SystemExclusive</a></li>
195
-
196
- <li><a href="../../MIDI/SystemReset.html">MIDI::SystemReset</a></li>
197
-
198
- <li><a href="../../MIDI/Tempo.html">MIDI::Tempo</a></li>
199
-
200
- <li><a href="../../MIDI/TimeSig.html">MIDI::TimeSig</a></li>
201
-
202
- <li><a href="../../MIDI/Track.html">MIDI::Track</a></li>
203
-
204
- <li><a href="../../MIDI/TuneRequest.html">MIDI::TuneRequest</a></li>
205
-
206
- <li><a href="../../MIDI/Utils.html">MIDI::Utils</a></li>
207
-
208
- <li><a href="../../Array.html">Array</a></li>
209
-
210
- <li><a href="../../IO.html">IO</a></li>
211
-
212
- </ul>
213
- <div id="no-class-search-results" style="display: none;">No matching classes.</div>
214
- </div>
215
-
216
-
217
- </div>
218
- </div>
219
-
220
- <div id="documentation">
221
- <h1 class="class">MIDI::IO::SeqWriter</h1>
222
-
223
- <div id="description">
224
-
225
- </div>
226
-
227
- <!-- Constants -->
228
-
229
-
230
- <!-- Attributes -->
231
-
232
-
233
- <!-- Methods -->
234
-
235
- <div id="public-class-method-details" class="method-section section">
236
- <h3 class="section-header">Public Class Methods</h3>
237
-
238
-
239
- <div id="new-method" class="method-detail ">
240
- <a name="method-c-new"></a>
241
-
242
- <div class="method-heading">
243
-
244
- <span class="method-name">new</span><span
245
- class="method-args">(seq, proc = nil)</span>
246
- <span class="method-click-advice">click to toggle source</span>
247
-
248
- </div>
249
-
250
- <div class="method-description">
251
-
252
-
253
-
254
-
255
-
256
- <div class="method-source-code"
257
- id="new-source">
258
- <pre>
259
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 12</span>
260
- 12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">seq</span>, <span class="ruby-identifier">proc</span> = <span class="ruby-keyword kw">nil</span>) <span class="ruby-comment cmt"># :yields: num_tracks, index</span>
261
- 13: <span class="ruby-ivar">@seq</span> = <span class="ruby-identifier">seq</span>
262
- 14: <span class="ruby-ivar">@update_block</span> = <span class="ruby-identifier">block_given?</span>() <span class="ruby-operator">?</span> <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span>() <span class="ruby-operator">:</span> <span class="ruby-identifier">proc</span>
263
- 15: <span class="ruby-keyword kw">end</span></pre>
264
- </div>
265
-
266
- </div>
267
-
268
-
269
-
270
-
271
- </div>
272
-
273
-
274
- </div>
275
-
276
- <div id="public-instance-method-details" class="method-section section">
277
- <h3 class="section-header">Public Instance Methods</h3>
278
-
279
-
280
- <div id="possibly-munge-due-to-running-status-byte-method" class="method-detail ">
281
- <a name="method-i-possibly_munge_due_to_running_status_byte"></a>
282
-
283
- <div class="method-heading">
284
-
285
- <span class="method-name">possibly_munge_due_to_running_status_byte</span><span
286
- class="method-args">(data, prev_status)</span>
287
- <span class="method-click-advice">click to toggle source</span>
288
-
289
- </div>
290
-
291
- <div class="method-description">
292
-
293
- <p>
294
- If we can use a running status byte, delete the status byte from the given
295
- data. Return the status to remember for next time as the running status
296
- byte for this event.
297
- </p>
298
-
299
-
300
-
301
- <div class="method-source-code"
302
- id="possibly-munge-due-to-running-status-byte-source">
303
- <pre>
304
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 80</span>
305
- 80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">possibly_munge_due_to_running_status_byte</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">prev_status</span>)
306
- 81: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>]
307
- 82: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0xf0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">prev_status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0xf0</span>
308
- 83:
309
- 84: <span class="ruby-identifier">chan</span> = (<span class="ruby-identifier">status</span> &amp; <span class="ruby-value">0x0f</span>)
310
- 85: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">chan</span> <span class="ruby-operator">!=</span> (<span class="ruby-identifier">prev_status</span> &amp; <span class="ruby-value">0x0f</span>)
311
- 86:
312
- 87: <span class="ruby-identifier">status</span> = (<span class="ruby-identifier">status</span> &amp; <span class="ruby-value">0xf0</span>)
313
- 88: <span class="ruby-identifier">prev_status</span> = (<span class="ruby-identifier">prev_status</span> &amp; <span class="ruby-value">0xf0</span>)
314
- 89:
315
- 90: <span class="ruby-comment cmt"># Both events are on the same channel. If the two status bytes are</span>
316
- 91: <span class="ruby-comment cmt"># exactly the same, the rest is trivial. If it's note on/note off,</span>
317
- 92: <span class="ruby-comment cmt"># we can combine those further.</span>
318
- 93: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">prev_status</span>
319
- 94: <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>] = [] <span class="ruby-comment cmt"># delete status byte from data</span>
320
- 95: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">chan</span>
321
- 96: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-constant">NOTE_OFF</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">data</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">==</span> <span class="ruby-value">64</span>
322
- 97: <span class="ruby-comment cmt"># If we see a note off and the velocity is 64, we can store</span>
323
- 98: <span class="ruby-comment cmt"># a note on with a velocity of 0. If the velocity isn't 64</span>
324
- 99: <span class="ruby-comment cmt"># then storing a note on would be bad because the would be</span>
325
- 100: <span class="ruby-comment cmt"># changed to 64 when reading the file back in.</span>
326
- 101: <span class="ruby-identifier">data</span>[<span class="ruby-value">2</span>] = <span class="ruby-value">0</span> <span class="ruby-comment cmt"># set vel to 0; do before possible shrinking</span>
327
- 102: <span class="ruby-identifier">status</span> = <span class="ruby-constant">NOTE_ON</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">chan</span>
328
- 103: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prev_status</span> <span class="ruby-operator">==</span> <span class="ruby-constant">NOTE_ON</span>
329
- 104: <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>] = [] <span class="ruby-comment cmt"># delete status byte</span>
330
- 105: <span class="ruby-keyword kw">else</span>
331
- 106: <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">status</span>
332
- 107: <span class="ruby-keyword kw">end</span>
333
- 108: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span>
334
- 109: <span class="ruby-keyword kw">else</span>
335
- 110: <span class="ruby-comment cmt"># Can't compress data</span>
336
- 111: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">chan</span>
337
- 112: <span class="ruby-keyword kw">end</span>
338
- 113: <span class="ruby-keyword kw">end</span></pre>
339
- </div>
340
-
341
- </div>
342
-
343
-
344
-
345
-
346
- </div>
347
-
348
-
349
- <div id="write--method" class="method-detail ">
350
- <a name="method-i-write16"></a>
351
-
352
- <div class="method-heading">
353
-
354
- <span class="method-name">write16</span><span
355
- class="method-args">(val)</span>
356
- <span class="method-click-advice">click to toggle source</span>
357
-
358
- </div>
359
-
360
- <div class="method-description">
361
-
362
-
363
-
364
-
365
-
366
- <div class="method-source-code"
367
- id="write--source">
368
- <pre>
369
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 127</span>
370
- 127: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write16</span>(<span class="ruby-identifier">val</span>)
371
- 128: <span class="ruby-identifier">val</span> = (<span class="ruby-operator">-</span><span class="ruby-identifier">val</span> <span class="ruby-operator">|</span> <span class="ruby-value">0x8000</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
372
- 129:
373
- 130: <span class="ruby-identifier">buffer</span> = []
374
- 131: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>((<span class="ruby-identifier">val</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>) &amp; <span class="ruby-value">0xff</span>)
375
- 132: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>(<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0xff</span>)
376
- 133: <span class="ruby-ivar">@bytes_written</span> <span class="ruby-operator">+=</span> <span class="ruby-value">2</span>
377
- 134: <span class="ruby-keyword kw">end</span></pre>
378
- </div>
379
-
380
- </div>
381
-
382
-
383
-
384
-
385
- </div>
386
-
387
-
388
- <div id="write--method" class="method-detail ">
389
- <a name="method-i-write32"></a>
390
-
391
- <div class="method-heading">
392
-
393
- <span class="method-name">write32</span><span
394
- class="method-args">(val)</span>
395
- <span class="method-click-advice">click to toggle source</span>
396
-
397
- </div>
398
-
399
- <div class="method-description">
400
-
401
-
402
-
403
-
404
-
405
- <div class="method-source-code"
406
- id="write--source">
407
- <pre>
408
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 136</span>
409
- 136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write32</span>(<span class="ruby-identifier">val</span>)
410
- 137: <span class="ruby-identifier">val</span> = (<span class="ruby-operator">-</span><span class="ruby-identifier">val</span> <span class="ruby-operator">|</span> <span class="ruby-value">0x80000000</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
411
- 138:
412
- 139: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>((<span class="ruby-identifier">val</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">24</span>) &amp; <span class="ruby-value">0xff</span>)
413
- 140: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>((<span class="ruby-identifier">val</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">16</span>) &amp; <span class="ruby-value">0xff</span>)
414
- 141: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>((<span class="ruby-identifier">val</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>) &amp; <span class="ruby-value">0xff</span>)
415
- 142: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>(<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0xff</span>)
416
- 143: <span class="ruby-ivar">@bytes_written</span> <span class="ruby-operator">+=</span> <span class="ruby-value">4</span>
417
- 144: <span class="ruby-keyword kw">end</span></pre>
418
- </div>
419
-
420
- </div>
421
-
422
-
423
-
424
-
425
- </div>
426
-
427
-
428
- <div id="write-bytes-method" class="method-detail ">
429
- <a name="method-i-write_bytes"></a>
430
-
431
- <div class="method-heading">
432
-
433
- <span class="method-name">write_bytes</span><span
434
- class="method-args">(bytes)</span>
435
- <span class="method-click-advice">click to toggle source</span>
436
-
437
- </div>
438
-
439
- <div class="method-description">
440
-
441
-
442
-
443
-
444
-
445
- <div class="method-source-code"
446
- id="write-bytes-source">
447
- <pre>
448
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 146</span>
449
- 146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_bytes</span>(<span class="ruby-identifier">bytes</span>)
450
- 147: <span class="ruby-identifier">bytes</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">putc</span>(<span class="ruby-identifier">b</span>) }
451
- 148: <span class="ruby-identifier">bytes</span>.<span class="ruby-identifier">length</span>
452
- 149: <span class="ruby-keyword kw">end</span></pre>
453
- </div>
454
-
455
- </div>
456
-
457
-
458
-
459
-
460
- </div>
461
-
462
-
463
- <div id="write-header-method" class="method-detail ">
464
- <a name="method-i-write_header"></a>
465
-
466
- <div class="method-heading">
467
-
468
- <span class="method-name">write_header</span><span
469
- class="method-args">()</span>
470
- <span class="method-click-advice">click to toggle source</span>
471
-
472
- </div>
473
-
474
- <div class="method-description">
475
-
476
-
477
-
478
-
479
-
480
- <div class="method-source-code"
481
- id="write-header-source">
482
- <pre>
483
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 29</span>
484
- 29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_header</span>
485
- 30: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">print</span> <span class="ruby-value str">'MThd'</span>
486
- 31: <span class="ruby-identifier">write32</span>(<span class="ruby-value">6</span>)
487
- 32: <span class="ruby-identifier">write16</span>(<span class="ruby-value">1</span>) <span class="ruby-comment cmt"># Ignore sequence format; write as format 1</span>
488
- 33: <span class="ruby-identifier">write16</span>(<span class="ruby-ivar">@seq</span>.<span class="ruby-identifier">tracks</span>.<span class="ruby-identifier">length</span>)
489
- 34: <span class="ruby-identifier">write16</span>(<span class="ruby-ivar">@seq</span>.<span class="ruby-identifier">ppqn</span>)
490
- 35: <span class="ruby-keyword kw">end</span></pre>
491
- </div>
492
-
493
- </div>
494
-
495
-
496
-
497
-
498
- </div>
499
-
500
-
501
- <div id="write-instrument-method" class="method-detail ">
502
- <a name="method-i-write_instrument"></a>
503
-
504
- <div class="method-heading">
505
-
506
- <span class="method-name">write_instrument</span><span
507
- class="method-args">(instrument)</span>
508
- <span class="method-click-advice">click to toggle source</span>
509
-
510
- </div>
511
-
512
- <div class="method-description">
513
-
514
-
515
-
516
-
517
-
518
- <div class="method-source-code"
519
- id="write-instrument-source">
520
- <pre>
521
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 115</span>
522
- 115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_instrument</span>(<span class="ruby-identifier">instrument</span>)
523
- 116: <span class="ruby-identifier">event</span> = <span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">META_INSTRUMENT</span>, <span class="ruby-identifier">instrument</span>)
524
- 117: <span class="ruby-identifier">write_var_len</span>(<span class="ruby-value">0</span>)
525
- 118: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">event</span>.<span class="ruby-identifier">data_as_bytes</span>()
526
- 119: <span class="ruby-ivar">@bytes_written</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">write_bytes</span>(<span class="ruby-identifier">data</span>)
527
- 120: <span class="ruby-keyword kw">end</span></pre>
528
- </div>
529
-
530
- </div>
531
-
532
-
533
-
534
-
535
- </div>
536
-
537
-
538
- <div id="write-to-method" class="method-detail ">
539
- <a name="method-i-write_to"></a>
540
-
541
- <div class="method-heading">
542
-
543
- <span class="method-name">write_to</span><span
544
- class="method-args">(io)</span>
545
- <span class="method-click-advice">click to toggle source</span>
546
-
547
- </div>
548
-
549
- <div class="method-description">
550
-
551
- <p>
552
- Writes a <a href="../../MIDI.html">MIDI</a> format 1 file.
553
- </p>
554
-
555
-
556
-
557
- <div class="method-source-code"
558
- id="write-to-source">
559
- <pre>
560
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 18</span>
561
- 18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_to</span>(<span class="ruby-identifier">io</span>)
562
- 19: <span class="ruby-ivar">@io</span> = <span class="ruby-identifier">io</span>
563
- 20: <span class="ruby-ivar">@bytes_written</span> = <span class="ruby-value">0</span>
564
- 21: <span class="ruby-identifier">write_header</span>()
565
- 22: <span class="ruby-ivar">@update_block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-ivar">@seq</span>.<span class="ruby-identifier">tracks</span>.<span class="ruby-identifier">length</span>, <span class="ruby-value">0</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@update_block</span>
566
- 23: <span class="ruby-ivar">@seq</span>.<span class="ruby-identifier">tracks</span>.<span class="ruby-identifier">each_with_index</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">track</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">|</span>
567
- 24: <span class="ruby-identifier">write_track</span>(<span class="ruby-identifier">track</span>)
568
- 25: <span class="ruby-ivar">@update_block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">track</span>, <span class="ruby-ivar">@seq</span>.<span class="ruby-identifier">tracks</span>.<span class="ruby-identifier">length</span>, <span class="ruby-identifier">i</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@update_block</span>
569
- 26: }
570
- 27: <span class="ruby-keyword kw">end</span></pre>
571
- </div>
572
-
573
- </div>
574
-
575
-
576
-
577
-
578
- </div>
579
-
580
-
581
- <div id="write-track-method" class="method-detail ">
582
- <a name="method-i-write_track"></a>
583
-
584
- <div class="method-heading">
585
-
586
- <span class="method-name">write_track</span><span
587
- class="method-args">(track)</span>
588
- <span class="method-click-advice">click to toggle source</span>
589
-
590
- </div>
591
-
592
- <div class="method-description">
593
-
594
-
595
-
596
-
597
-
598
- <div class="method-source-code"
599
- id="write-track-source">
600
- <pre>
601
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 37</span>
602
- 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_track</span>(<span class="ruby-identifier">track</span>)
603
- 38: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">print</span> <span class="ruby-value str">'MTrk'</span>
604
- 39: <span class="ruby-identifier">track_size_file_pos</span> = <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">tell</span>()
605
- 40: <span class="ruby-identifier">write32</span>(<span class="ruby-value">0</span>) <span class="ruby-comment cmt"># Dummy byte count; overwritten later</span>
606
- 41: <span class="ruby-ivar">@bytes_written</span> = <span class="ruby-value">0</span> <span class="ruby-comment cmt"># Reset after previous write</span>
607
- 42:
608
- 43: <span class="ruby-identifier">write_instrument</span>(<span class="ruby-identifier">track</span>.<span class="ruby-identifier">instrument</span>)
609
- 44:
610
- 45: <span class="ruby-identifier">prev_event</span> = <span class="ruby-keyword kw">nil</span>
611
- 46: <span class="ruby-identifier">prev_status</span> = <span class="ruby-value">0</span>
612
- 47: <span class="ruby-identifier">track</span>.<span class="ruby-identifier">events</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">|</span>
613
- 48: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">event</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Realtime</span>)
614
- 49: <span class="ruby-identifier">write_var_len</span>(<span class="ruby-identifier">event</span>.<span class="ruby-identifier">delta_time</span>)
615
- 50: <span class="ruby-keyword kw">end</span>
616
- 51:
617
- 52: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">event</span>.<span class="ruby-identifier">data_as_bytes</span>()
618
- 53: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>] <span class="ruby-comment cmt"># status byte plus channel number, if any</span>
619
- 54:
620
- 55: <span class="ruby-comment cmt"># running status byte</span>
621
- 56: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">possibly_munge_due_to_running_status_byte</span>(<span class="ruby-identifier">data</span>,
622
- 57: <span class="ruby-identifier">prev_status</span>)
623
- 58:
624
- 59: <span class="ruby-ivar">@bytes_written</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">write_bytes</span>(<span class="ruby-identifier">data</span>)
625
- 60:
626
- 61: <span class="ruby-identifier">prev_event</span> = <span class="ruby-identifier">event</span>
627
- 62: <span class="ruby-identifier">prev_status</span> = <span class="ruby-identifier">status</span>
628
- 63: }
629
- 64:
630
- 65: <span class="ruby-comment cmt"># Write track end event.</span>
631
- 66: <span class="ruby-identifier">event</span> = <span class="ruby-constant">MetaEvent</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">META_TRACK_END</span>)
632
- 67: <span class="ruby-identifier">write_var_len</span>(<span class="ruby-value">0</span>)
633
- 68: <span class="ruby-ivar">@bytes_written</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">write_bytes</span>(<span class="ruby-identifier">event</span>.<span class="ruby-identifier">data_as_bytes</span>())
634
- 69:
635
- 70: <span class="ruby-comment cmt"># Go back to beginning of track data and write number of bytes,</span>
636
- 71: <span class="ruby-comment cmt"># then come back here to end of file.</span>
637
- 72: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">seek</span>(<span class="ruby-identifier">track_size_file_pos</span>)
638
- 73: <span class="ruby-identifier">write32</span>(<span class="ruby-ivar">@bytes_written</span>)
639
- 74: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">seek</span>(<span class="ruby-value">0</span>, <span class="ruby-operator">::</span><span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">SEEK_END</span>)
640
- 75: <span class="ruby-keyword kw">end</span></pre>
641
- </div>
642
-
643
- </div>
644
-
645
-
646
-
647
-
648
- </div>
649
-
650
-
651
- <div id="write-var-len-method" class="method-detail ">
652
- <a name="method-i-write_var_len"></a>
653
-
654
- <div class="method-heading">
655
-
656
- <span class="method-name">write_var_len</span><span
657
- class="method-args">(val)</span>
658
- <span class="method-click-advice">click to toggle source</span>
659
-
660
- </div>
661
-
662
- <div class="method-description">
663
-
664
-
665
-
666
-
667
-
668
- <div class="method-source-code"
669
- id="write-var-len-source">
670
- <pre>
671
- <span class="ruby-comment cmt"># File lib/midilib/io/seqwriter.rb, line 122</span>
672
- 122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_var_len</span>(<span class="ruby-identifier">val</span>)
673
- 123: <span class="ruby-identifier">buffer</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">as_var_len</span>(<span class="ruby-identifier">val</span>)
674
- 124: <span class="ruby-ivar">@bytes_written</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">write_bytes</span>(<span class="ruby-identifier">buffer</span>)
675
- 125: <span class="ruby-keyword kw">end</span></pre>
676
- </div>
677
-
678
- </div>
679
-
680
-
681
-
682
-
683
- </div>
684
-
685
-
686
- </div>
687
-
688
-
689
- </div>
690
-
691
-
692
- <div id="rdoc-debugging-section-dump" class="debugging-section">
693
-
694
- <p>Disabled; run with --debug to generate this.</p>
695
-
696
- </div>
697
-
698
- <div id="validator-badges">
699
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
700
- <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
701
- Rdoc Generator</a> 1.1.6</small>.</p>
702
- </div>
703
-
704
- </body>
705
- </html>
706
-