midilib 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,238 @@
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>Module: MIDI::IO</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="module">
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/midifile_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/midilib/io/midifile.rb">lib/midilib/io/midifile.rb</a></li>
43
+
44
+ <li><a href="../lib/midilib/io/seqreader_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
45
+ class="thickbox" title="lib/midilib/io/seqreader.rb">lib/midilib/io/seqreader.rb</a></li>
46
+
47
+ <li><a href="../lib/midilib/io/seqwriter_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
48
+ class="thickbox" title="lib/midilib/io/seqwriter.rb">lib/midilib/io/seqwriter.rb</a></li>
49
+
50
+ </ul>
51
+ </div>
52
+ </div>
53
+
54
+
55
+ </div>
56
+
57
+ <div id="class-metadata">
58
+
59
+ <!-- Parent Class -->
60
+
61
+
62
+ <!-- Namespace Contents -->
63
+
64
+ <div id="namespace-list-section" class="section">
65
+ <h3 class="section-header">Namespace</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><span class="type">CLASS</span> <a href="IO/MIDIFile.html">MIDI::IO::MIDIFile</a></li>
69
+
70
+ <li><span class="type">CLASS</span> <a href="IO/SeqReader.html">MIDI::IO::SeqReader</a></li>
71
+
72
+ <li><span class="type">CLASS</span> <a href="IO/SeqWriter.html">MIDI::IO::SeqWriter</a></li>
73
+
74
+ </ul>
75
+ </div>
76
+
77
+
78
+ <!-- Method Quickref -->
79
+
80
+
81
+ <!-- Included Modules -->
82
+
83
+ </div>
84
+
85
+ <div id="project-metadata">
86
+
87
+
88
+ <div id="fileindex-section" class="section project-section">
89
+ <h3 class="section-header">Files</h3>
90
+ <ul>
91
+
92
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
93
+
94
+ <li class="file"><a href="../TODO_rdoc.html">TODO.rdoc</a></li>
95
+
96
+ </ul>
97
+ </div>
98
+
99
+
100
+ <div id="classindex-section" class="section project-section">
101
+ <h3 class="section-header">Class Index
102
+ <span class="search-toggle"><img src="../images/find.png"
103
+ height="16" width="16" alt="[+]"
104
+ title="show/hide quicksearch" /></span></h3>
105
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
106
+ <fieldset>
107
+ <legend>Quicksearch</legend>
108
+ <input type="text" name="quicksearch" value=""
109
+ class="quicksearch-field" />
110
+ </fieldset>
111
+ </form>
112
+
113
+ <ul class="link-list">
114
+
115
+ <li><a href="../MIDI.html">MIDI</a></li>
116
+
117
+ <li><a href="../MIDI/ActiveSense.html">MIDI::ActiveSense</a></li>
118
+
119
+ <li><a href="../MIDI/ChannelEvent.html">MIDI::ChannelEvent</a></li>
120
+
121
+ <li><a href="../MIDI/ChannelPressure.html">MIDI::ChannelPressure</a></li>
122
+
123
+ <li><a href="../MIDI/Clock.html">MIDI::Clock</a></li>
124
+
125
+ <li><a href="../MIDI/Continue.html">MIDI::Continue</a></li>
126
+
127
+ <li><a href="../MIDI/Controller.html">MIDI::Controller</a></li>
128
+
129
+ <li><a href="../MIDI/Event.html">MIDI::Event</a></li>
130
+
131
+ <li><a href="../MIDI/IO.html">MIDI::IO</a></li>
132
+
133
+ <li><a href="../MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a></li>
134
+
135
+ <li><a href="../MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a></li>
136
+
137
+ <li><a href="../MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a></li>
138
+
139
+ <li><a href="../MIDI/KeySig.html">MIDI::KeySig</a></li>
140
+
141
+ <li><a href="../MIDI/Marker.html">MIDI::Marker</a></li>
142
+
143
+ <li><a href="../MIDI/Measure.html">MIDI::Measure</a></li>
144
+
145
+ <li><a href="../MIDI/Measures.html">MIDI::Measures</a></li>
146
+
147
+ <li><a href="../MIDI/MetaEvent.html">MIDI::MetaEvent</a></li>
148
+
149
+ <li><a href="../MIDI/NoteEvent.html">MIDI::NoteEvent</a></li>
150
+
151
+ <li><a href="../MIDI/NoteOff.html">MIDI::NoteOff</a></li>
152
+
153
+ <li><a href="../MIDI/NoteOff.html">MIDI::NoteOff</a></li>
154
+
155
+ <li><a href="../MIDI/NoteOn.html">MIDI::NoteOn</a></li>
156
+
157
+ <li><a href="../MIDI/NoteOn.html">MIDI::NoteOn</a></li>
158
+
159
+ <li><a href="../MIDI/PitchBend.html">MIDI::PitchBend</a></li>
160
+
161
+ <li><a href="../MIDI/PolyPressure.html">MIDI::PolyPressure</a></li>
162
+
163
+ <li><a href="../MIDI/ProgramChange.html">MIDI::ProgramChange</a></li>
164
+
165
+ <li><a href="../MIDI/Realtime.html">MIDI::Realtime</a></li>
166
+
167
+ <li><a href="../MIDI/Sequence.html">MIDI::Sequence</a></li>
168
+
169
+ <li><a href="../MIDI/SongPointer.html">MIDI::SongPointer</a></li>
170
+
171
+ <li><a href="../MIDI/SongSelect.html">MIDI::SongSelect</a></li>
172
+
173
+ <li><a href="../MIDI/Start.html">MIDI::Start</a></li>
174
+
175
+ <li><a href="../MIDI/Stop.html">MIDI::Stop</a></li>
176
+
177
+ <li><a href="../MIDI/SystemCommon.html">MIDI::SystemCommon</a></li>
178
+
179
+ <li><a href="../MIDI/SystemExclusive.html">MIDI::SystemExclusive</a></li>
180
+
181
+ <li><a href="../MIDI/SystemReset.html">MIDI::SystemReset</a></li>
182
+
183
+ <li><a href="../MIDI/Tempo.html">MIDI::Tempo</a></li>
184
+
185
+ <li><a href="../MIDI/TimeSig.html">MIDI::TimeSig</a></li>
186
+
187
+ <li><a href="../MIDI/Track.html">MIDI::Track</a></li>
188
+
189
+ <li><a href="../MIDI/TuneRequest.html">MIDI::TuneRequest</a></li>
190
+
191
+ <li><a href="../MIDI/Utils.html">MIDI::Utils</a></li>
192
+
193
+ <li><a href="../Array.html">Array</a></li>
194
+
195
+ <li><a href="../IO.html">IO</a></li>
196
+
197
+ </ul>
198
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
199
+ </div>
200
+
201
+
202
+ </div>
203
+ </div>
204
+
205
+ <div id="documentation">
206
+ <h1 class="module">MIDI::IO</h1>
207
+
208
+ <div id="description">
209
+
210
+ </div>
211
+
212
+ <!-- Constants -->
213
+
214
+
215
+ <!-- Attributes -->
216
+
217
+
218
+ <!-- Methods -->
219
+
220
+
221
+ </div>
222
+
223
+
224
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
225
+
226
+ <p>Disabled; run with --debug to generate this.</p>
227
+
228
+ </div>
229
+
230
+ <div id="validator-badges">
231
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
232
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
233
+ Rdoc Generator</a> 1.1.6</small>.</p>
234
+ </div>
235
+
236
+ </body>
237
+ </html>
238
+
@@ -0,0 +1,2269 @@
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::MIDIFile</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/midifile_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/midilib/io/midifile.rb">lib/midilib/io/midifile.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-arbitrary">#arbitrary</a></li>
75
+
76
+ <li><a href="#method-i-bad_byte">#bad_byte</a></li>
77
+
78
+ <li><a href="#method-i-chan_message">#chan_message</a></li>
79
+
80
+ <li><a href="#method-i-chan_pressure">#chan_pressure</a></li>
81
+
82
+ <li><a href="#method-i-controller">#controller</a></li>
83
+
84
+ <li><a href="#method-i-end_track">#end_track</a></li>
85
+
86
+ <li><a href="#method-i-eot">#eot</a></li>
87
+
88
+ <li><a href="#method-i-error">#error</a></li>
89
+
90
+ <li><a href="#method-i-get_bytes">#get_bytes</a></li>
91
+
92
+ <li><a href="#method-i-getc">#getc</a></li>
93
+
94
+ <li><a href="#method-i-handle_arbitrary">#handle_arbitrary</a></li>
95
+
96
+ <li><a href="#method-i-handle_sysex">#handle_sysex</a></li>
97
+
98
+ <li><a href="#method-i-header">#header</a></li>
99
+
100
+ <li><a href="#method-i-key_signature">#key_signature</a></li>
101
+
102
+ <li><a href="#method-i-meta_event">#meta_event</a></li>
103
+
104
+ <li><a href="#method-i-meta_misc">#meta_misc</a></li>
105
+
106
+ <li><a href="#method-i-msg">#msg</a></li>
107
+
108
+ <li><a href="#method-i-msg_add">#msg_add</a></li>
109
+
110
+ <li><a href="#method-i-msg_init">#msg_init</a></li>
111
+
112
+ <li><a href="#method-i-msg_read">#msg_read</a></li>
113
+
114
+ <li><a href="#method-i-note_off">#note_off</a></li>
115
+
116
+ <li><a href="#method-i-note_on">#note_on</a></li>
117
+
118
+ <li><a href="#method-i-pitch_bend">#pitch_bend</a></li>
119
+
120
+ <li><a href="#method-i-pressure">#pressure</a></li>
121
+
122
+ <li><a href="#method-i-program">#program</a></li>
123
+
124
+ <li><a href="#method-i-read16">#read16</a></li>
125
+
126
+ <li><a href="#method-i-read32">#read32</a></li>
127
+
128
+ <li><a href="#method-i-read_from">#read_from</a></li>
129
+
130
+ <li><a href="#method-i-read_header">#read_header</a></li>
131
+
132
+ <li><a href="#method-i-read_mt_header_string">#read_mt_header_string</a></li>
133
+
134
+ <li><a href="#method-i-read_track">#read_track</a></li>
135
+
136
+ <li><a href="#method-i-read_var_len">#read_var_len</a></li>
137
+
138
+ <li><a href="#method-i-sequence_number">#sequence_number</a></li>
139
+
140
+ <li><a href="#method-i-sequencer_specific">#sequencer_specific</a></li>
141
+
142
+ <li><a href="#method-i-smpte">#smpte</a></li>
143
+
144
+ <li><a href="#method-i-start_track">#start_track</a></li>
145
+
146
+ <li><a href="#method-i-sysex">#sysex</a></li>
147
+
148
+ <li><a href="#method-i-tempo">#tempo</a></li>
149
+
150
+ <li><a href="#method-i-text">#text</a></li>
151
+
152
+ <li><a href="#method-i-time_signature">#time_signature</a></li>
153
+
154
+ <li><a href="#method-i-write16">#write16</a></li>
155
+
156
+ <li><a href="#method-i-write32">#write32</a></li>
157
+
158
+ <li><a href="#method-i-write_var_len">#write_var_len</a></li>
159
+
160
+ </ul>
161
+ </div>
162
+
163
+
164
+ <!-- Included Modules -->
165
+
166
+ </div>
167
+
168
+ <div id="project-metadata">
169
+
170
+
171
+ <div id="fileindex-section" class="section project-section">
172
+ <h3 class="section-header">Files</h3>
173
+ <ul>
174
+
175
+ <li class="file"><a href="../../README_rdoc.html">README.rdoc</a></li>
176
+
177
+ <li class="file"><a href="../../TODO_rdoc.html">TODO.rdoc</a></li>
178
+
179
+ </ul>
180
+ </div>
181
+
182
+
183
+ <div id="classindex-section" class="section project-section">
184
+ <h3 class="section-header">Class Index
185
+ <span class="search-toggle"><img src="../../images/find.png"
186
+ height="16" width="16" alt="[+]"
187
+ title="show/hide quicksearch" /></span></h3>
188
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
189
+ <fieldset>
190
+ <legend>Quicksearch</legend>
191
+ <input type="text" name="quicksearch" value=""
192
+ class="quicksearch-field" />
193
+ </fieldset>
194
+ </form>
195
+
196
+ <ul class="link-list">
197
+
198
+ <li><a href="../../MIDI.html">MIDI</a></li>
199
+
200
+ <li><a href="../../MIDI/ActiveSense.html">MIDI::ActiveSense</a></li>
201
+
202
+ <li><a href="../../MIDI/ChannelEvent.html">MIDI::ChannelEvent</a></li>
203
+
204
+ <li><a href="../../MIDI/ChannelPressure.html">MIDI::ChannelPressure</a></li>
205
+
206
+ <li><a href="../../MIDI/Clock.html">MIDI::Clock</a></li>
207
+
208
+ <li><a href="../../MIDI/Continue.html">MIDI::Continue</a></li>
209
+
210
+ <li><a href="../../MIDI/Controller.html">MIDI::Controller</a></li>
211
+
212
+ <li><a href="../../MIDI/Event.html">MIDI::Event</a></li>
213
+
214
+ <li><a href="../../MIDI/IO.html">MIDI::IO</a></li>
215
+
216
+ <li><a href="../../MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a></li>
217
+
218
+ <li><a href="../../MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a></li>
219
+
220
+ <li><a href="../../MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a></li>
221
+
222
+ <li><a href="../../MIDI/KeySig.html">MIDI::KeySig</a></li>
223
+
224
+ <li><a href="../../MIDI/Marker.html">MIDI::Marker</a></li>
225
+
226
+ <li><a href="../../MIDI/Measure.html">MIDI::Measure</a></li>
227
+
228
+ <li><a href="../../MIDI/Measures.html">MIDI::Measures</a></li>
229
+
230
+ <li><a href="../../MIDI/MetaEvent.html">MIDI::MetaEvent</a></li>
231
+
232
+ <li><a href="../../MIDI/NoteEvent.html">MIDI::NoteEvent</a></li>
233
+
234
+ <li><a href="../../MIDI/NoteOff.html">MIDI::NoteOff</a></li>
235
+
236
+ <li><a href="../../MIDI/NoteOff.html">MIDI::NoteOff</a></li>
237
+
238
+ <li><a href="../../MIDI/NoteOn.html">MIDI::NoteOn</a></li>
239
+
240
+ <li><a href="../../MIDI/NoteOn.html">MIDI::NoteOn</a></li>
241
+
242
+ <li><a href="../../MIDI/PitchBend.html">MIDI::PitchBend</a></li>
243
+
244
+ <li><a href="../../MIDI/PolyPressure.html">MIDI::PolyPressure</a></li>
245
+
246
+ <li><a href="../../MIDI/ProgramChange.html">MIDI::ProgramChange</a></li>
247
+
248
+ <li><a href="../../MIDI/Realtime.html">MIDI::Realtime</a></li>
249
+
250
+ <li><a href="../../MIDI/Sequence.html">MIDI::Sequence</a></li>
251
+
252
+ <li><a href="../../MIDI/SongPointer.html">MIDI::SongPointer</a></li>
253
+
254
+ <li><a href="../../MIDI/SongSelect.html">MIDI::SongSelect</a></li>
255
+
256
+ <li><a href="../../MIDI/Start.html">MIDI::Start</a></li>
257
+
258
+ <li><a href="../../MIDI/Stop.html">MIDI::Stop</a></li>
259
+
260
+ <li><a href="../../MIDI/SystemCommon.html">MIDI::SystemCommon</a></li>
261
+
262
+ <li><a href="../../MIDI/SystemExclusive.html">MIDI::SystemExclusive</a></li>
263
+
264
+ <li><a href="../../MIDI/SystemReset.html">MIDI::SystemReset</a></li>
265
+
266
+ <li><a href="../../MIDI/Tempo.html">MIDI::Tempo</a></li>
267
+
268
+ <li><a href="../../MIDI/TimeSig.html">MIDI::TimeSig</a></li>
269
+
270
+ <li><a href="../../MIDI/Track.html">MIDI::Track</a></li>
271
+
272
+ <li><a href="../../MIDI/TuneRequest.html">MIDI::TuneRequest</a></li>
273
+
274
+ <li><a href="../../MIDI/Utils.html">MIDI::Utils</a></li>
275
+
276
+ <li><a href="../../Array.html">Array</a></li>
277
+
278
+ <li><a href="../../IO.html">IO</a></li>
279
+
280
+ </ul>
281
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
282
+ </div>
283
+
284
+
285
+ </div>
286
+ </div>
287
+
288
+ <div id="documentation">
289
+ <h1 class="class">MIDI::IO::MIDIFile</h1>
290
+
291
+ <div id="description">
292
+ <p>
293
+ A <a href="MIDIFile.html">MIDIFile</a> parses a <a
294
+ href="../../MIDI.html">MIDI</a> file and calls methods when it sees <a
295
+ href="../../MIDI.html">MIDI</a> events. Most of the methods are stubs. To
296
+ do anything interesting with the events, override these methods (those
297
+ between the &#8220;The rest of these are NOPs by default&#8221; and
298
+ &#8220;End of NOPs&#8221; comments).
299
+ </p>
300
+ <p>
301
+ See <a href="SeqReader.html">SeqReader</a> for a subclass that uses these
302
+ methods to create <a href="../Event.html">Event</a> objects.
303
+ </p>
304
+
305
+ </div>
306
+
307
+ <!-- Constants -->
308
+
309
+ <div id="constants-list" class="section">
310
+ <h3 class="section-header">Constants</h3>
311
+ <dl>
312
+
313
+ <dt><a name="MThd_BYTE_ARRAY">MThd_BYTE_ARRAY</a></dt>
314
+
315
+ <dd class="description"></dd>
316
+
317
+
318
+ <dt><a name="MTrk_BYTE_ARRAY">MTrk_BYTE_ARRAY</a></dt>
319
+
320
+ <dd class="description"></dd>
321
+
322
+
323
+ <dt><a name="NUM_DATA_BYTES">NUM_DATA_BYTES</a></dt>
324
+
325
+ <dd class="description"><p>
326
+ This array is indexed by the high half of a status byte. Its value is
327
+ either the number of bytes needed (1 or 2) for a channel message, or 0 if
328
+ it&#8217;s not a channel message.
329
+ </p></dd>
330
+
331
+
332
+ </dl>
333
+ </div>
334
+
335
+
336
+ <!-- Attributes -->
337
+
338
+ <div id="attribute-method-details" class="method-section section">
339
+ <h3 class="section-header">Attributes</h3>
340
+
341
+
342
+ <div id="curr-ticks-attribute-method" class="method-detail">
343
+ <a name="curr_ticks"></a>
344
+
345
+ <a name="curr_ticks="></a>
346
+
347
+ <div class="method-heading attribute-method-heading">
348
+ <span class="method-name">curr_ticks</span><span
349
+ class="attribute-access-type">[RW]</span>
350
+ </div>
351
+
352
+ <div class="method-description">
353
+
354
+
355
+
356
+ </div>
357
+ </div>
358
+
359
+ <div id="ticks-so-far-attribute-method" class="method-detail">
360
+ <a name="ticks_so_far"></a>
361
+
362
+ <a name="ticks_so_far="></a>
363
+
364
+ <div class="method-heading attribute-method-heading">
365
+ <span class="method-name">ticks_so_far</span><span
366
+ class="attribute-access-type">[RW]</span>
367
+ </div>
368
+
369
+ <div class="method-description">
370
+
371
+
372
+
373
+ </div>
374
+ </div>
375
+
376
+ <div id="bytes-to-be-read-attribute-method" class="method-detail">
377
+ <a name="bytes_to_be_read"></a>
378
+
379
+ <a name="bytes_to_be_read="></a>
380
+
381
+ <div class="method-heading attribute-method-heading">
382
+ <span class="method-name">bytes_to_be_read</span><span
383
+ class="attribute-access-type">[RW]</span>
384
+ </div>
385
+
386
+ <div class="method-description">
387
+
388
+
389
+
390
+ </div>
391
+ </div>
392
+
393
+ <div id="no-merge-attribute-method" class="method-detail">
394
+ <a name="no_merge"></a>
395
+
396
+ <a name="no_merge="></a>
397
+
398
+ <div class="method-heading attribute-method-heading">
399
+ <span class="method-name">no_merge</span><span
400
+ class="attribute-access-type">[RW]</span>
401
+ </div>
402
+
403
+ <div class="method-description">
404
+
405
+
406
+
407
+ </div>
408
+ </div>
409
+
410
+ <div id="skip-init-attribute-method" class="method-detail">
411
+ <a name="skip_init"></a>
412
+
413
+ <a name="skip_init="></a>
414
+
415
+ <div class="method-heading attribute-method-heading">
416
+ <span class="method-name">skip_init</span><span
417
+ class="attribute-access-type">[RW]</span>
418
+ </div>
419
+
420
+ <div class="method-description">
421
+
422
+
423
+
424
+ </div>
425
+ </div>
426
+
427
+ <div id="raw-time-stamp-data-attribute-method" class="method-detail">
428
+ <a name="raw_time_stamp_data"></a>
429
+
430
+ <a name="raw_time_stamp_data="></a>
431
+
432
+ <div class="method-heading attribute-method-heading">
433
+ <span class="method-name">raw_time_stamp_data</span><span
434
+ class="attribute-access-type">[RW]</span>
435
+ </div>
436
+
437
+ <div class="method-description">
438
+
439
+ <p>
440
+ Raw data info
441
+ </p>
442
+
443
+ </div>
444
+ </div>
445
+
446
+ <div id="raw-var-num-data-attribute-method" class="method-detail">
447
+ <a name="raw_var_num_data"></a>
448
+
449
+ <a name="raw_var_num_data="></a>
450
+
451
+ <div class="method-heading attribute-method-heading">
452
+ <span class="method-name">raw_var_num_data</span><span
453
+ class="attribute-access-type">[RW]</span>
454
+ </div>
455
+
456
+ <div class="method-description">
457
+
458
+
459
+
460
+ </div>
461
+ </div>
462
+
463
+ <div id="raw-data-attribute-method" class="method-detail">
464
+ <a name="raw_data"></a>
465
+
466
+ <a name="raw_data="></a>
467
+
468
+ <div class="method-heading attribute-method-heading">
469
+ <span class="method-name">raw_data</span><span
470
+ class="attribute-access-type">[RW]</span>
471
+ </div>
472
+
473
+ <div class="method-description">
474
+
475
+
476
+
477
+ </div>
478
+ </div>
479
+
480
+ </div>
481
+
482
+
483
+ <!-- Methods -->
484
+
485
+ <div id="public-class-method-details" class="method-section section">
486
+ <h3 class="section-header">Public Class Methods</h3>
487
+
488
+
489
+ <div id="new-method" class="method-detail ">
490
+ <a name="method-c-new"></a>
491
+
492
+ <div class="method-heading">
493
+
494
+ <span class="method-name">new</span><span
495
+ class="method-args">()</span>
496
+ <span class="method-click-advice">click to toggle source</span>
497
+
498
+ </div>
499
+
500
+ <div class="method-description">
501
+
502
+
503
+
504
+
505
+
506
+ <div class="method-source-code"
507
+ id="new-source">
508
+ <pre>
509
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 49</span>
510
+ 49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
511
+ 50: <span class="ruby-ivar">@no_merge</span> = <span class="ruby-keyword kw">false</span>
512
+ 51: <span class="ruby-ivar">@skip_init</span> = <span class="ruby-keyword kw">true</span>
513
+ 52: <span class="ruby-ivar">@io</span> = <span class="ruby-keyword kw">nil</span>
514
+ 53: <span class="ruby-ivar">@bytes_to_be_read</span> = <span class="ruby-value">0</span>
515
+ 54: <span class="ruby-ivar">@msg_buf</span> = <span class="ruby-keyword kw">nil</span>
516
+ 55: <span class="ruby-keyword kw">end</span></pre>
517
+ </div>
518
+
519
+ </div>
520
+
521
+
522
+
523
+
524
+ </div>
525
+
526
+
527
+ </div>
528
+
529
+ <div id="public-instance-method-details" class="method-section section">
530
+ <h3 class="section-header">Public Instance Methods</h3>
531
+
532
+
533
+ <div id="arbitrary-method" class="method-detail ">
534
+ <a name="method-i-arbitrary"></a>
535
+
536
+ <div class="method-heading">
537
+
538
+ <span class="method-name">arbitrary</span><span
539
+ class="method-args">(msg)</span>
540
+ <span class="method-click-advice">click to toggle source</span>
541
+
542
+ </div>
543
+
544
+ <div class="method-description">
545
+
546
+
547
+
548
+
549
+
550
+ <div class="method-source-code"
551
+ id="arbitrary-source">
552
+ <pre>
553
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 152</span>
554
+ 152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">arbitrary</span>(<span class="ruby-identifier">msg</span>)
555
+ 153: <span class="ruby-keyword kw">end</span></pre>
556
+ </div>
557
+
558
+ </div>
559
+
560
+
561
+
562
+
563
+ </div>
564
+
565
+
566
+ <div id="bad-byte-method" class="method-detail ">
567
+ <a name="method-i-bad_byte"></a>
568
+
569
+ <div class="method-heading">
570
+
571
+ <span class="method-name">bad_byte</span><span
572
+ class="method-args">(c)</span>
573
+ <span class="method-click-advice">click to toggle source</span>
574
+
575
+ </div>
576
+
577
+ <div class="method-description">
578
+
579
+ <p>
580
+ Handle an unexpected byte.
581
+ </p>
582
+
583
+
584
+
585
+ <div class="method-source-code"
586
+ id="bad-byte-source">
587
+ <pre>
588
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 294</span>
589
+ 294: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bad_byte</span>(<span class="ruby-identifier">c</span>)
590
+ 295: <span class="ruby-identifier">error</span>(<span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">&quot;unexpected byte: 0x%02x&quot;</span>, <span class="ruby-identifier">c</span>))
591
+ 296: <span class="ruby-keyword kw">end</span></pre>
592
+ </div>
593
+
594
+ </div>
595
+
596
+
597
+
598
+
599
+ </div>
600
+
601
+
602
+ <div id="chan-message-method" class="method-detail ">
603
+ <a name="method-i-chan_message"></a>
604
+
605
+ <div class="method-heading">
606
+
607
+ <span class="method-name">chan_message</span><span
608
+ class="method-args">(running, status, c1, c2)</span>
609
+ <span class="method-click-advice">click to toggle source</span>
610
+
611
+ </div>
612
+
613
+ <div class="method-description">
614
+
615
+ <p>
616
+ Handle a channel message (note on, note off, etc.)
617
+ </p>
618
+
619
+
620
+
621
+ <div class="method-source-code"
622
+ id="chan-message-source">
623
+ <pre>
624
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 335</span>
625
+ 335: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chan_message</span>(<span class="ruby-identifier">running</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">c1</span>, <span class="ruby-identifier">c2</span>)
626
+ 336: <span class="ruby-ivar">@raw_data</span> = []
627
+ 337: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">running</span>
628
+ 338: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c1</span>
629
+ 339: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c2</span>
630
+ 340:
631
+ 341: <span class="ruby-identifier">chan</span> = <span class="ruby-identifier">status</span> &amp; <span class="ruby-value">0x0f</span>
632
+ 342:
633
+ 343: <span class="ruby-keyword kw">case</span> (<span class="ruby-identifier">status</span> &amp; <span class="ruby-value">0xf0</span>)
634
+ 344: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">NOTE_OFF</span>
635
+ 345: <span class="ruby-identifier">note_off</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>, <span class="ruby-identifier">c2</span>)
636
+ 346: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">NOTE_ON</span>
637
+ 347: <span class="ruby-identifier">note_on</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>, <span class="ruby-identifier">c2</span>)
638
+ 348: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">POLY_PRESSURE</span>
639
+ 349: <span class="ruby-identifier">pressure</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>, <span class="ruby-identifier">c2</span>)
640
+ 350: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">CONTROLLER</span>
641
+ 351: <span class="ruby-identifier">controller</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>, <span class="ruby-identifier">c2</span>)
642
+ 352: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">PITCH_BEND</span>
643
+ 353: <span class="ruby-identifier">pitch_bend</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>, <span class="ruby-identifier">c2</span>)
644
+ 354: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">PROGRAM_CHANGE</span>
645
+ 355: <span class="ruby-identifier">program</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>)
646
+ 356: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">CHANNEL_PRESSURE</span>
647
+ 357: <span class="ruby-identifier">chan_pressure</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">c1</span>)
648
+ 358: <span class="ruby-keyword kw">else</span>
649
+ 359: <span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;illegal chan message 0x#{'%02x' % (status &amp; 0xf0)}\n&quot;</span>)
650
+ 360: <span class="ruby-keyword kw">end</span>
651
+ 361: <span class="ruby-keyword kw">end</span></pre>
652
+ </div>
653
+
654
+ </div>
655
+
656
+
657
+
658
+
659
+ </div>
660
+
661
+
662
+ <div id="chan-pressure-method" class="method-detail ">
663
+ <a name="method-i-chan_pressure"></a>
664
+
665
+ <div class="method-heading">
666
+
667
+ <span class="method-name">chan_pressure</span><span
668
+ class="method-args">(chan, press)</span>
669
+ <span class="method-click-advice">click to toggle source</span>
670
+
671
+ </div>
672
+
673
+ <div class="method-description">
674
+
675
+
676
+
677
+
678
+
679
+ <div class="method-source-code"
680
+ id="chan-pressure-source">
681
+ <pre>
682
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 119</span>
683
+ 119: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chan_pressure</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">press</span>)
684
+ 120: <span class="ruby-keyword kw">end</span></pre>
685
+ </div>
686
+
687
+ </div>
688
+
689
+
690
+
691
+
692
+ </div>
693
+
694
+
695
+ <div id="controller-method" class="method-detail ">
696
+ <a name="method-i-controller"></a>
697
+
698
+ <div class="method-heading">
699
+
700
+ <span class="method-name">controller</span><span
701
+ class="method-args">(chan, control, value)</span>
702
+ <span class="method-click-advice">click to toggle source</span>
703
+
704
+ </div>
705
+
706
+ <div class="method-description">
707
+
708
+
709
+
710
+
711
+
712
+ <div class="method-source-code"
713
+ id="controller-source">
714
+ <pre>
715
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 110</span>
716
+ 110: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">controller</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">control</span>, <span class="ruby-identifier">value</span>)
717
+ 111: <span class="ruby-keyword kw">end</span></pre>
718
+ </div>
719
+
720
+ </div>
721
+
722
+
723
+
724
+
725
+ </div>
726
+
727
+
728
+ <div id="end-track-method" class="method-detail ">
729
+ <a name="method-i-end_track"></a>
730
+
731
+ <div class="method-heading">
732
+
733
+ <span class="method-name">end_track</span><span
734
+ class="method-args">()</span>
735
+ <span class="method-click-advice">click to toggle source</span>
736
+
737
+ </div>
738
+
739
+ <div class="method-description">
740
+
741
+
742
+
743
+
744
+
745
+ <div class="method-source-code"
746
+ id="end-track-source">
747
+ <pre>
748
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 98</span>
749
+ 98: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_track</span>()
750
+ 99: <span class="ruby-keyword kw">end</span></pre>
751
+ </div>
752
+
753
+ </div>
754
+
755
+
756
+
757
+
758
+ </div>
759
+
760
+
761
+ <div id="eot-method" class="method-detail ">
762
+ <a name="method-i-eot"></a>
763
+
764
+ <div class="method-heading">
765
+
766
+ <span class="method-name">eot</span><span
767
+ class="method-args">()</span>
768
+ <span class="method-click-advice">click to toggle source</span>
769
+
770
+ </div>
771
+
772
+ <div class="method-description">
773
+
774
+
775
+
776
+
777
+
778
+ <div class="method-source-code"
779
+ id="eot-source">
780
+ <pre>
781
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 137</span>
782
+ 137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eot</span>()
783
+ 138: <span class="ruby-keyword kw">end</span></pre>
784
+ </div>
785
+
786
+ </div>
787
+
788
+
789
+
790
+
791
+ </div>
792
+
793
+
794
+ <div id="error-method" class="method-detail ">
795
+ <a name="method-i-error"></a>
796
+
797
+ <div class="method-heading">
798
+
799
+ <span class="method-name">error</span><span
800
+ class="method-args">(str)</span>
801
+ <span class="method-click-advice">click to toggle source</span>
802
+
803
+ </div>
804
+
805
+ <div class="method-description">
806
+
807
+ <p>
808
+ The default error handler.
809
+ </p>
810
+
811
+
812
+
813
+ <div class="method-source-code"
814
+ id="error-source">
815
+ <pre>
816
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 84</span>
817
+ 84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error</span>(<span class="ruby-identifier">str</span>)
818
+ 85: <span class="ruby-identifier">loc</span> = <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">tell</span>() <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
819
+ 86: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{self.class.name} error at byte #{loc} (0x#{'%02x' % loc}): #{str}&quot;</span>
820
+ 87: <span class="ruby-keyword kw">end</span></pre>
821
+ </div>
822
+
823
+ </div>
824
+
825
+
826
+
827
+
828
+ </div>
829
+
830
+
831
+ <div id="get-bytes-method" class="method-detail ">
832
+ <a name="method-i-get_bytes"></a>
833
+
834
+ <div class="method-heading">
835
+
836
+ <span class="method-name">get_bytes</span><span
837
+ class="method-args">(n)</span>
838
+ <span class="method-click-advice">click to toggle source</span>
839
+
840
+ </div>
841
+
842
+ <div class="method-description">
843
+
844
+ <p>
845
+ Return the next <tt>n</tt> bytes from @io as an array.
846
+ </p>
847
+
848
+
849
+
850
+ <div class="method-source-code"
851
+ id="get-bytes-source">
852
+ <pre>
853
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 77</span>
854
+ 77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_bytes</span>(<span class="ruby-identifier">n</span>)
855
+ 78: <span class="ruby-identifier">buf</span> = []
856
+ 79: <span class="ruby-identifier">n</span>.<span class="ruby-identifier">times</span> { <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">getc</span>() }
857
+ 80: <span class="ruby-identifier">buf</span>
858
+ 81: <span class="ruby-keyword kw">end</span></pre>
859
+ </div>
860
+
861
+ </div>
862
+
863
+
864
+
865
+
866
+ </div>
867
+
868
+
869
+ <div id="getc-method" class="method-detail ">
870
+ <a name="method-i-getc"></a>
871
+
872
+ <div class="method-heading">
873
+
874
+ <span class="method-name">getc</span><span
875
+ class="method-args">()</span>
876
+ <span class="method-click-advice">click to toggle source</span>
877
+
878
+ </div>
879
+
880
+ <div class="method-description">
881
+
882
+ <p>
883
+ This default getc implementation tries to read a single byte from io and
884
+ returns it as an integer.
885
+ </p>
886
+
887
+
888
+
889
+ <div class="method-source-code"
890
+ id="getc-source">
891
+ <pre>
892
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 71</span>
893
+ 71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getc</span>
894
+ 72: <span class="ruby-ivar">@bytes_to_be_read</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
895
+ 73: <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">readbyte</span>()
896
+ 74: <span class="ruby-keyword kw">end</span></pre>
897
+ </div>
898
+
899
+ </div>
900
+
901
+
902
+
903
+
904
+ </div>
905
+
906
+
907
+ <div id="handle-arbitrary-method" class="method-detail ">
908
+ <a name="method-i-handle_arbitrary"></a>
909
+
910
+ <div class="method-heading">
911
+
912
+ <span class="method-name">handle_arbitrary</span><span
913
+ class="method-args">(msg)</span>
914
+ <span class="method-click-advice">click to toggle source</span>
915
+
916
+ </div>
917
+
918
+ <div class="method-description">
919
+
920
+ <p>
921
+ Copy message into raw data array, then call arbitrary().
922
+ </p>
923
+
924
+
925
+
926
+ <div class="method-source-code"
927
+ id="handle-arbitrary-source">
928
+ <pre>
929
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 370</span>
930
+ 370: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_arbitrary</span>(<span class="ruby-identifier">msg</span>)
931
+ 371: <span class="ruby-ivar">@raw_data</span> = <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">dup</span>()
932
+ 372: <span class="ruby-identifier">arbitrary</span>(<span class="ruby-identifier">msg</span>)
933
+ 373: <span class="ruby-keyword kw">end</span></pre>
934
+ </div>
935
+
936
+ </div>
937
+
938
+
939
+
940
+
941
+ </div>
942
+
943
+
944
+ <div id="handle-sysex-method" class="method-detail ">
945
+ <a name="method-i-handle_sysex"></a>
946
+
947
+ <div class="method-heading">
948
+
949
+ <span class="method-name">handle_sysex</span><span
950
+ class="method-args">(msg)</span>
951
+ <span class="method-click-advice">click to toggle source</span>
952
+
953
+ </div>
954
+
955
+ <div class="method-description">
956
+
957
+ <p>
958
+ Copy message into raw data array, then call sysex().
959
+ </p>
960
+
961
+
962
+
963
+ <div class="method-source-code"
964
+ id="handle-sysex-source">
965
+ <pre>
966
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 364</span>
967
+ 364: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_sysex</span>(<span class="ruby-identifier">msg</span>)
968
+ 365: <span class="ruby-ivar">@raw_data</span> = <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">dup</span>()
969
+ 366: <span class="ruby-identifier">sysex</span>(<span class="ruby-identifier">msg</span>)
970
+ 367: <span class="ruby-keyword kw">end</span></pre>
971
+ </div>
972
+
973
+ </div>
974
+
975
+
976
+
977
+
978
+ </div>
979
+
980
+
981
+ <div id="header-method" class="method-detail ">
982
+ <a name="method-i-header"></a>
983
+
984
+ <div class="method-heading">
985
+
986
+ <span class="method-name">header</span><span
987
+ class="method-args">(format, ntrks, division)</span>
988
+ <span class="method-click-advice">click to toggle source</span>
989
+
990
+ </div>
991
+
992
+ <div class="method-description">
993
+
994
+ <p>
995
+ <a href="../../MIDI.html">MIDI</a> header.
996
+ </p>
997
+
998
+
999
+
1000
+ <div class="method-source-code"
1001
+ id="header-source">
1002
+ <pre>
1003
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 92</span>
1004
+ 92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">header</span>(<span class="ruby-identifier">format</span>, <span class="ruby-identifier">ntrks</span>, <span class="ruby-identifier">division</span>)
1005
+ 93: <span class="ruby-keyword kw">end</span></pre>
1006
+ </div>
1007
+
1008
+ </div>
1009
+
1010
+
1011
+
1012
+
1013
+ </div>
1014
+
1015
+
1016
+ <div id="key-signature-method" class="method-detail ">
1017
+ <a name="method-i-key_signature"></a>
1018
+
1019
+ <div class="method-heading">
1020
+
1021
+ <span class="method-name">key_signature</span><span
1022
+ class="method-args">(sharpflat, is_minor)</span>
1023
+ <span class="method-click-advice">click to toggle source</span>
1024
+
1025
+ </div>
1026
+
1027
+ <div class="method-description">
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+ <div class="method-source-code"
1034
+ id="key-signature-source">
1035
+ <pre>
1036
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 149</span>
1037
+ 149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">key_signature</span>(<span class="ruby-identifier">sharpflat</span>, <span class="ruby-identifier">is_minor</span>)
1038
+ 150: <span class="ruby-keyword kw">end</span></pre>
1039
+ </div>
1040
+
1041
+ </div>
1042
+
1043
+
1044
+
1045
+
1046
+ </div>
1047
+
1048
+
1049
+ <div id="meta-event-method" class="method-detail ">
1050
+ <a name="method-i-meta_event"></a>
1051
+
1052
+ <div class="method-heading">
1053
+
1054
+ <span class="method-name">meta_event</span><span
1055
+ class="method-args">(type)</span>
1056
+ <span class="method-click-advice">click to toggle source</span>
1057
+
1058
+ </div>
1059
+
1060
+ <div class="method-description">
1061
+
1062
+ <p>
1063
+ Handle a meta event.
1064
+ </p>
1065
+
1066
+
1067
+
1068
+ <div class="method-source-code"
1069
+ id="meta-event-source">
1070
+ <pre>
1071
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 299</span>
1072
+ 299: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">meta_event</span>(<span class="ruby-identifier">type</span>)
1073
+ 300: <span class="ruby-identifier">m</span> = <span class="ruby-identifier">msg</span>() <span class="ruby-comment cmt"># Copy of internal message buffer</span>
1074
+ 301:
1075
+ 302: <span class="ruby-comment cmt"># Create raw data array</span>
1076
+ 303: <span class="ruby-ivar">@raw_data</span> = []
1077
+ 304: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">META_EVENT</span>
1078
+ 305: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">type</span>
1079
+ 306: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@raw_var_num_data</span>
1080
+ 307: <span class="ruby-ivar">@raw_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">m</span>
1081
+ 308: <span class="ruby-ivar">@raw_data</span>.<span class="ruby-identifier">flatten!</span>
1082
+ 309:
1083
+ 310: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">type</span>
1084
+ 311: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_SEQ_NUM</span>
1085
+ 312: <span class="ruby-identifier">sequence_number</span>((<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">8</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>])
1086
+ 313: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_TEXT</span>, <span class="ruby-constant">META_COPYRIGHT</span>, <span class="ruby-constant">META_SEQ_NAME</span>, <span class="ruby-constant">META_INSTRUMENT</span>,
1087
+ 314: <span class="ruby-constant">META_LYRIC</span>, <span class="ruby-constant">META_MARKER</span>, <span class="ruby-constant">META_CUE</span>, <span class="ruby-value">0x08</span>, <span class="ruby-value">0x09</span>, <span class="ruby-value">0x0a</span>,
1088
+ 315: <span class="ruby-value">0x0b</span>, <span class="ruby-value">0x0c</span>, <span class="ruby-value">0x0d</span>, <span class="ruby-value">0x0e</span>, <span class="ruby-value">0x0f</span>
1089
+ 316: <span class="ruby-identifier">text</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">m</span>)
1090
+ 317: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_TRACK_END</span>
1091
+ 318: <span class="ruby-identifier">eot</span>()
1092
+ 319: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_SET_TEMPO</span>
1093
+ 320: <span class="ruby-identifier">tempo</span>((<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">16</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">8</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>])
1094
+ 321: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_SMPTE</span>
1095
+ 322: <span class="ruby-identifier">smpte</span>(<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">4</span>])
1096
+ 323: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_TIME_SIG</span>
1097
+ 324: <span class="ruby-identifier">time_signature</span>(<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>])
1098
+ 325: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_KEY_SIG</span>
1099
+ 326: <span class="ruby-identifier">key_signature</span>(<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">true</span>)
1100
+ 327: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_SEQ_SPECIF</span>
1101
+ 328: <span class="ruby-identifier">sequencer_specific</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">m</span>)
1102
+ 329: <span class="ruby-keyword kw">else</span>
1103
+ 330: <span class="ruby-identifier">meta_misc</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">m</span>)
1104
+ 331: <span class="ruby-keyword kw">end</span>
1105
+ 332: <span class="ruby-keyword kw">end</span></pre>
1106
+ </div>
1107
+
1108
+ </div>
1109
+
1110
+
1111
+
1112
+
1113
+ </div>
1114
+
1115
+
1116
+ <div id="meta-misc-method" class="method-detail ">
1117
+ <a name="method-i-meta_misc"></a>
1118
+
1119
+ <div class="method-heading">
1120
+
1121
+ <span class="method-name">meta_misc</span><span
1122
+ class="method-args">(type, msg)</span>
1123
+ <span class="method-click-advice">click to toggle source</span>
1124
+
1125
+ </div>
1126
+
1127
+ <div class="method-description">
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+ <div class="method-source-code"
1134
+ id="meta-misc-source">
1135
+ <pre>
1136
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 125</span>
1137
+ 125: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">meta_misc</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">msg</span>)
1138
+ 126: <span class="ruby-keyword kw">end</span></pre>
1139
+ </div>
1140
+
1141
+ </div>
1142
+
1143
+
1144
+
1145
+
1146
+ </div>
1147
+
1148
+
1149
+ <div id="msg-method" class="method-detail ">
1150
+ <a name="method-i-msg"></a>
1151
+
1152
+ <div class="method-heading">
1153
+
1154
+ <span class="method-name">msg</span><span
1155
+ class="method-args">()</span>
1156
+ <span class="method-click-advice">click to toggle source</span>
1157
+
1158
+ </div>
1159
+
1160
+ <div class="method-description">
1161
+
1162
+ <p>
1163
+ Return a copy of the internal message buffer.
1164
+ </p>
1165
+
1166
+
1167
+
1168
+ <div class="method-source-code"
1169
+ id="msg-source">
1170
+ <pre>
1171
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 460</span>
1172
+ 460: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">msg</span>
1173
+ 461: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@msg_buf</span>.<span class="ruby-identifier">dup</span>()
1174
+ 462: <span class="ruby-keyword kw">end</span></pre>
1175
+ </div>
1176
+
1177
+ </div>
1178
+
1179
+
1180
+
1181
+
1182
+ </div>
1183
+
1184
+
1185
+ <div id="msg-add-method" class="method-detail ">
1186
+ <a name="method-i-msg_add"></a>
1187
+
1188
+ <div class="method-heading">
1189
+
1190
+ <span class="method-name">msg_add</span><span
1191
+ class="method-args">(c)</span>
1192
+ <span class="method-click-advice">click to toggle source</span>
1193
+
1194
+ </div>
1195
+
1196
+ <div class="method-description">
1197
+
1198
+ <p>
1199
+ Add a byte to the current message buffer.
1200
+ </p>
1201
+
1202
+
1203
+
1204
+ <div class="method-source-code"
1205
+ id="msg-add-source">
1206
+ <pre>
1207
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 442</span>
1208
+ 442: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">msg_add</span>(<span class="ruby-identifier">c</span>)
1209
+ 443: <span class="ruby-ivar">@msg_buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span>
1210
+ 444: <span class="ruby-keyword kw">end</span></pre>
1211
+ </div>
1212
+
1213
+ </div>
1214
+
1215
+
1216
+
1217
+
1218
+ </div>
1219
+
1220
+
1221
+ <div id="msg-init-method" class="method-detail ">
1222
+ <a name="method-i-msg_init"></a>
1223
+
1224
+ <div class="method-heading">
1225
+
1226
+ <span class="method-name">msg_init</span><span
1227
+ class="method-args">()</span>
1228
+ <span class="method-click-advice">click to toggle source</span>
1229
+
1230
+ </div>
1231
+
1232
+ <div class="method-description">
1233
+
1234
+ <p>
1235
+ Initialize the internal message buffer.
1236
+ </p>
1237
+
1238
+
1239
+
1240
+ <div class="method-source-code"
1241
+ id="msg-init-source">
1242
+ <pre>
1243
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 455</span>
1244
+ 455: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">msg_init</span>
1245
+ 456: <span class="ruby-ivar">@msg_buf</span> = []
1246
+ 457: <span class="ruby-keyword kw">end</span></pre>
1247
+ </div>
1248
+
1249
+ </div>
1250
+
1251
+
1252
+
1253
+
1254
+ </div>
1255
+
1256
+
1257
+ <div id="msg-read-method" class="method-detail ">
1258
+ <a name="method-i-msg_read"></a>
1259
+
1260
+ <div class="method-heading">
1261
+
1262
+ <span class="method-name">msg_read</span><span
1263
+ class="method-args">(n_bytes)</span>
1264
+ <span class="method-click-advice">click to toggle source</span>
1265
+
1266
+ </div>
1267
+
1268
+ <div class="method-description">
1269
+
1270
+ <p>
1271
+ Read and add a number of bytes to the message buffer. Return the last byte
1272
+ (so we can see if it&#8217;s an EOX or not).
1273
+ </p>
1274
+
1275
+
1276
+
1277
+ <div class="method-source-code"
1278
+ id="msg-read-source">
1279
+ <pre>
1280
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 448</span>
1281
+ 448: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">msg_read</span>(<span class="ruby-identifier">n_bytes</span>)
1282
+ 449: <span class="ruby-ivar">@msg_buf</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">get_bytes</span>(<span class="ruby-identifier">n_bytes</span>)
1283
+ 450: <span class="ruby-ivar">@msg_buf</span>.<span class="ruby-identifier">flatten!</span>
1284
+ 451: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@msg_buf</span>[<span class="ruby-value">1</span>]
1285
+ 452: <span class="ruby-keyword kw">end</span></pre>
1286
+ </div>
1287
+
1288
+ </div>
1289
+
1290
+
1291
+
1292
+
1293
+ </div>
1294
+
1295
+
1296
+ <div id="note-off-method" class="method-detail ">
1297
+ <a name="method-i-note_off"></a>
1298
+
1299
+ <div class="method-heading">
1300
+
1301
+ <span class="method-name">note_off</span><span
1302
+ class="method-args">(chan, note, vel)</span>
1303
+ <span class="method-click-advice">click to toggle source</span>
1304
+
1305
+ </div>
1306
+
1307
+ <div class="method-description">
1308
+
1309
+
1310
+
1311
+
1312
+
1313
+ <div class="method-source-code"
1314
+ id="note-off-source">
1315
+ <pre>
1316
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 104</span>
1317
+ 104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">note_off</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">note</span>, <span class="ruby-identifier">vel</span>)
1318
+ 105: <span class="ruby-keyword kw">end</span></pre>
1319
+ </div>
1320
+
1321
+ </div>
1322
+
1323
+
1324
+
1325
+
1326
+ </div>
1327
+
1328
+
1329
+ <div id="note-on-method" class="method-detail ">
1330
+ <a name="method-i-note_on"></a>
1331
+
1332
+ <div class="method-heading">
1333
+
1334
+ <span class="method-name">note_on</span><span
1335
+ class="method-args">(chan, note, vel)</span>
1336
+ <span class="method-click-advice">click to toggle source</span>
1337
+
1338
+ </div>
1339
+
1340
+ <div class="method-description">
1341
+
1342
+
1343
+
1344
+
1345
+
1346
+ <div class="method-source-code"
1347
+ id="note-on-source">
1348
+ <pre>
1349
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 101</span>
1350
+ 101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">note_on</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">note</span>, <span class="ruby-identifier">vel</span>)
1351
+ 102: <span class="ruby-keyword kw">end</span></pre>
1352
+ </div>
1353
+
1354
+ </div>
1355
+
1356
+
1357
+
1358
+
1359
+ </div>
1360
+
1361
+
1362
+ <div id="pitch-bend-method" class="method-detail ">
1363
+ <a name="method-i-pitch_bend"></a>
1364
+
1365
+ <div class="method-heading">
1366
+
1367
+ <span class="method-name">pitch_bend</span><span
1368
+ class="method-args">(chan, msb, lsb)</span>
1369
+ <span class="method-click-advice">click to toggle source</span>
1370
+
1371
+ </div>
1372
+
1373
+ <div class="method-description">
1374
+
1375
+
1376
+
1377
+
1378
+
1379
+ <div class="method-source-code"
1380
+ id="pitch-bend-source">
1381
+ <pre>
1382
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 113</span>
1383
+ 113: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pitch_bend</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">msb</span>, <span class="ruby-identifier">lsb</span>)
1384
+ 114: <span class="ruby-keyword kw">end</span></pre>
1385
+ </div>
1386
+
1387
+ </div>
1388
+
1389
+
1390
+
1391
+
1392
+ </div>
1393
+
1394
+
1395
+ <div id="pressure-method" class="method-detail ">
1396
+ <a name="method-i-pressure"></a>
1397
+
1398
+ <div class="method-heading">
1399
+
1400
+ <span class="method-name">pressure</span><span
1401
+ class="method-args">(chan, note, press)</span>
1402
+ <span class="method-click-advice">click to toggle source</span>
1403
+
1404
+ </div>
1405
+
1406
+ <div class="method-description">
1407
+
1408
+
1409
+
1410
+
1411
+
1412
+ <div class="method-source-code"
1413
+ id="pressure-source">
1414
+ <pre>
1415
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 107</span>
1416
+ 107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pressure</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">note</span>, <span class="ruby-identifier">press</span>)
1417
+ 108: <span class="ruby-keyword kw">end</span></pre>
1418
+ </div>
1419
+
1420
+ </div>
1421
+
1422
+
1423
+
1424
+
1425
+ </div>
1426
+
1427
+
1428
+ <div id="program-method" class="method-detail ">
1429
+ <a name="method-i-program"></a>
1430
+
1431
+ <div class="method-heading">
1432
+
1433
+ <span class="method-name">program</span><span
1434
+ class="method-args">(chan, program)</span>
1435
+ <span class="method-click-advice">click to toggle source</span>
1436
+
1437
+ </div>
1438
+
1439
+ <div class="method-description">
1440
+
1441
+
1442
+
1443
+
1444
+
1445
+ <div class="method-source-code"
1446
+ id="program-source">
1447
+ <pre>
1448
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 116</span>
1449
+ 116: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">program</span>(<span class="ruby-identifier">chan</span>, <span class="ruby-identifier">program</span>)
1450
+ 117: <span class="ruby-keyword kw">end</span></pre>
1451
+ </div>
1452
+
1453
+ </div>
1454
+
1455
+
1456
+
1457
+
1458
+ </div>
1459
+
1460
+
1461
+ <div id="read--method" class="method-detail ">
1462
+ <a name="method-i-read16"></a>
1463
+
1464
+ <div class="method-heading">
1465
+
1466
+ <span class="method-name">read16</span><span
1467
+ class="method-args">()</span>
1468
+ <span class="method-click-advice">click to toggle source</span>
1469
+
1470
+ </div>
1471
+
1472
+ <div class="method-description">
1473
+
1474
+ <p>
1475
+ Read and return a sixteen bit value.
1476
+ </p>
1477
+
1478
+
1479
+
1480
+ <div class="method-source-code"
1481
+ id="read--source">
1482
+ <pre>
1483
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 376</span>
1484
+ 376: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read16</span>
1485
+ 377: <span class="ruby-identifier">val</span> = (<span class="ruby-identifier">getc</span>() <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">8</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">getc</span>()
1486
+ 378: <span class="ruby-identifier">val</span> = <span class="ruby-operator">-</span>(<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x7fff</span>) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x8000</span>).<span class="ruby-identifier">nonzero?</span>
1487
+ 379: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
1488
+ 380: <span class="ruby-keyword kw">end</span></pre>
1489
+ </div>
1490
+
1491
+ </div>
1492
+
1493
+
1494
+
1495
+
1496
+ </div>
1497
+
1498
+
1499
+ <div id="read--method" class="method-detail ">
1500
+ <a name="method-i-read32"></a>
1501
+
1502
+ <div class="method-heading">
1503
+
1504
+ <span class="method-name">read32</span><span
1505
+ class="method-args">()</span>
1506
+ <span class="method-click-advice">click to toggle source</span>
1507
+
1508
+ </div>
1509
+
1510
+ <div class="method-description">
1511
+
1512
+ <p>
1513
+ Read and return a 32-bit value.
1514
+ </p>
1515
+
1516
+
1517
+
1518
+ <div class="method-source-code"
1519
+ id="read--source">
1520
+ <pre>
1521
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 383</span>
1522
+ 383: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read32</span>
1523
+ 384: <span class="ruby-identifier">val</span> = (<span class="ruby-identifier">getc</span>() <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">24</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">getc</span>() <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">16</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">getc</span>() <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">8</span>) <span class="ruby-operator">+</span>
1524
+ 385: <span class="ruby-identifier">getc</span>()
1525
+ 386: <span class="ruby-identifier">val</span> = <span class="ruby-operator">-</span>(<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x7fffffff</span>) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x80000000</span>).<span class="ruby-identifier">nonzero?</span>
1526
+ 387: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
1527
+ 388: <span class="ruby-keyword kw">end</span></pre>
1528
+ </div>
1529
+
1530
+ </div>
1531
+
1532
+
1533
+
1534
+
1535
+ </div>
1536
+
1537
+
1538
+ <div id="read-from-method" class="method-detail ">
1539
+ <a name="method-i-read_from"></a>
1540
+
1541
+ <div class="method-heading">
1542
+
1543
+ <span class="method-name">read_from</span><span
1544
+ class="method-args">(io)</span>
1545
+ <span class="method-click-advice">click to toggle source</span>
1546
+
1547
+ </div>
1548
+
1549
+ <div class="method-description">
1550
+
1551
+ <p>
1552
+ The only public method. Each <a href="../../MIDI.html">MIDI</a> event in
1553
+ the file causes a method to be called.
1554
+ </p>
1555
+
1556
+
1557
+
1558
+ <div class="method-source-code"
1559
+ id="read-from-source">
1560
+ <pre>
1561
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 59</span>
1562
+ 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_from</span>(<span class="ruby-identifier">io</span>)
1563
+ 60: <span class="ruby-identifier">error</span>(<span class="ruby-value str">'must specify non-nil input stream'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">nil?</span>
1564
+ 61: <span class="ruby-ivar">@io</span> = <span class="ruby-identifier">io</span>
1565
+ 62:
1566
+ 63: <span class="ruby-identifier">ntrks</span> = <span class="ruby-identifier">read_header</span>()
1567
+ 64: <span class="ruby-identifier">error</span>(<span class="ruby-value str">'No tracks!'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ntrks</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>
1568
+ 65:
1569
+ 66: <span class="ruby-identifier">ntrks</span>.<span class="ruby-identifier">times</span> { <span class="ruby-identifier">read_track</span>() }
1570
+ 67: <span class="ruby-keyword kw">end</span></pre>
1571
+ </div>
1572
+
1573
+ </div>
1574
+
1575
+
1576
+
1577
+
1578
+ </div>
1579
+
1580
+
1581
+ <div id="read-header-method" class="method-detail ">
1582
+ <a name="method-i-read_header"></a>
1583
+
1584
+ <div class="method-heading">
1585
+
1586
+ <span class="method-name">read_header</span><span
1587
+ class="method-args">()</span>
1588
+ <span class="method-click-advice">click to toggle source</span>
1589
+
1590
+ </div>
1591
+
1592
+ <div class="method-description">
1593
+
1594
+ <p>
1595
+ Read a header chunk.
1596
+ </p>
1597
+
1598
+
1599
+
1600
+ <div class="method-source-code"
1601
+ id="read-header-source">
1602
+ <pre>
1603
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 190</span>
1604
+ 190: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_header</span>
1605
+ 191: <span class="ruby-ivar">@bytes_to_be_read</span> = <span class="ruby-value">0</span>
1606
+ 192: <span class="ruby-identifier">read_mt_header_string</span>(<span class="ruby-constant">MThd_BYTE_ARRAY</span>, <span class="ruby-ivar">@skip_init</span>) <span class="ruby-comment cmt"># &quot;MThd&quot;</span>
1607
+ 193:
1608
+ 194: <span class="ruby-ivar">@bytes_to_be_read</span> = <span class="ruby-identifier">read32</span>()
1609
+ 195: <span class="ruby-identifier">format</span> = <span class="ruby-identifier">read16</span>()
1610
+ 196: <span class="ruby-identifier">ntrks</span> = <span class="ruby-identifier">read16</span>()
1611
+ 197: <span class="ruby-identifier">division</span> = <span class="ruby-identifier">read16</span>()
1612
+ 198:
1613
+ 199: <span class="ruby-identifier">header</span>(<span class="ruby-identifier">format</span>, <span class="ruby-identifier">ntrks</span>, <span class="ruby-identifier">division</span>)
1614
+ 200:
1615
+ 201: <span class="ruby-comment cmt"># Flush any extra stuff, in case the length of the header is not 6</span>
1616
+ 202: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@bytes_to_be_read</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
1617
+ 203: <span class="ruby-identifier">get_bytes</span>(<span class="ruby-ivar">@bytes_to_be_read</span>)
1618
+ 204: <span class="ruby-ivar">@bytes_to_be_read</span> = <span class="ruby-value">0</span>
1619
+ 205: <span class="ruby-keyword kw">end</span>
1620
+ 206:
1621
+ 207: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ntrks</span>
1622
+ 208: <span class="ruby-keyword kw">end</span></pre>
1623
+ </div>
1624
+
1625
+ </div>
1626
+
1627
+
1628
+
1629
+
1630
+ </div>
1631
+
1632
+
1633
+ <div id="read-mt-header-string-method" class="method-detail ">
1634
+ <a name="method-i-read_mt_header_string"></a>
1635
+
1636
+ <div class="method-heading">
1637
+
1638
+ <span class="method-name">read_mt_header_string</span><span
1639
+ class="method-args">(bytes, skip)</span>
1640
+ <span class="method-click-advice">click to toggle source</span>
1641
+
1642
+ </div>
1643
+
1644
+ <div class="method-description">
1645
+
1646
+ <p>
1647
+ Read through &#8216;MThd&#8217; or &#8216;MTrk&#8217; header string. If
1648
+ skip is true, attempt to skip initial trash. If there is an error, <a
1649
+ href="MIDIFile.html#method-i-error">#</a> is called.
1650
+ </p>
1651
+
1652
+
1653
+
1654
+ <div class="method-source-code"
1655
+ id="read-mt-header-string-source">
1656
+ <pre>
1657
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 160</span>
1658
+ 160: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_mt_header_string</span>(<span class="ruby-identifier">bytes</span>, <span class="ruby-identifier">skip</span>)
1659
+ 161: <span class="ruby-identifier">b</span> = []
1660
+ 162: <span class="ruby-identifier">bytes_to_read</span> = <span class="ruby-value">4</span>
1661
+ 163: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
1662
+ 164: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">get_bytes</span>(<span class="ruby-identifier">bytes_to_read</span>)
1663
+ 165: <span class="ruby-identifier">b</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">data</span>
1664
+ 166: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">4</span>
1665
+ 167: <span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;unexpected EOF while trying to read header&quot;</span> <span class="ruby-operator">+</span>
1666
+ 168: <span class="ruby-node">&quot; string #{s}&quot;</span>)
1667
+ 169: <span class="ruby-keyword kw">end</span>
1668
+ 170:
1669
+ 171: <span class="ruby-comment cmt"># See if we found the bytes we're looking for</span>
1670
+ 172: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">b</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">bytes</span>
1671
+ 173:
1672
+ 174: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">skip</span> <span class="ruby-comment cmt"># Try again with the next char</span>
1673
+ 175: <span class="ruby-identifier">i</span> = <span class="ruby-identifier">b</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">1</span>].<span class="ruby-identifier">index</span>(<span class="ruby-identifier">bytes</span>[<span class="ruby-value">0</span>])
1674
+ 176: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">nil?</span>
1675
+ 177: <span class="ruby-identifier">b</span> = []
1676
+ 178: <span class="ruby-identifier">bytes_to_read</span> = <span class="ruby-value">4</span>
1677
+ 179: <span class="ruby-keyword kw">else</span>
1678
+ 180: <span class="ruby-identifier">b</span> = <span class="ruby-identifier">b</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span><span class="ruby-value">1</span>]
1679
+ 181: <span class="ruby-identifier">bytes_to_read</span> = <span class="ruby-value">4</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">i</span>
1680
+ 182: <span class="ruby-keyword kw">end</span>
1681
+ 183: <span class="ruby-keyword kw">else</span>
1682
+ 184: <span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;header string #{bytes.collect{|b| b.chr}.join} not found&quot;</span>)
1683
+ 185: <span class="ruby-keyword kw">end</span>
1684
+ 186: <span class="ruby-keyword kw">end</span>
1685
+ 187: <span class="ruby-keyword kw">end</span></pre>
1686
+ </div>
1687
+
1688
+ </div>
1689
+
1690
+
1691
+
1692
+
1693
+ </div>
1694
+
1695
+
1696
+ <div id="read-track-method" class="method-detail ">
1697
+ <a name="method-i-read_track"></a>
1698
+
1699
+ <div class="method-heading">
1700
+
1701
+ <span class="method-name">read_track</span><span
1702
+ class="method-args">()</span>
1703
+ <span class="method-click-advice">click to toggle source</span>
1704
+
1705
+ </div>
1706
+
1707
+ <div class="method-description">
1708
+
1709
+ <p>
1710
+ Read a track chunk.
1711
+ </p>
1712
+
1713
+
1714
+
1715
+ <div class="method-source-code"
1716
+ id="read-track-source">
1717
+ <pre>
1718
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 211</span>
1719
+ 211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_track</span>
1720
+ 212: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">c1</span> = <span class="ruby-identifier">type</span> = <span class="ruby-identifier">needed</span> = <span class="ruby-value">0</span>
1721
+ 213: <span class="ruby-identifier">sysex_continue</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># True if last msg was unfinished</span>
1722
+ 214: <span class="ruby-identifier">running</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># True when running status used</span>
1723
+ 215: <span class="ruby-identifier">status</span> = <span class="ruby-value">0</span> <span class="ruby-comment cmt"># (Possibly running) status byte</span>
1724
+ 216:
1725
+ 217: <span class="ruby-ivar">@bytes_to_be_read</span> = <span class="ruby-value">0</span>
1726
+ 218: <span class="ruby-identifier">read_mt_header_string</span>(<span class="ruby-constant">MTrk_BYTE_ARRAY</span>, <span class="ruby-keyword kw">false</span>)
1727
+ 219:
1728
+ 220: <span class="ruby-ivar">@bytes_to_be_read</span> = <span class="ruby-identifier">read32</span>()
1729
+ 221: <span class="ruby-ivar">@curr_ticks</span> = <span class="ruby-ivar">@ticks_so_far</span> = <span class="ruby-value">0</span>
1730
+ 222:
1731
+ 223: <span class="ruby-identifier">start_track</span>()
1732
+ 224:
1733
+ 225: <span class="ruby-keyword kw">while</span> <span class="ruby-ivar">@bytes_to_be_read</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
1734
+ 226: <span class="ruby-ivar">@curr_ticks</span> = <span class="ruby-identifier">read_var_len</span>() <span class="ruby-comment cmt"># Delta time</span>
1735
+ 227: <span class="ruby-ivar">@ticks_so_far</span> <span class="ruby-operator">+=</span> <span class="ruby-ivar">@curr_ticks</span>
1736
+ 228:
1737
+ 229: <span class="ruby-comment cmt"># Copy raw var num data into raw time stamp data</span>
1738
+ 230: <span class="ruby-ivar">@raw_time_stamp_data</span> = <span class="ruby-ivar">@raw_var_num_data</span>.<span class="ruby-identifier">dup</span>()
1739
+ 231:
1740
+ 232: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">getc</span>() <span class="ruby-comment cmt"># Read first byte</span>
1741
+ 233:
1742
+ 234: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sysex_continue</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">EOX</span>
1743
+ 235: <span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;didn't find expected continuation of a sysex&quot;</span>)
1744
+ 236: <span class="ruby-keyword kw">end</span>
1745
+ 237:
1746
+ 238: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">c</span> &amp; <span class="ruby-value">0x80</span>).<span class="ruby-identifier">zero?</span> <span class="ruby-comment cmt"># Running status?</span>
1747
+ 239: <span class="ruby-identifier">error</span>(<span class="ruby-value str">'unexpected running status'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span>.<span class="ruby-identifier">zero?</span>
1748
+ 240: <span class="ruby-identifier">running</span> = <span class="ruby-keyword kw">true</span>
1749
+ 241: <span class="ruby-keyword kw">else</span>
1750
+ 242: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">c</span>
1751
+ 243: <span class="ruby-identifier">running</span> = <span class="ruby-keyword kw">false</span>
1752
+ 244: <span class="ruby-keyword kw">end</span>
1753
+ 245:
1754
+ 246: <span class="ruby-identifier">needed</span> = <span class="ruby-constant">NUM_DATA_BYTES</span>[(<span class="ruby-identifier">status</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">4</span>) &amp; <span class="ruby-value">0x0f</span>]
1755
+ 247:
1756
+ 248: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">needed</span>.<span class="ruby-identifier">nonzero?</span> <span class="ruby-comment cmt"># i.e., is it a channel message?</span>
1757
+ 249: <span class="ruby-identifier">c1</span> = <span class="ruby-identifier">running</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">:</span> (<span class="ruby-identifier">getc</span>() &amp; <span class="ruby-value">0x7f</span>)
1758
+ 250:
1759
+ 251: <span class="ruby-comment cmt"># The &quot;&amp; 0x7f&quot; here may seem unnecessary, but I've seen</span>
1760
+ 252: <span class="ruby-comment cmt"># &quot;bad&quot; MIDI files that had, for example, volume bytes</span>
1761
+ 253: <span class="ruby-comment cmt"># with the upper bit set. This code should not harm</span>
1762
+ 254: <span class="ruby-comment cmt"># proper data.</span>
1763
+ 255: <span class="ruby-identifier">chan_message</span>(<span class="ruby-identifier">running</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">c1</span>,
1764
+ 256: (<span class="ruby-identifier">needed</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>) <span class="ruby-operator">?</span> (<span class="ruby-identifier">getc</span>() &amp; <span class="ruby-value">0x7f</span>) <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)
1765
+ 257: <span class="ruby-keyword kw">next</span>
1766
+ 258: <span class="ruby-keyword kw">end</span>
1767
+ 259:
1768
+ 260: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">c</span>
1769
+ 261: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">META_EVENT</span> <span class="ruby-comment cmt"># Meta event</span>
1770
+ 262: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">getc</span>()
1771
+ 263: <span class="ruby-identifier">msg_init</span>()
1772
+ 264: <span class="ruby-identifier">msg_read</span>(<span class="ruby-identifier">read_var_len</span>())
1773
+ 265: <span class="ruby-identifier">meta_event</span>(<span class="ruby-identifier">type</span>)
1774
+ 266: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">SYSEX</span> <span class="ruby-comment cmt"># Start of system exclusive</span>
1775
+ 267: <span class="ruby-identifier">msg_init</span>()
1776
+ 268: <span class="ruby-identifier">msg_add</span>(<span class="ruby-constant">SYSEX</span>)
1777
+ 269: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">msg_read</span>(<span class="ruby-identifier">read_var_len</span>())
1778
+ 270:
1779
+ 271: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">==</span> <span class="ruby-constant">EOX</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@no_merge</span>
1780
+ 272: <span class="ruby-identifier">handle_sysex</span>(<span class="ruby-identifier">msg</span>())
1781
+ 273: <span class="ruby-keyword kw">else</span>
1782
+ 274: <span class="ruby-identifier">sysex_continue</span> = <span class="ruby-keyword kw">true</span>
1783
+ 275: <span class="ruby-keyword kw">end</span>
1784
+ 276: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">EOX</span> <span class="ruby-comment cmt"># Sysex continuation or arbitrary stuff</span>
1785
+ 277: <span class="ruby-identifier">msg_init</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">sysex_continue</span>
1786
+ 278: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">msg_read</span>(<span class="ruby-identifier">read_var_len</span>())
1787
+ 279:
1788
+ 280: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">sysex_continue</span>
1789
+ 281: <span class="ruby-identifier">handle_arbitrary</span>(<span class="ruby-identifier">msg</span>())
1790
+ 282: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">==</span> <span class="ruby-constant">EOX</span>
1791
+ 283: <span class="ruby-identifier">handle_sysex</span>(<span class="ruby-identifier">msg</span>())
1792
+ 284: <span class="ruby-identifier">sysex_continue</span> = <span class="ruby-keyword kw">false</span>
1793
+ 285: <span class="ruby-keyword kw">end</span>
1794
+ 286: <span class="ruby-keyword kw">else</span>
1795
+ 287: <span class="ruby-identifier">bad_byte</span>(<span class="ruby-identifier">c</span>)
1796
+ 288: <span class="ruby-keyword kw">end</span>
1797
+ 289: <span class="ruby-keyword kw">end</span>
1798
+ 290: <span class="ruby-identifier">end_track</span>()
1799
+ 291: <span class="ruby-keyword kw">end</span></pre>
1800
+ </div>
1801
+
1802
+ </div>
1803
+
1804
+
1805
+
1806
+
1807
+ </div>
1808
+
1809
+
1810
+ <div id="read-var-len-method" class="method-detail ">
1811
+ <a name="method-i-read_var_len"></a>
1812
+
1813
+ <div class="method-heading">
1814
+
1815
+ <span class="method-name">read_var_len</span><span
1816
+ class="method-args">()</span>
1817
+ <span class="method-click-advice">click to toggle source</span>
1818
+
1819
+ </div>
1820
+
1821
+ <div class="method-description">
1822
+
1823
+ <p>
1824
+ Read a varlen value.
1825
+ </p>
1826
+
1827
+
1828
+
1829
+ <div class="method-source-code"
1830
+ id="read-var-len-source">
1831
+ <pre>
1832
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 391</span>
1833
+ 391: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_var_len</span>
1834
+ 392: <span class="ruby-ivar">@raw_var_num_data</span> = []
1835
+ 393: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">getc</span>()
1836
+ 394: <span class="ruby-ivar">@raw_var_num_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span>
1837
+ 395: <span class="ruby-identifier">val</span> = <span class="ruby-identifier">c</span>
1838
+ 396: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x80</span>).<span class="ruby-identifier">nonzero?</span>
1839
+ 397: <span class="ruby-identifier">val</span> <span class="ruby-operator">&amp;=</span> <span class="ruby-value">0x7f</span>
1840
+ 398: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
1841
+ 399: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">getc</span>()
1842
+ 400: <span class="ruby-ivar">@raw_var_num_data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span>
1843
+ 401: <span class="ruby-identifier">val</span> = (<span class="ruby-identifier">val</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">7</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">c</span> &amp; <span class="ruby-value">0x7f</span>)
1844
+ 402: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">c</span> &amp; <span class="ruby-value">0x80</span>).<span class="ruby-identifier">zero?</span>
1845
+ 403: <span class="ruby-keyword kw">end</span>
1846
+ 404: <span class="ruby-keyword kw">end</span>
1847
+ 405: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
1848
+ 406: <span class="ruby-keyword kw">end</span></pre>
1849
+ </div>
1850
+
1851
+ </div>
1852
+
1853
+
1854
+
1855
+
1856
+ </div>
1857
+
1858
+
1859
+ <div id="sequence-number-method" class="method-detail ">
1860
+ <a name="method-i-sequence_number"></a>
1861
+
1862
+ <div class="method-heading">
1863
+
1864
+ <span class="method-name">sequence_number</span><span
1865
+ class="method-args">(num)</span>
1866
+ <span class="method-click-advice">click to toggle source</span>
1867
+
1868
+ </div>
1869
+
1870
+ <div class="method-description">
1871
+
1872
+
1873
+
1874
+
1875
+
1876
+ <div class="method-source-code"
1877
+ id="sequence-number-source">
1878
+ <pre>
1879
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 131</span>
1880
+ 131: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sequence_number</span>(<span class="ruby-identifier">num</span>)
1881
+ 132: <span class="ruby-keyword kw">end</span></pre>
1882
+ </div>
1883
+
1884
+ </div>
1885
+
1886
+
1887
+
1888
+
1889
+ </div>
1890
+
1891
+
1892
+ <div id="sequencer-specific-method" class="method-detail ">
1893
+ <a name="method-i-sequencer_specific"></a>
1894
+
1895
+ <div class="method-heading">
1896
+
1897
+ <span class="method-name">sequencer_specific</span><span
1898
+ class="method-args">(type, msg)</span>
1899
+ <span class="method-click-advice">click to toggle source</span>
1900
+
1901
+ </div>
1902
+
1903
+ <div class="method-description">
1904
+
1905
+
1906
+
1907
+
1908
+
1909
+ <div class="method-source-code"
1910
+ id="sequencer-specific-source">
1911
+ <pre>
1912
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 128</span>
1913
+ 128: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sequencer_specific</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">msg</span>)
1914
+ 129: <span class="ruby-keyword kw">end</span></pre>
1915
+ </div>
1916
+
1917
+ </div>
1918
+
1919
+
1920
+
1921
+
1922
+ </div>
1923
+
1924
+
1925
+ <div id="smpte-method" class="method-detail ">
1926
+ <a name="method-i-smpte"></a>
1927
+
1928
+ <div class="method-heading">
1929
+
1930
+ <span class="method-name">smpte</span><span
1931
+ class="method-args">(hour, min, sec, frame, fract)</span>
1932
+ <span class="method-click-advice">click to toggle source</span>
1933
+
1934
+ </div>
1935
+
1936
+ <div class="method-description">
1937
+
1938
+
1939
+
1940
+
1941
+
1942
+ <div class="method-source-code"
1943
+ id="smpte-source">
1944
+ <pre>
1945
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 143</span>
1946
+ 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">smpte</span>(<span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">frame</span>, <span class="ruby-identifier">fract</span>)
1947
+ 144: <span class="ruby-keyword kw">end</span></pre>
1948
+ </div>
1949
+
1950
+ </div>
1951
+
1952
+
1953
+
1954
+
1955
+ </div>
1956
+
1957
+
1958
+ <div id="start-track-method" class="method-detail ">
1959
+ <a name="method-i-start_track"></a>
1960
+
1961
+ <div class="method-heading">
1962
+
1963
+ <span class="method-name">start_track</span><span
1964
+ class="method-args">(bytes_to_be_read)</span>
1965
+ <span class="method-click-advice">click to toggle source</span>
1966
+
1967
+ </div>
1968
+
1969
+ <div class="method-description">
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+ <div class="method-source-code"
1976
+ id="start-track-source">
1977
+ <pre>
1978
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 95</span>
1979
+ 95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_track</span>(<span class="ruby-identifier">bytes_to_be_read</span>)
1980
+ 96: <span class="ruby-keyword kw">end</span></pre>
1981
+ </div>
1982
+
1983
+ </div>
1984
+
1985
+
1986
+
1987
+
1988
+ </div>
1989
+
1990
+
1991
+ <div id="sysex-method" class="method-detail ">
1992
+ <a name="method-i-sysex"></a>
1993
+
1994
+ <div class="method-heading">
1995
+
1996
+ <span class="method-name">sysex</span><span
1997
+ class="method-args">(msg)</span>
1998
+ <span class="method-click-advice">click to toggle source</span>
1999
+
2000
+ </div>
2001
+
2002
+ <div class="method-description">
2003
+
2004
+
2005
+
2006
+
2007
+
2008
+ <div class="method-source-code"
2009
+ id="sysex-source">
2010
+ <pre>
2011
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 122</span>
2012
+ 122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sysex</span>(<span class="ruby-identifier">msg</span>)
2013
+ 123: <span class="ruby-keyword kw">end</span></pre>
2014
+ </div>
2015
+
2016
+ </div>
2017
+
2018
+
2019
+
2020
+
2021
+ </div>
2022
+
2023
+
2024
+ <div id="tempo-method" class="method-detail ">
2025
+ <a name="method-i-tempo"></a>
2026
+
2027
+ <div class="method-heading">
2028
+
2029
+ <span class="method-name">tempo</span><span
2030
+ class="method-args">(microsecs)</span>
2031
+ <span class="method-click-advice">click to toggle source</span>
2032
+
2033
+ </div>
2034
+
2035
+ <div class="method-description">
2036
+
2037
+
2038
+
2039
+
2040
+
2041
+ <div class="method-source-code"
2042
+ id="tempo-source">
2043
+ <pre>
2044
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 146</span>
2045
+ 146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tempo</span>(<span class="ruby-identifier">microsecs</span>)
2046
+ 147: <span class="ruby-keyword kw">end</span></pre>
2047
+ </div>
2048
+
2049
+ </div>
2050
+
2051
+
2052
+
2053
+
2054
+ </div>
2055
+
2056
+
2057
+ <div id="text-method" class="method-detail ">
2058
+ <a name="method-i-text"></a>
2059
+
2060
+ <div class="method-heading">
2061
+
2062
+ <span class="method-name">text</span><span
2063
+ class="method-args">(type, msg)</span>
2064
+ <span class="method-click-advice">click to toggle source</span>
2065
+
2066
+ </div>
2067
+
2068
+ <div class="method-description">
2069
+
2070
+
2071
+
2072
+
2073
+
2074
+ <div class="method-source-code"
2075
+ id="text-source">
2076
+ <pre>
2077
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 134</span>
2078
+ 134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">text</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">msg</span>)
2079
+ 135: <span class="ruby-keyword kw">end</span></pre>
2080
+ </div>
2081
+
2082
+ </div>
2083
+
2084
+
2085
+
2086
+
2087
+ </div>
2088
+
2089
+
2090
+ <div id="time-signature-method" class="method-detail ">
2091
+ <a name="method-i-time_signature"></a>
2092
+
2093
+ <div class="method-heading">
2094
+
2095
+ <span class="method-name">time_signature</span><span
2096
+ class="method-args">(numer, denom, clocks, qnotes)</span>
2097
+ <span class="method-click-advice">click to toggle source</span>
2098
+
2099
+ </div>
2100
+
2101
+ <div class="method-description">
2102
+
2103
+
2104
+
2105
+
2106
+
2107
+ <div class="method-source-code"
2108
+ id="time-signature-source">
2109
+ <pre>
2110
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 140</span>
2111
+ 140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time_signature</span>(<span class="ruby-identifier">numer</span>, <span class="ruby-identifier">denom</span>, <span class="ruby-identifier">clocks</span>, <span class="ruby-identifier">qnotes</span>)
2112
+ 141: <span class="ruby-keyword kw">end</span></pre>
2113
+ </div>
2114
+
2115
+ </div>
2116
+
2117
+
2118
+
2119
+
2120
+ </div>
2121
+
2122
+
2123
+ <div id="write--method" class="method-detail ">
2124
+ <a name="method-i-write16"></a>
2125
+
2126
+ <div class="method-heading">
2127
+
2128
+ <span class="method-name">write16</span><span
2129
+ class="method-args">(val)</span>
2130
+ <span class="method-click-advice">click to toggle source</span>
2131
+
2132
+ </div>
2133
+
2134
+ <div class="method-description">
2135
+
2136
+ <p>
2137
+ Write a sixteen-bit value.
2138
+ </p>
2139
+
2140
+
2141
+
2142
+ <div class="method-source-code"
2143
+ id="write--source">
2144
+ <pre>
2145
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 409</span>
2146
+ 409: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write16</span>(<span class="ruby-identifier">val</span>)
2147
+ 410: <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>
2148
+ 411: <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>)
2149
+ 412: <span class="ruby-identifier">putc</span>(<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0xff</span>)
2150
+ 413: <span class="ruby-keyword kw">end</span></pre>
2151
+ </div>
2152
+
2153
+ </div>
2154
+
2155
+
2156
+
2157
+
2158
+ </div>
2159
+
2160
+
2161
+ <div id="write--method" class="method-detail ">
2162
+ <a name="method-i-write32"></a>
2163
+
2164
+ <div class="method-heading">
2165
+
2166
+ <span class="method-name">write32</span><span
2167
+ class="method-args">(val)</span>
2168
+ <span class="method-click-advice">click to toggle source</span>
2169
+
2170
+ </div>
2171
+
2172
+ <div class="method-description">
2173
+
2174
+ <p>
2175
+ Write a 32-bit value.
2176
+ </p>
2177
+
2178
+
2179
+
2180
+ <div class="method-source-code"
2181
+ id="write--source">
2182
+ <pre>
2183
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 416</span>
2184
+ 416: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write32</span>(<span class="ruby-identifier">val</span>)
2185
+ 417: <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>
2186
+ 418: <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>)
2187
+ 419: <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>)
2188
+ 420: <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>)
2189
+ 421: <span class="ruby-identifier">putc</span>(<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0xff</span>)
2190
+ 422: <span class="ruby-keyword kw">end</span></pre>
2191
+ </div>
2192
+
2193
+ </div>
2194
+
2195
+
2196
+
2197
+
2198
+ </div>
2199
+
2200
+
2201
+ <div id="write-var-len-method" class="method-detail ">
2202
+ <a name="method-i-write_var_len"></a>
2203
+
2204
+ <div class="method-heading">
2205
+
2206
+ <span class="method-name">write_var_len</span><span
2207
+ class="method-args">(val)</span>
2208
+ <span class="method-click-advice">click to toggle source</span>
2209
+
2210
+ </div>
2211
+
2212
+ <div class="method-description">
2213
+
2214
+ <p>
2215
+ Write a variable length value.
2216
+ </p>
2217
+
2218
+
2219
+
2220
+ <div class="method-source-code"
2221
+ id="write-var-len-source">
2222
+ <pre>
2223
+ <span class="ruby-comment cmt"># File lib/midilib/io/midifile.rb, line 425</span>
2224
+ 425: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_var_len</span>(<span class="ruby-identifier">val</span>)
2225
+ 426: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">zero?</span>
2226
+ 427: <span class="ruby-identifier">putc</span>(<span class="ruby-value">0</span>)
2227
+ 428: <span class="ruby-keyword kw">return</span>
2228
+ 429: <span class="ruby-keyword kw">end</span>
2229
+ 430:
2230
+ 431: <span class="ruby-identifier">buf</span> = []
2231
+ 432:
2232
+ 433: <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x7f</span>)
2233
+ 434: <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">value</span> <span class="ruby-operator">&gt;&gt;=</span> <span class="ruby-value">7</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
2234
+ 435: <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">val</span> &amp; <span class="ruby-value">0x7f</span>) <span class="ruby-operator">|</span> <span class="ruby-value">0x80</span>
2235
+ 436: <span class="ruby-keyword kw">end</span>
2236
+ 437:
2237
+ 438: <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">reverse</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-identifier">putc</span>(<span class="ruby-identifier">b</span>) }
2238
+ 439: <span class="ruby-keyword kw">end</span></pre>
2239
+ </div>
2240
+
2241
+ </div>
2242
+
2243
+
2244
+
2245
+
2246
+ </div>
2247
+
2248
+
2249
+ </div>
2250
+
2251
+
2252
+ </div>
2253
+
2254
+
2255
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
2256
+
2257
+ <p>Disabled; run with --debug to generate this.</p>
2258
+
2259
+ </div>
2260
+
2261
+ <div id="validator-badges">
2262
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
2263
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
2264
+ Rdoc Generator</a> 1.1.6</small>.</p>
2265
+ </div>
2266
+
2267
+ </body>
2268
+ </html>
2269
+