apply(), apply_config() implemented

version now printed in login logger.info string
This commit is contained in:
onyx-and-iris 2023-07-09 05:48:08 +01:00
parent 80f76c36b7
commit abd64034b1

View File

@ -2,9 +2,12 @@ require_relative "install"
require_relative "cbindings" require_relative "cbindings"
require_relative "kinds" require_relative "kinds"
require_relative "midi" require_relative "midi"
require "easy_logging"
module Voicemeeter module Voicemeeter
class Base class Base
include EasyLogging
attr_reader :kind, :midi attr_reader :kind, :midi
def initialize(kind, **kwargs) def initialize(kind, **kwargs)
@ -13,15 +16,21 @@ module Voicemeeter
@midi = Midi.new @midi = Midi.new
end end
def to_s
"Voicemeeter #{@kind}"
end
def login def login
self.runvm if CBindings.call(:bind_login, ok: [0, 1]) == 1 self.runvm if CBindings.call(:bind_login, ok: [0, 1]) == 1
clear_dirty clear_dirty
logger.info "Successfully logged into #{self} version #{version}"
end end
def logout def logout
clear_dirty clear_dirty
sleep(0.1) sleep(0.1)
CBindings.call(:bind_logout) CBindings.call(:bind_logout)
logger.info "Sucessfully logged out of #{self}"
end end
def pdirty? def pdirty?
@ -43,9 +52,8 @@ module Voicemeeter
kinds = { kinds = {
basic: Kinds::KindEnum::BASIC, basic: Kinds::KindEnum::BASIC,
banana: Kinds::KindEnum::BANANA, banana: Kinds::KindEnum::BANANA,
potato: Kinds::KindEnum::POTATO potato: Install::OS_BITS == 64 ? 6 : Kinds::KindEnum::POTATO
} }
kinds[:potato] = 6 if Install::OS_BITS == 64
CBindings.call(:bind_runvm, kinds[@kind.name]) CBindings.call(:bind_runvm, kinds[@kind.name])
sleep(1) sleep(1)
end end
@ -157,5 +165,24 @@ module Voicemeeter
end end
got_midi got_midi
end end
def apply(data)
data.each do |key, val|
kls, index, *rem = key.to_s.split("-")
if rem.empty?
target = self.send(kls)
else
dir = "#{index.chomp("stream")}stream"
index = rem[0]
target = self.vban.send(dir)
end
target[index.to_i].apply(val)
end
end
def apply_config(name)
apply(self.configs[name])
logger.info("profile #{name} applied!")
end
end end
end end