bug in read_from_yml fixed

This commit is contained in:
onyx-and-iris 2023-07-14 01:48:11 +01:00
parent 5dbf3e547c
commit 3e6fe5c443

View File

@ -29,24 +29,24 @@ module Voicemeeter
aouts = (0...@kind.phys_out).to_h { |i| ["A#{i + 1}", false] } aouts = (0...@kind.phys_out).to_h { |i| ["A#{i + 1}", false] }
bouts = (0...@kind.virt_out).to_h { |i| ["B#{i + 1}", false] } bouts = (0...@kind.virt_out).to_h { |i| ["B#{i + 1}", false] }
strip_bools = %w[mute mono solo].to_h { |param| [param, false] } strip_bools = %w[mute mono solo].to_h { |param| [param, false] }
gain = ["gain"].to_h { |param| [param, 0.0] } gain = [:gain].to_h { |param| [param, 0.0] }
phys_float = phys_float =
%w[comp gate denoiser].to_h { |param| [param, { knob: 0.0 }] } %w[comp gate denoiser].to_h { |param| [param, { knob: 0.0 }] }
eq = ["eq"].to_h { |param| [param, { on: false }] } eq = [:eq].to_h { |param| [param, { on: false }] }
overrides = { "B1" => true } overrides = { B1: true }
# physical strip params # physical strip params
phys_strip = phys_strip =
(0...@kind.phys_in).to_h do |i| (0...@kind.phys_in).to_h do |i|
[ [
"strip-#{i}", "strip-#{i}",
{**aouts,**bouts,**strip_bools,**gain,**phys_float,**eq,**overrides} {**aouts, **bouts, **strip_bools, **gain, **phys_float, **eq, **overrides}
] ]
end end
overrides = { "A1" => true } overrides = { A1: true }
# virtual strip params # virtual strip params
virt_strip = virt_strip =
(@kind.phys_in...@kind.phys_in + @kind.virt_in).to_h do |i| (@kind.phys_in...@kind.phys_in + @kind.virt_in).to_h do |i|
@ -56,7 +56,7 @@ module Voicemeeter
] ]
end end
bus_bools = %w[mute mono].to_h { |param| [param, false] } bus_bools = %i[mute mono].to_h { |param| [param, false] }
bus = bus =
(0...@kind.num_bus).to_h do |i| (0...@kind.num_bus).to_h do |i|
["bus-#{i}", { **bus_bools, **gain, **eq }] ["bus-#{i}", { **bus_bools, **gain, **eq }]
@ -66,22 +66,26 @@ module Voicemeeter
def read_from_yml def read_from_yml
#stree-ignore #stree-ignore
filepaths = [ configpaths = [
Pathname.getwd.join("configs", @kind.name.to_s), 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(".config", "voicemeeter-rb", @kind.name.to_s),
Pathname.new(Dir.home).join("Documents", "Voicemeeter", "configs", @kind.name.to_s) Pathname.new(Dir.home).join("Documents", "Voicemeeter", "configs", @kind.name.to_s)
] ]
filepaths.each do |pn| configpaths.each do |configpath|
if pn.exist? if configpath.exist?
logger.debug "checking #{pn} for configs" logger.debug "checking #{configpath} for configs"
configs = pn.glob("*.yml") filepaths = configpath.glob("*.yml")
configs.each do |config| filepaths.each do |filepath|
filename = (config.basename.sub_ext "").to_s.to_sym filename = (filepath.basename.sub_ext "").to_s.to_sym
if @configs.key? filename if configs.key? filename
logger.debug "config with name '#{filename}' already in memory, skipping..." logger.debug "config with name '#{filename}' already in memory, skipping..."
next next
end end
@configs[filename] = YAML.load_file(config)
configs[filename] = YAML.load_file(
filepath,
symbolize_names: true
)
logger.info "#{@kind.name}/#{filename} loaded into memory" logger.info "#{@kind.name}/#{filename} loaded into memory"
end end
end end
@ -92,7 +96,7 @@ module Voicemeeter
def build def build
logger.debug "Running #{self}" logger.debug "Running #{self}"
@configs[:reset] = build_reset_profile configs[:reset] = build_reset_profile
read_from_yml read_from_yml
end end
end end