ffi-coremidi 0.3.3 → 0.3.4
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 +4 -4
- data/lib/coremidi.rb +1 -1
- data/lib/coremidi/source.rb +24 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 752cf9224dff1bcef04045b05c844967890ce76a
|
4
|
+
data.tar.gz: 0579caa9d9f3c37194925d45338168e91a882869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b82dbdb161c5f4d6c135d325ae862072b6df2c2f82bf70fca28aa2eb805a4f4815a914a5b693e09ae6964289d33d601779197fbaf611e520bc5a1d9a01419f
|
7
|
+
data.tar.gz: b540b594437d51a15e4e7ad7b40da1953db2d0e4bfff20aad1346afbb1e08149746b826e240ca116698c74947b5de773e4782c0297e031f01d3041b5c7fbc4bf
|
data/lib/coremidi.rb
CHANGED
data/lib/coremidi/source.rb
CHANGED
@@ -172,18 +172,39 @@ module CoreMIDI
|
|
172
172
|
messages = []
|
173
173
|
messages << data.slice!(0, first[:length])
|
174
174
|
(count - 1).times do |i|
|
175
|
-
|
175
|
+
length_index = find_next_length_index(data)
|
176
|
+
message_length = data[length_index]
|
176
177
|
unless message_length.nil?
|
177
|
-
|
178
|
+
packet_start_index = length_index + 2
|
179
|
+
packet_end_index = packet_start_index + message_length
|
178
180
|
if data.length >= packet_end_index + 1
|
179
181
|
packet = data.slice!(0..packet_end_index)
|
180
|
-
|
182
|
+
message = packet.slice(packet_start_index, message_length)
|
183
|
+
messages << message
|
181
184
|
end
|
182
185
|
end
|
183
186
|
end
|
184
187
|
messages
|
185
188
|
end
|
186
189
|
|
190
|
+
# Get the next index for "length" from the blob of MIDI data
|
191
|
+
# @param [Array<Fixnum>] data
|
192
|
+
# @return [Fixnum]
|
193
|
+
def find_next_length_index(data)
|
194
|
+
last_is_zero = false
|
195
|
+
data.each_with_index do |num, i|
|
196
|
+
if num.zero?
|
197
|
+
if last_is_zero
|
198
|
+
return i + 1
|
199
|
+
else
|
200
|
+
last_is_zero = true
|
201
|
+
end
|
202
|
+
else
|
203
|
+
last_is_zero = false
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
187
208
|
# Timestamp for a received MIDI message
|
188
209
|
# @return [Fixnum]
|
189
210
|
def timestamp(now)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-coremidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|