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