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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 139d11b8026aa7260adbd6388fb4872b7773409e
4
- data.tar.gz: 1254869a8df40213da841a526d06fb30a8e55c3f
3
+ metadata.gz: 752cf9224dff1bcef04045b05c844967890ce76a
4
+ data.tar.gz: 0579caa9d9f3c37194925d45338168e91a882869
5
5
  SHA512:
6
- metadata.gz: 93cd4cc3d7c7415c6e5d90aa1b6794598639701cb528adf07c6ee5cd7051a65c250858b62c86ae36062a8cbf281e230452f8876868dd420286d5cfb24122c3a6
7
- data.tar.gz: a71bcd64f2c44eb5e80e2bdd1912a3459ab82f0e9e94f0532e98c5ac7b214c0337636db2e76fbf2fc5a12248721cedef96878c9258421773692641110cb88e6c
6
+ metadata.gz: 71b82dbdb161c5f4d6c135d325ae862072b6df2c2f82bf70fca28aa2eb805a4f4815a914a5b693e09ae6964289d33d601779197fbaf611e520bc5a1d9a01419f
7
+ data.tar.gz: b540b594437d51a15e4e7ad7b40da1953db2d0e4bfff20aad1346afbb1e08149746b826e240ca116698c74947b5de773e4782c0297e031f01d3041b5c7fbc4bf
data/lib/coremidi.rb CHANGED
@@ -19,5 +19,5 @@ require "coremidi/source"
19
19
  require "coremidi/destination"
20
20
 
21
21
  module CoreMIDI
22
- VERSION = "0.3.3"
22
+ VERSION = "0.3.4"
23
23
  end
@@ -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
- message_length = data[8]
175
+ length_index = find_next_length_index(data)
176
+ message_length = data[length_index]
176
177
  unless message_length.nil?
177
- packet_end_index = 10 + message_length
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
- messages << packet.slice(10, message_length)
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.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-16 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi