2023-07-09 05:47:37 +01:00
|
|
|
require "yaml"
|
|
|
|
require "easy_logging"
|
2023-07-09 19:44:43 +01:00
|
|
|
require "pathname"
|
|
|
|
|
|
|
|
require_relative "kinds"
|
2023-07-09 05:47:37 +01:00
|
|
|
|
|
|
|
module Voicemeeter
|
|
|
|
module Configs
|
|
|
|
private
|
|
|
|
|
|
|
|
class Loader
|
|
|
|
include EasyLogging
|
|
|
|
|
|
|
|
attr_reader :configs
|
|
|
|
|
|
|
|
def initialize(kind)
|
|
|
|
@kind = kind
|
|
|
|
@configs = Hash.new
|
|
|
|
logger.debug("generated loader for #{kind}")
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def build_reset_profile(overrides = {})
|
|
|
|
aouts = (0...@kind.phys_out).to_h { |i| ["A#{i + 1}", false] }
|
|
|
|
bouts = (0...@kind.virt_out).to_h { |i| ["B#{i + 1}", false] }
|
2023-07-09 19:44:43 +01:00
|
|
|
strip_bools = %w[mute mono solo].to_h { |param| [param, false] }
|
|
|
|
gain = ["gain"].to_h { |param| [param, 0.0] }
|
2023-07-09 05:47:37 +01:00
|
|
|
|
|
|
|
phys_float =
|
|
|
|
%w[comp gate denoiser].to_h { |param| [param, { knob: 0.0 }] }
|
2023-07-09 19:44:43 +01:00
|
|
|
eq = ["eq"].to_h { |param| [param, { on: false }] }
|
|
|
|
|
|
|
|
overrides = { "B1" => true }
|
2023-07-09 05:47:37 +01:00
|
|
|
|
|
|
|
# physical strip params
|
|
|
|
phys_strip =
|
|
|
|
(0...@kind.phys_in).to_h do |i|
|
|
|
|
[
|
|
|
|
"strip-#{i}",
|
2023-07-09 19:44:43 +01:00
|
|
|
{
|
|
|
|
**aouts,
|
|
|
|
**bouts,
|
|
|
|
**strip_bools,
|
|
|
|
**gain,
|
|
|
|
**phys_float,
|
|
|
|
**eq,
|
|
|
|
**overrides
|
|
|
|
}
|
2023-07-09 05:47:37 +01:00
|
|
|
]
|
|
|
|
end
|
2023-07-09 19:44:43 +01:00
|
|
|
|
|
|
|
overrides = { "A1" => true }
|
2023-07-09 05:47:37 +01:00
|
|
|
# virtual strip params
|
|
|
|
virt_strip =
|
|
|
|
(@kind.phys_in...@kind.phys_in + @kind.virt_in).to_h do |i|
|
2023-07-09 19:44:43 +01:00
|
|
|
[
|
|
|
|
"strip-#{i}",
|
|
|
|
{ **aouts, **bouts, **strip_bools, **gain, **overrides }
|
|
|
|
]
|
2023-07-09 05:47:37 +01:00
|
|
|
end
|
2023-07-09 19:44:43 +01:00
|
|
|
|
|
|
|
bus_bools = %w[mute mono].to_h { |param| [param, false] }
|
|
|
|
bus =
|
|
|
|
(0...@kind.num_bus).to_h do |i|
|
|
|
|
["bus-#{i}", { **bus_bools, **gain, **eq }]
|
|
|
|
end
|
|
|
|
{ **phys_strip, **virt_strip, **bus }
|
|
|
|
end
|
|
|
|
|
|
|
|
def read_from_yml
|
|
|
|
filepaths = [
|
|
|
|
Pathname.getwd.join("configs", @kind.name.to_s),
|
|
|
|
Pathname.new(Dir.home).join(
|
|
|
|
".config",
|
|
|
|
"voicemeeter-rb",
|
|
|
|
@kind.name.to_s
|
|
|
|
),
|
|
|
|
Pathname.new(Dir.home).join(
|
|
|
|
"Documents",
|
|
|
|
"Voicemeeter",
|
|
|
|
"configs",
|
|
|
|
@kind.name.to_s
|
|
|
|
)
|
|
|
|
]
|
|
|
|
filepaths.each do |pn|
|
|
|
|
configs = pn.glob("*.yml")
|
|
|
|
configs.each do |config|
|
|
|
|
filename = config.basename.sub_ext ""
|
|
|
|
@configs[filename.to_s.to_sym] = YAML.load_file(config)
|
|
|
|
end
|
|
|
|
end
|
2023-07-09 05:47:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
def build
|
|
|
|
@configs[:reset] = build_reset_profile
|
2023-07-09 19:44:43 +01:00
|
|
|
read_from_yml
|
2023-07-09 05:47:37 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
public
|
|
|
|
|
2023-07-09 19:44:43 +01:00
|
|
|
def get(kind_id)
|
2023-07-09 05:47:37 +01:00
|
|
|
if @loaders.nil?
|
|
|
|
@loaders = Kinds::ALL.to_h { |kind| [kind.name, Loader.new(kind)] }
|
|
|
|
@loaders.each { |name, loader| loader.build }
|
|
|
|
end
|
|
|
|
@loaders[kind_id].configs
|
|
|
|
end
|
|
|
|
|
2023-07-09 19:44:43 +01:00
|
|
|
module_function :get
|
2023-07-09 05:47:37 +01:00
|
|
|
end
|
|
|
|
end
|