2023-07-13 21:57:32 +01:00
|
|
|
require "easy_logging"
|
|
|
|
|
|
|
|
module Voicemeeter
|
|
|
|
module Worker
|
|
|
|
include EasyLogging
|
|
|
|
|
|
|
|
def init_producer(que)
|
|
|
|
Thread.new do
|
2023-07-14 01:46:25 +01:00
|
|
|
while @running
|
2023-07-13 21:57:32 +01:00
|
|
|
que << :pdirty if event.pdirty
|
|
|
|
que << :mdirty if event.mdirty
|
|
|
|
que << :midi if event.midi
|
|
|
|
que << :ldirty if event.ldirty
|
|
|
|
sleep(@ratelimit)
|
|
|
|
end
|
2023-07-14 01:46:25 +01:00
|
|
|
que << :stop
|
2023-07-13 21:57:32 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def init_worker(que)
|
|
|
|
logger.info "Listening for #{event.get.join(", ")} events"
|
|
|
|
@cache[:strip_level], @cache[:bus_level] = _get_levels
|
|
|
|
@running = true
|
|
|
|
Thread.new do
|
|
|
|
loop do
|
|
|
|
e_from_que = @que.pop
|
2023-07-14 01:46:25 +01:00
|
|
|
if e_from_que == :stop
|
2023-07-13 21:57:32 +01:00
|
|
|
break
|
|
|
|
logger.debug("closing #{self} thread")
|
|
|
|
end
|
|
|
|
on_event :on_pdirty if e_from_que == :pdirty && pdirty?
|
|
|
|
on_event :on_mdirty if e_from_que == :mdirty && mdirty?
|
|
|
|
on_event :on_midi if e_from_que == :midi && get_midi_message
|
|
|
|
if e_from_que == :ldirty && ldirty?
|
2023-07-14 01:46:25 +01:00
|
|
|
cache[:strip_comp] = cache[:strip_level].map.with_index do |x, i|
|
|
|
|
!(x == cache[:strip_buf][i])
|
|
|
|
end
|
|
|
|
cache[:bus_comp] = cache[:bus_level].map.with_index do |x, i|
|
|
|
|
!(x == cache[:bus_buf][i])
|
|
|
|
end
|
|
|
|
cache[:strip_level] = cache[:strip_buf]
|
|
|
|
cache[:bus_level] = cache[:bus_buf]
|
2023-07-13 21:57:32 +01:00
|
|
|
on_event :on_ldirty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_worker
|
|
|
|
@running = false
|
|
|
|
end
|
|
|
|
|
|
|
|
module_function :init_worker, :end_worker
|
|
|
|
end
|
|
|
|
end
|