mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 18:00:48 +00:00
check configpath only if configpath exists
override Loader to_s
This commit is contained in:
parent
01314e2e98
commit
ca66af7d84
@ -16,12 +16,16 @@ module Voicemeeter
|
|||||||
def initialize(kind)
|
def initialize(kind)
|
||||||
@kind = kind
|
@kind = kind
|
||||||
@configs = Hash.new
|
@configs = Hash.new
|
||||||
logger.debug("generated loader for #{kind}")
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"Loader #{@kind}"
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def build_reset_profile(overrides = {})
|
#stree-ignore
|
||||||
|
def build_reset_profile
|
||||||
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] }
|
||||||
@ -38,15 +42,7 @@ module Voicemeeter
|
|||||||
(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
|
||||||
|
|
||||||
@ -69,25 +65,25 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def read_from_yml
|
def read_from_yml
|
||||||
|
#stree-ignore
|
||||||
filepaths = [
|
filepaths = [
|
||||||
Pathname.getwd.join("configs", @kind.name.to_s),
|
Pathname.getwd.join("configs", @kind.name.to_s),
|
||||||
Pathname.new(Dir.home).join(
|
Pathname.new(Dir.home).join(".config", "voicemeeter-rb", @kind.name.to_s),
|
||||||
".config",
|
Pathname.new(Dir.home).join("Documents", "Voicemeeter", "configs", @kind.name.to_s)
|
||||||
"voicemeeter-rb",
|
|
||||||
@kind.name.to_s
|
|
||||||
),
|
|
||||||
Pathname.new(Dir.home).join(
|
|
||||||
"Documents",
|
|
||||||
"Voicemeeter",
|
|
||||||
"configs",
|
|
||||||
@kind.name.to_s
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
filepaths.each do |pn|
|
filepaths.each do |pn|
|
||||||
|
if pn.exist?
|
||||||
|
logger.debug "checking #{pn} for configs"
|
||||||
configs = pn.glob("*.yml")
|
configs = pn.glob("*.yml")
|
||||||
configs.each do |config|
|
configs.each do |config|
|
||||||
filename = config.basename.sub_ext ""
|
filename = (config.basename.sub_ext "").to_s.to_sym
|
||||||
@configs[filename.to_s.to_sym] = YAML.load_file(config)
|
if @configs.key? filename
|
||||||
|
logger.debug "config with name '#{filename}' already in memory, skipping..."
|
||||||
|
next
|
||||||
|
end
|
||||||
|
@configs[filename] = YAML.load_file(config)
|
||||||
|
logger.info "#{@kind.name}/#{filename} loaded into memory"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -95,6 +91,7 @@ module Voicemeeter
|
|||||||
public
|
public
|
||||||
|
|
||||||
def build
|
def build
|
||||||
|
logger.debug "Running #{self}"
|
||||||
@configs[:reset] = build_reset_profile
|
@configs[:reset] = build_reset_profile
|
||||||
read_from_yml
|
read_from_yml
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user