midi-communications-windows 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.version +6 -0
- data/.yardoc/checksums +8 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/.yardopts +8 -0
- data/Gemfile +3 -0
- data/LICENSE +165 -0
- data/README.md +176 -0
- data/Rakefile +13 -0
- data/doc/MIDICommunicationsWindows/API/MIDIHdr.html +144 -0
- data/doc/MIDICommunicationsWindows/API/MIDIInCaps.html +142 -0
- data/doc/MIDICommunicationsWindows/API/MIDIOutCaps.html +140 -0
- data/doc/MIDICommunicationsWindows/API/MSG.html +143 -0
- data/doc/MIDICommunicationsWindows/API.html +981 -0
- data/doc/MIDICommunicationsWindows/Device/ClassMethods.html +365 -0
- data/doc/MIDICommunicationsWindows/Device/InstanceMethods.html +1096 -0
- data/doc/MIDICommunicationsWindows/Device.html +988 -0
- data/doc/MIDICommunicationsWindows/Error.html +438 -0
- data/doc/MIDICommunicationsWindows/Input.html +1554 -0
- data/doc/MIDICommunicationsWindows/Message.html +700 -0
- data/doc/MIDICommunicationsWindows/Output.html +1697 -0
- data/doc/MIDICommunicationsWindows/TypeConversion.html +369 -0
- data/doc/MIDICommunicationsWindows.html +210 -0
- data/doc/_index.html +262 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +206 -0
- data/doc/css/style.css +1089 -0
- data/doc/file.README.html +240 -0
- data/doc/file.testing-on-windows.html +253 -0
- data/doc/file_list.html +64 -0
- data/doc/frames.html +22 -0
- data/doc/index.html +240 -0
- data/doc/js/app.js +801 -0
- data/doc/js/full_list.js +334 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +382 -0
- data/doc/top-level-namespace.html +112 -0
- data/docs/testing-on-windows.md +222 -0
- data/examples/input.rb +27 -0
- data/examples/list_ports.rb +17 -0
- data/examples/output.rb +22 -0
- data/examples/sysex_output.rb +15 -0
- data/lib/midi-communications-windows/api.rb +340 -0
- data/lib/midi-communications-windows/device.rb +310 -0
- data/lib/midi-communications-windows/input.rb +486 -0
- data/lib/midi-communications-windows/message.rb +133 -0
- data/lib/midi-communications-windows/output.rb +206 -0
- data/lib/midi-communications-windows/type_conversion.rb +20 -0
- data/lib/midi-communications-windows/version.rb +4 -0
- data/lib/midi-communications-windows.rb +76 -0
- data/midi-communications-windows.gemspec +32 -0
- metadata +220 -0
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
Module: MIDICommunicationsWindows::Message
|
|
8
|
+
|
|
9
|
+
— MIDI Communications Windows API
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css">
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css">
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "MIDICommunicationsWindows::Message";
|
|
19
|
+
relpath = '../';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div id="main_progress" aria-hidden="true"></div>
|
|
31
|
+
|
|
32
|
+
<div class="nav_wrap">
|
|
33
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|
34
|
+
<div id="resizer"></div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div id="main" tabindex="-1">
|
|
38
|
+
<div id="header">
|
|
39
|
+
<div id="menu">
|
|
40
|
+
|
|
41
|
+
<a href="../_index.html">Index (M)</a> »
|
|
42
|
+
<span class='title'><span class='object_link'><a href="../MIDICommunicationsWindows.html" title="MIDICommunicationsWindows (module)">MIDICommunicationsWindows</a></span></span>
|
|
43
|
+
»
|
|
44
|
+
<span class="title">Message</span>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div id="search">
|
|
49
|
+
|
|
50
|
+
<a class="full_list_link" id="class_list_link"
|
|
51
|
+
href="../class_list.html">
|
|
52
|
+
|
|
53
|
+
<svg width="24" height="24">
|
|
54
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
55
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
56
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
57
|
+
</svg>
|
|
58
|
+
</a>
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div class="clear"></div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div id="content"><h1>Module: MIDICommunicationsWindows::Message
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
</h1>
|
|
69
|
+
<div class="box_info">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<dl>
|
|
82
|
+
<dt>Defined in:</dt>
|
|
83
|
+
<dd>lib/midi-communications-windows/message.rb
|
|
84
|
+
</dd>
|
|
85
|
+
</dl>
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<h2>Overview</h2><div class="docstring">
|
|
90
|
+
<div class="discussion">
|
|
91
|
+
<p>Conversion between MIDI bytes and the packed 32-bit word WinMM uses for
|
|
92
|
+
short messages.</p>
|
|
93
|
+
<p>WinMM does not pass short messages as byte strings. It packs them into a
|
|
94
|
+
<code>DWORD</code>: the status byte in the low-order byte, the first data byte next,
|
|
95
|
+
the second data byte after that, and the high-order byte unused. The same
|
|
96
|
+
packing is used in both directions — as <code>dwMsg</code> for <code>midiOutShortMsg</code>, and
|
|
97
|
+
as <code>dwParam1</code> in the notification a client receives for input.</p>
|
|
98
|
+
<h2 id="Why_the_length_matters">Why the length matters</h2>
|
|
99
|
+
<p>A packed word carries no length. Nothing distinguishes a Clock, which is one
|
|
100
|
+
byte, from a Note On whose two data bytes happen to be zero: both arrive as
|
|
101
|
+
a word whose upper three bytes are zero. The length has to be derived from
|
|
102
|
+
the status byte, and getting it wrong is not a cosmetic problem — a Clock
|
|
103
|
+
delivered as <code>[0xF8, 0, 0]</code> is not a MIDI Clock message, and a parser
|
|
104
|
+
reading it will either reject it or invent two events that were never sent.
|
|
105
|
+
In MusaDSL that is the difference between a piece that follows the DAW's
|
|
106
|
+
tempo and one that does not start at all.</p>
|
|
107
|
+
<h2 id="Why_this_file_has_no_FFI_in_it">Why this file has no FFI in it</h2>
|
|
108
|
+
<p>This is the only part of the gem with logic rather than plumbing, and it is
|
|
109
|
+
also the part most likely to be wrong. Keeping it free of any binding to
|
|
110
|
+
<code>winmm.dll</code> means it can be tested on any machine, by anyone, without
|
|
111
|
+
Windows and without a MIDI port — which is what lets <code>test/message_test.rb</code>
|
|
112
|
+
run anywhere.</p>
|
|
113
|
+
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="tags">
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<h2>
|
|
122
|
+
Constant Summary
|
|
123
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
|
124
|
+
</h2>
|
|
125
|
+
|
|
126
|
+
<dl class="constants">
|
|
127
|
+
|
|
128
|
+
<dt id="CHANNEL_MESSAGE_LENGTHS-constant" class="">CHANNEL_MESSAGE_LENGTHS =
|
|
129
|
+
<div class="docstring">
|
|
130
|
+
<div class="discussion">
|
|
131
|
+
<p>Number of bytes in a channel message, indexed by the status byte's high
|
|
132
|
+
nibble. Program Change and Channel Pressure carry one data byte; every
|
|
133
|
+
other channel message carries two.</p>
|
|
134
|
+
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="tags">
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
</div>
|
|
141
|
+
</dt>
|
|
142
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
|
143
|
+
<span class='int'>0x8</span> <span class='op'>=></span> <span class='int'>3</span><span class='comma'>,</span> <span class='comment'># Note Off
|
|
144
|
+
</span> <span class='int'>0x9</span> <span class='op'>=></span> <span class='int'>3</span><span class='comma'>,</span> <span class='comment'># Note On
|
|
145
|
+
</span> <span class='int'>0xA</span> <span class='op'>=></span> <span class='int'>3</span><span class='comma'>,</span> <span class='comment'># Polyphonic Key Pressure
|
|
146
|
+
</span> <span class='int'>0xB</span> <span class='op'>=></span> <span class='int'>3</span><span class='comma'>,</span> <span class='comment'># Control Change
|
|
147
|
+
</span> <span class='int'>0xC</span> <span class='op'>=></span> <span class='int'>2</span><span class='comma'>,</span> <span class='comment'># Program Change
|
|
148
|
+
</span> <span class='int'>0xD</span> <span class='op'>=></span> <span class='int'>2</span><span class='comma'>,</span> <span class='comment'># Channel Pressure
|
|
149
|
+
</span> <span class='int'>0xE</span> <span class='op'>=></span> <span class='int'>3</span> <span class='comment'># Pitch Bend Change
|
|
150
|
+
</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
151
|
+
|
|
152
|
+
<dt id="SYSTEM_COMMON_MESSAGE_LENGTHS-constant" class="">SYSTEM_COMMON_MESSAGE_LENGTHS =
|
|
153
|
+
<div class="docstring">
|
|
154
|
+
<div class="discussion">
|
|
155
|
+
<p>Number of bytes in a System Common message, indexed by status byte.
|
|
156
|
+
Everything from 0xF8 up is System Real Time and is always one byte, so it
|
|
157
|
+
is not listed here.</p>
|
|
158
|
+
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="tags">
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
</div>
|
|
165
|
+
</dt>
|
|
166
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
|
167
|
+
<span class='int'>0xF1</span> <span class='op'>=></span> <span class='int'>2</span><span class='comma'>,</span> <span class='comment'># MIDI Time Code Quarter Frame
|
|
168
|
+
</span> <span class='int'>0xF2</span> <span class='op'>=></span> <span class='int'>3</span><span class='comma'>,</span> <span class='comment'># Song Position Pointer
|
|
169
|
+
</span> <span class='int'>0xF3</span> <span class='op'>=></span> <span class='int'>2</span><span class='comma'>,</span> <span class='comment'># Song Select
|
|
170
|
+
</span> <span class='int'>0xF6</span> <span class='op'>=></span> <span class='int'>1</span> <span class='comment'># Tune Request
|
|
171
|
+
</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
172
|
+
|
|
173
|
+
</dl>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<h2>
|
|
184
|
+
Class Method Summary
|
|
185
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
186
|
+
</h2>
|
|
187
|
+
|
|
188
|
+
<ul class="summary">
|
|
189
|
+
|
|
190
|
+
<li class="public ">
|
|
191
|
+
<span class="summary_signature">
|
|
192
|
+
|
|
193
|
+
<a href="#length_of-class_method" title="length_of (class method)">.<strong>length_of</strong>(status) ⇒ Integer </a>
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
</span>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
<span class="summary_desc"><div class='inline'><p>How many bytes the message with this status byte occupies.</p></div></span>
|
|
208
|
+
|
|
209
|
+
</li>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
<li class="public ">
|
|
213
|
+
<span class="summary_signature">
|
|
214
|
+
|
|
215
|
+
<a href="#pack-class_method" title="pack (class method)">.<strong>pack</strong>(bytes) ⇒ Integer </a>
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
</span>
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
<span class="summary_desc"><div class='inline'><p>Packs a short message into the word <code>midiOutShortMsg</code> expects.</p></div></span>
|
|
230
|
+
|
|
231
|
+
</li>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
<li class="public ">
|
|
235
|
+
<span class="summary_signature">
|
|
236
|
+
|
|
237
|
+
<a href="#sysex%3F-class_method" title="sysex? (class method)">.<strong>sysex?</strong>(bytes) ⇒ Boolean </a>
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
</span>
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
<span class="summary_desc"><div class='inline'><p>Is this the start of a System Exclusive message?.</p></div></span>
|
|
252
|
+
|
|
253
|
+
</li>
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
<li class="public ">
|
|
257
|
+
<span class="summary_signature">
|
|
258
|
+
|
|
259
|
+
<a href="#unpack-class_method" title="unpack (class method)">.<strong>unpack</strong>(word) ⇒ Array<Integer> </a>
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
</span>
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
<span class="summary_desc"><div class='inline'><p>Unpacks the word WinMM delivers for an incoming short message.</p></div></span>
|
|
274
|
+
|
|
275
|
+
</li>
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
</ul>
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
<div id="class_method_details" class="method_details_list">
|
|
285
|
+
<h2>Class Method Details</h2>
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
<div class="method_details first">
|
|
289
|
+
<h3 class="signature first" id="length_of-class_method">
|
|
290
|
+
|
|
291
|
+
.<strong>length_of</strong>(status) ⇒ <tt>Integer</tt>
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
</h3><div class="docstring">
|
|
298
|
+
<div class="discussion">
|
|
299
|
+
<p>How many bytes the message with this status byte occupies.</p>
|
|
300
|
+
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
<div class="tags">
|
|
304
|
+
|
|
305
|
+
<div class="examples">
|
|
306
|
+
<h4 class="tag_title">Examples:</h4>
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="MIDICommunicationsWindows::Message (module)">Message</a></span></span><span class='period'>.</span><span class='id identifier rubyid_length_of'>length_of</span><span class='lparen'>(</span><span class='int'>0x90</span><span class='rparen'>)</span> <span class='comment'># => 3 Note On
|
|
310
|
+
</span><span class='const'><span class='object_link'><a href="" title="MIDICommunicationsWindows::Message (module)">Message</a></span></span><span class='period'>.</span><span class='id identifier rubyid_length_of'>length_of</span><span class='lparen'>(</span><span class='int'>0xC0</span><span class='rparen'>)</span> <span class='comment'># => 2 Program Change
|
|
311
|
+
</span><span class='const'><span class='object_link'><a href="" title="MIDICommunicationsWindows::Message (module)">Message</a></span></span><span class='period'>.</span><span class='id identifier rubyid_length_of'>length_of</span><span class='lparen'>(</span><span class='int'>0xF8</span><span class='rparen'>)</span> <span class='comment'># => 1 Clock</span></code></pre>
|
|
312
|
+
|
|
313
|
+
</div>
|
|
314
|
+
<p class="tag_title">Parameters:</p>
|
|
315
|
+
<ul class="param">
|
|
316
|
+
|
|
317
|
+
<li>
|
|
318
|
+
|
|
319
|
+
<span class='name'>status</span>
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
—
|
|
327
|
+
<div class='inline'><p>a MIDI status byte, 0x80..0xFF</p></div>
|
|
328
|
+
|
|
329
|
+
</li>
|
|
330
|
+
|
|
331
|
+
</ul>
|
|
332
|
+
|
|
333
|
+
<p class="tag_title">Returns:</p>
|
|
334
|
+
<ul class="return">
|
|
335
|
+
|
|
336
|
+
<li>
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
—
|
|
344
|
+
<div class='inline'><p>1, 2 or 3</p></div>
|
|
345
|
+
|
|
346
|
+
</li>
|
|
347
|
+
|
|
348
|
+
</ul>
|
|
349
|
+
<p class="tag_title">Raises:</p>
|
|
350
|
+
<ul class="raise">
|
|
351
|
+
|
|
352
|
+
<li>
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
—
|
|
360
|
+
<div class='inline'><p>if the byte is not a status byte, or begins a
|
|
361
|
+
System Exclusive message, which is never delivered as a short message</p></div>
|
|
362
|
+
|
|
363
|
+
</li>
|
|
364
|
+
|
|
365
|
+
</ul>
|
|
366
|
+
|
|
367
|
+
</div><table class="source_code">
|
|
368
|
+
<tr>
|
|
369
|
+
<td>
|
|
370
|
+
<pre class="lines">
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
68
|
|
374
|
+
69
|
|
375
|
+
70
|
|
376
|
+
71
|
|
377
|
+
72
|
|
378
|
+
73
|
|
379
|
+
74
|
|
380
|
+
75
|
|
381
|
+
76
|
|
382
|
+
77
|
|
383
|
+
78
|
|
384
|
+
79
|
|
385
|
+
80</pre>
|
|
386
|
+
</td>
|
|
387
|
+
<td>
|
|
388
|
+
<pre class="code"><span class="info file"># File 'lib/midi-communications-windows/message.rb', line 68</span>
|
|
389
|
+
|
|
390
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_length_of'>length_of</span><span class='lparen'>(</span><span class='id identifier rubyid_status'>status</span><span class='rparen'>)</span>
|
|
391
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>not a status byte: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0x%02X</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_status'>status</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_status'>status</span> <span class='op'><</span> <span class='int'>0x80</span> <span class='op'>||</span> <span class='id identifier rubyid_status'>status</span> <span class='op'>></span> <span class='int'>0xFF</span>
|
|
392
|
+
|
|
393
|
+
<span class='comment'># System Exclusive does not travel as a short message: WinMM delivers it
|
|
394
|
+
</span> <span class='comment'># through a buffer instead, so a caller who reaches here with 0xF0 has
|
|
395
|
+
</span> <span class='comment'># confused the two paths.
|
|
396
|
+
</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>System Exclusive is not a short message</span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_status'>status</span> <span class='op'>==</span> <span class='int'>0xF0</span>
|
|
397
|
+
|
|
398
|
+
<span class='kw'>return</span> <span class='int'>1</span> <span class='kw'>if</span> <span class='id identifier rubyid_status'>status</span> <span class='op'>>=</span> <span class='int'>0xF8</span>
|
|
399
|
+
<span class='kw'>return</span> <span class='const'><span class='object_link'><a href="#SYSTEM_COMMON_MESSAGE_LENGTHS-constant" title="MIDICommunicationsWindows::Message::SYSTEM_COMMON_MESSAGE_LENGTHS (constant)">SYSTEM_COMMON_MESSAGE_LENGTHS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_status'>status</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_status'>status</span> <span class='op'>>=</span> <span class='int'>0xF0</span>
|
|
400
|
+
|
|
401
|
+
<span class='const'><span class='object_link'><a href="#CHANNEL_MESSAGE_LENGTHS-constant" title="MIDICommunicationsWindows::Message::CHANNEL_MESSAGE_LENGTHS (constant)">CHANNEL_MESSAGE_LENGTHS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_status'>status</span> <span class='op'>>></span> <span class='int'>4</span><span class='rparen'>)</span>
|
|
402
|
+
<span class='kw'>end</span></pre>
|
|
403
|
+
</td>
|
|
404
|
+
</tr>
|
|
405
|
+
</table>
|
|
406
|
+
</div>
|
|
407
|
+
|
|
408
|
+
<div class="method_details ">
|
|
409
|
+
<h3 class="signature " id="pack-class_method">
|
|
410
|
+
|
|
411
|
+
.<strong>pack</strong>(bytes) ⇒ <tt>Integer</tt>
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
</h3><div class="docstring">
|
|
418
|
+
<div class="discussion">
|
|
419
|
+
<p>Packs a short message into the word <code>midiOutShortMsg</code> expects.</p>
|
|
420
|
+
<p>The length must be exactly what the status byte calls for. Too few bytes
|
|
421
|
+
is plainly a mistake; too many is either a mistake or an attempt at
|
|
422
|
+
running status, which WinMM does not accept on output. Quietly dropping
|
|
423
|
+
the surplus would send something the caller did not ask for and give no
|
|
424
|
+
sign of it.</p>
|
|
425
|
+
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
<div class="tags">
|
|
429
|
+
|
|
430
|
+
<div class="examples">
|
|
431
|
+
<h4 class="tag_title">Examples:</h4>
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="MIDICommunicationsWindows::Message (module)">Message</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pack'>pack</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>0x90</span><span class='comma'>,</span> <span class='int'>0x3C</span><span class='comma'>,</span> <span class='int'>0x64</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='comment'># => 0x00643C90</span></code></pre>
|
|
435
|
+
|
|
436
|
+
</div>
|
|
437
|
+
<p class="tag_title">Parameters:</p>
|
|
438
|
+
<ul class="param">
|
|
439
|
+
|
|
440
|
+
<li>
|
|
441
|
+
|
|
442
|
+
<span class='name'>bytes</span>
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
<span class='type'>(<tt>Array<Integer></tt>)</span>
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
—
|
|
450
|
+
<div class='inline'><p>the message, status byte first</p></div>
|
|
451
|
+
|
|
452
|
+
</li>
|
|
453
|
+
|
|
454
|
+
</ul>
|
|
455
|
+
|
|
456
|
+
<p class="tag_title">Returns:</p>
|
|
457
|
+
<ul class="return">
|
|
458
|
+
|
|
459
|
+
<li>
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
—
|
|
467
|
+
<div class='inline'><p>the packed word</p></div>
|
|
468
|
+
|
|
469
|
+
</li>
|
|
470
|
+
|
|
471
|
+
</ul>
|
|
472
|
+
<p class="tag_title">Raises:</p>
|
|
473
|
+
<ul class="raise">
|
|
474
|
+
|
|
475
|
+
<li>
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
—
|
|
483
|
+
<div class='inline'><p>if the message is not the length its status byte
|
|
484
|
+
calls for</p></div>
|
|
485
|
+
|
|
486
|
+
</li>
|
|
487
|
+
|
|
488
|
+
</ul>
|
|
489
|
+
|
|
490
|
+
</div><table class="source_code">
|
|
491
|
+
<tr>
|
|
492
|
+
<td>
|
|
493
|
+
<pre class="lines">
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
114
|
|
497
|
+
115
|
|
498
|
+
116
|
|
499
|
+
117
|
|
500
|
+
118
|
|
501
|
+
119
|
|
502
|
+
120
|
|
503
|
+
121
|
|
504
|
+
122
|
|
505
|
+
123</pre>
|
|
506
|
+
</td>
|
|
507
|
+
<td>
|
|
508
|
+
<pre class="code"><span class="info file"># File 'lib/midi-communications-windows/message.rb', line 114</span>
|
|
509
|
+
|
|
510
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_pack'>pack</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='rparen'>)</span>
|
|
511
|
+
<span class='id identifier rubyid_length'>length</span> <span class='op'>=</span> <span class='id identifier rubyid_length_of'>length_of</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span>
|
|
512
|
+
|
|
513
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='id identifier rubyid_length'>length</span>
|
|
514
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span>
|
|
515
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0x%02X</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'> is a </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_length'>length</span><span class='embexpr_end'>}</span><span class='tstring_content'>-byte message, got </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='embexpr_end'>}</span><span class='tstring_content'> bytes</span><span class='tstring_end'>"</span></span>
|
|
516
|
+
<span class='kw'>end</span>
|
|
517
|
+
|
|
518
|
+
<span class='id identifier rubyid_bytes'>bytes</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>|</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>0</span><span class='rparen'>)</span> <span class='op'><<</span> <span class='int'>8</span><span class='rparen'>)</span> <span class='op'>|</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>0</span><span class='rparen'>)</span> <span class='op'><<</span> <span class='int'>16</span><span class='rparen'>)</span>
|
|
519
|
+
<span class='kw'>end</span></pre>
|
|
520
|
+
</td>
|
|
521
|
+
</tr>
|
|
522
|
+
</table>
|
|
523
|
+
</div>
|
|
524
|
+
|
|
525
|
+
<div class="method_details ">
|
|
526
|
+
<h3 class="signature " id="sysex?-class_method">
|
|
527
|
+
|
|
528
|
+
.<strong>sysex?</strong>(bytes) ⇒ <tt>Boolean</tt>
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
</h3><div class="docstring">
|
|
535
|
+
<div class="discussion">
|
|
536
|
+
<p>Is this the start of a System Exclusive message?</p>
|
|
537
|
+
|
|
538
|
+
</div>
|
|
539
|
+
</div>
|
|
540
|
+
<div class="tags">
|
|
541
|
+
<p class="tag_title">Parameters:</p>
|
|
542
|
+
<ul class="param">
|
|
543
|
+
|
|
544
|
+
<li>
|
|
545
|
+
|
|
546
|
+
<span class='name'>bytes</span>
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
<span class='type'>(<tt>Array<Integer></tt>)</span>
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
—
|
|
554
|
+
<div class='inline'><p>a message, status byte first</p></div>
|
|
555
|
+
|
|
556
|
+
</li>
|
|
557
|
+
|
|
558
|
+
</ul>
|
|
559
|
+
|
|
560
|
+
<p class="tag_title">Returns:</p>
|
|
561
|
+
<ul class="return">
|
|
562
|
+
|
|
563
|
+
<li>
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
</li>
|
|
571
|
+
|
|
572
|
+
</ul>
|
|
573
|
+
|
|
574
|
+
</div><table class="source_code">
|
|
575
|
+
<tr>
|
|
576
|
+
<td>
|
|
577
|
+
<pre class="lines">
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
129
|
|
581
|
+
130
|
|
582
|
+
131</pre>
|
|
583
|
+
</td>
|
|
584
|
+
<td>
|
|
585
|
+
<pre class="code"><span class="info file"># File 'lib/midi-communications-windows/message.rb', line 129</span>
|
|
586
|
+
|
|
587
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_sysex?'>sysex?</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='rparen'>)</span>
|
|
588
|
+
<span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>==</span> <span class='int'>0xF0</span>
|
|
589
|
+
<span class='kw'>end</span></pre>
|
|
590
|
+
</td>
|
|
591
|
+
</tr>
|
|
592
|
+
</table>
|
|
593
|
+
</div>
|
|
594
|
+
|
|
595
|
+
<div class="method_details ">
|
|
596
|
+
<h3 class="signature " id="unpack-class_method">
|
|
597
|
+
|
|
598
|
+
.<strong>unpack</strong>(word) ⇒ <tt>Array<Integer></tt>
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
</h3><div class="docstring">
|
|
605
|
+
<div class="discussion">
|
|
606
|
+
<p>Unpacks the word WinMM delivers for an incoming short message.</p>
|
|
607
|
+
|
|
608
|
+
</div>
|
|
609
|
+
</div>
|
|
610
|
+
<div class="tags">
|
|
611
|
+
|
|
612
|
+
<div class="examples">
|
|
613
|
+
<h4 class="tag_title">Examples:</h4>
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
<h5 class="example_title"><div class='inline'><p>A Clock arrives as a word whose upper bytes are zero</p></div></h5>
|
|
617
|
+
|
|
618
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="MIDICommunicationsWindows::Message (module)">Message</a></span></span><span class='period'>.</span><span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='int'>0x0000_00F8</span><span class='rparen'>)</span> <span class='comment'># => [0xF8]</span></code></pre>
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
<h5 class="example_title"><div class='inline'><p>A Note On carries all three</p></div></h5>
|
|
622
|
+
|
|
623
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="MIDICommunicationsWindows::Message (module)">Message</a></span></span><span class='period'>.</span><span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='int'>0x0064_3C90</span><span class='rparen'>)</span> <span class='comment'># => [0x90, 0x3C, 0x64]</span></code></pre>
|
|
624
|
+
|
|
625
|
+
</div>
|
|
626
|
+
<p class="tag_title">Parameters:</p>
|
|
627
|
+
<ul class="param">
|
|
628
|
+
|
|
629
|
+
<li>
|
|
630
|
+
|
|
631
|
+
<span class='name'>word</span>
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
—
|
|
639
|
+
<div class='inline'><p>the <code>dwParam1</code> of an <code>MM_MIM_DATA</code> notification</p></div>
|
|
640
|
+
|
|
641
|
+
</li>
|
|
642
|
+
|
|
643
|
+
</ul>
|
|
644
|
+
|
|
645
|
+
<p class="tag_title">Returns:</p>
|
|
646
|
+
<ul class="return">
|
|
647
|
+
|
|
648
|
+
<li>
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
<span class='type'>(<tt>Array<Integer></tt>)</span>
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
—
|
|
656
|
+
<div class='inline'><p>the message's bytes, of the length its status
|
|
657
|
+
byte calls for</p></div>
|
|
658
|
+
|
|
659
|
+
</li>
|
|
660
|
+
|
|
661
|
+
</ul>
|
|
662
|
+
|
|
663
|
+
</div><table class="source_code">
|
|
664
|
+
<tr>
|
|
665
|
+
<td>
|
|
666
|
+
<pre class="lines">
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
93
|
|
670
|
+
94
|
|
671
|
+
95
|
|
672
|
+
96
|
|
673
|
+
97</pre>
|
|
674
|
+
</td>
|
|
675
|
+
<td>
|
|
676
|
+
<pre class="code"><span class="info file"># File 'lib/midi-communications-windows/message.rb', line 93</span>
|
|
677
|
+
|
|
678
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='id identifier rubyid_word'>word</span><span class='rparen'>)</span>
|
|
679
|
+
<span class='id identifier rubyid_bytes'>bytes</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_word'>word</span> <span class='op'>&</span> <span class='int'>0xFF</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_word'>word</span> <span class='op'>>></span> <span class='int'>8</span><span class='rparen'>)</span> <span class='op'>&</span> <span class='int'>0xFF</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_word'>word</span> <span class='op'>>></span> <span class='int'>16</span><span class='rparen'>)</span> <span class='op'>&</span> <span class='int'>0xFF</span><span class='rbracket'>]</span>
|
|
680
|
+
|
|
681
|
+
<span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='lparen'>(</span><span class='id identifier rubyid_length_of'>length_of</span><span class='lparen'>(</span><span class='id identifier rubyid_bytes'>bytes</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
682
|
+
<span class='kw'>end</span></pre>
|
|
683
|
+
</td>
|
|
684
|
+
</tr>
|
|
685
|
+
</table>
|
|
686
|
+
</div>
|
|
687
|
+
|
|
688
|
+
</div>
|
|
689
|
+
|
|
690
|
+
</div>
|
|
691
|
+
|
|
692
|
+
<div id="footer">
|
|
693
|
+
Generated on Sun Sep 6 21:20:52 2026 by
|
|
694
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
695
|
+
0.9.45 (ruby-3.4.7).
|
|
696
|
+
</div>
|
|
697
|
+
|
|
698
|
+
</div>
|
|
699
|
+
</body>
|
|
700
|
+
</html>
|