mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-15 23:00:48 +00:00
read_from_yaml implemented
This commit is contained in:
parent
f7f8ed64ee
commit
e91d8dbd37
@ -1,6 +1,8 @@
|
|||||||
require "yaml"
|
require "yaml"
|
||||||
require_relative "kinds"
|
|
||||||
require "easy_logging"
|
require "easy_logging"
|
||||||
|
require "pathname"
|
||||||
|
|
||||||
|
require_relative "kinds"
|
||||||
|
|
||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
module Configs
|
module Configs
|
||||||
@ -22,49 +24,92 @@ module Voicemeeter
|
|||||||
def build_reset_profile(overrides = {})
|
def build_reset_profile(overrides = {})
|
||||||
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] }
|
||||||
bools = %w[mute mono solo].to_h { |param| [param, false] }
|
strip_bools = %w[mute mono solo].to_h { |param| [param, false] }
|
||||||
floats = ["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 }] }
|
||||||
phys_bool = ["eq"].to_h { |param| [param, { on: false }] }
|
eq = ["eq"].to_h { |param| [param, { on: false }] }
|
||||||
|
|
||||||
|
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, **bools, **floats, **phys_float, **phys_bool }
|
{
|
||||||
|
**aouts,
|
||||||
|
**bouts,
|
||||||
|
**strip_bools,
|
||||||
|
**gain,
|
||||||
|
**phys_float,
|
||||||
|
**eq,
|
||||||
|
**overrides
|
||||||
|
}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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|
|
||||||
["strip-#{i}", { **aouts, **bouts, **bools, **floats }]
|
[
|
||||||
|
"strip-#{i}",
|
||||||
|
{ **aouts, **bouts, **strip_bools, **gain, **overrides }
|
||||||
|
]
|
||||||
end
|
end
|
||||||
{ **phys_strip, **virt_strip }
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
def build
|
def build
|
||||||
@configs[:reset] = build_reset_profile
|
@configs[:reset] = build_reset_profile
|
||||||
|
read_from_yml
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
def load
|
def get(kind_id)
|
||||||
if @loaders.nil?
|
if @loaders.nil?
|
||||||
@loaders = Kinds::ALL.to_h { |kind| [kind.name, Loader.new(kind)] }
|
@loaders = Kinds::ALL.to_h { |kind| [kind.name, Loader.new(kind)] }
|
||||||
@loaders.each { |name, loader| loader.build }
|
@loaders.each { |name, loader| loader.build }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def get(kind_id)
|
|
||||||
@loaders[kind_id].configs
|
@loaders[kind_id].configs
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function :get, :load
|
module_function :get
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user