event type passed as symbol to on_update callback

This commit is contained in:
onyx-and-iris 2023-08-03 13:13:01 +01:00
parent 33635e5f9b
commit 2dab83ec31
3 changed files with 7 additions and 7 deletions

View File

@ -14,7 +14,7 @@ class Main
end end
def on_update(event) def on_update(event)
if event == "midi" if event == :midi
current = @vm.midi.current current = @vm.midi.current
midi_handler(current, @vm.midi.get(current)) midi_handler(current, @vm.midi.get(current))
end end

View File

@ -18,9 +18,9 @@ module Voicemeeter
private def trigger(event) private def trigger(event)
callbacks.each do |callback| callbacks.each do |callback|
if callback.is_a? Method if callback.is_a? Method
callback.call if callback.name == event callback.call if callback.name == "on_#{event}".to_sym
elsif callback.respond_to? :on_update elsif callback.respond_to? :on_update
callback.on_update event.to_s[3..] callback.on_update event
end end
end end
end end

View File

@ -35,15 +35,15 @@ module Voicemeeter
logger.debug "closing #{Thread.current.name} thread" logger.debug "closing #{Thread.current.name} thread"
break break
end end
trigger :on_pdirty if e_from_que == :pdirty && pdirty? trigger :pdirty if e_from_que == :pdirty && pdirty?
trigger :on_mdirty if e_from_que == :mdirty && mdirty? trigger :mdirty if e_from_que == :mdirty && mdirty?
trigger :on_midi if e_from_que == :midi && get_midi_message trigger :midi if e_from_que == :midi && get_midi_message
if e_from_que == :ldirty && ldirty? if e_from_que == :ldirty && ldirty?
cache[:strip_comp] = cache[:strip_level].zip(cache[:strip_buf]).map { |a, b| a != b } cache[:strip_comp] = cache[:strip_level].zip(cache[:strip_buf]).map { |a, b| a != b }
cache[:bus_comp] = cache[:bus_level].zip(cache[:bus_buf]).map { |a, b| a != b } cache[:bus_comp] = cache[:bus_level].zip(cache[:bus_buf]).map { |a, b| a != b }
cache[:strip_level] = cache[:strip_buf] cache[:strip_level] = cache[:strip_buf]
cache[:bus_level] = cache[:bus_buf] cache[:bus_level] = cache[:bus_buf]
trigger :on_ldirty trigger :ldirty
end end
end end
end end