fixes bug reading midi values

This commit is contained in:
onyx-and-iris 2023-07-18 07:30:04 +01:00
parent eaf92197dc
commit e5be645818
3 changed files with 6 additions and 9 deletions

View File

@ -209,11 +209,11 @@ module Voicemeeter
exp: ->(x) { x >= 0 }
)
if (got_midi = res > 0)
vals = cmsg.read_string_bytes
vals = cmsg.read_string.bytes
vals.each_slice(3) do |ch, key, velocity|
midi.channel = ch if midi.channel.nil? || midi.channel != ch
midi.channel = ch.to_i
midi.current = key.to_i
midi.set(key.to_i, velocity.to_i)
midi.cache[key.to_i] = velocity.to_i
end
end
got_midi

View File

@ -18,7 +18,7 @@ module Voicemeeter
def trigger(event)
@callbacks.each do |callback|
if callback.respond_to? :on_update
callback.on_update { event.to_s[3..] }
callback.on_update event.to_s[3..]
elsif callback.name == event
callback.call
end

View File

@ -1,6 +1,7 @@
module Voicemeeter
class Midi
attr_accessor :cache, :current, :channel
attr_accessor :current, :channel
attr_reader :cache
def initialize
@cache = {}
@ -9,9 +10,5 @@ module Voicemeeter
def get(key)
cache[key]
end
def set(key, velocity)
cache[key] = velocity
end
end
end