mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-24 10:50:49 +00:00
fixes bug reading midi values
This commit is contained in:
parent
eaf92197dc
commit
e5be645818
@ -209,11 +209,11 @@ module Voicemeeter
|
|||||||
exp: ->(x) { x >= 0 }
|
exp: ->(x) { x >= 0 }
|
||||||
)
|
)
|
||||||
if (got_midi = res > 0)
|
if (got_midi = res > 0)
|
||||||
vals = cmsg.read_string_bytes
|
vals = cmsg.read_string.bytes
|
||||||
vals.each_slice(3) do |ch, key, velocity|
|
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.current = key.to_i
|
||||||
midi.set(key.to_i, velocity.to_i)
|
midi.cache[key.to_i] = velocity.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
got_midi
|
got_midi
|
||||||
|
@ -18,7 +18,7 @@ module Voicemeeter
|
|||||||
def trigger(event)
|
def trigger(event)
|
||||||
@callbacks.each do |callback|
|
@callbacks.each do |callback|
|
||||||
if callback.respond_to? :on_update
|
if callback.respond_to? :on_update
|
||||||
callback.on_update { event.to_s[3..] }
|
callback.on_update event.to_s[3..]
|
||||||
elsif callback.name == event
|
elsif callback.name == event
|
||||||
callback.call
|
callback.call
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
class Midi
|
class Midi
|
||||||
attr_accessor :cache, :current, :channel
|
attr_accessor :current, :channel
|
||||||
|
attr_reader :cache
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@cache = {}
|
@cache = {}
|
||||||
@ -9,9 +10,5 @@ module Voicemeeter
|
|||||||
def get(key)
|
def get(key)
|
||||||
cache[key]
|
cache[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(key, velocity)
|
|
||||||
cache[key] = velocity
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user