From 45370cb2349385f2d603c12c83f153e4d78bc56f Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 29 Jul 2023 18:11:52 +0100 Subject: [PATCH] fixes bug reading zero values. (input with index 0, velocity 0 etc) --- lib/voicemeeter/base.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/voicemeeter/base.rb b/lib/voicemeeter/base.rb index 3bb9128..d77167a 100644 --- a/lib/voicemeeter/base.rb +++ b/lib/voicemeeter/base.rb @@ -199,11 +199,11 @@ module Voicemeeter exp: ->(x) { x >= 0 } ) if (got_midi = res > 0) - vals = cmsg.read_string.bytes - vals.each_slice(3) do |ch, key, velocity| - midi.channel = ch.to_i - midi.current = key.to_i - midi.cache[key.to_i] = velocity.to_i + data = cmsg.read_bytes(res).bytes + data.each_slice(3) do |ch, key, velocity| + midi.channel = ch + midi.current = key + midi.cache[key] = velocity end end got_midi