voicemeeter-rb/lib/voicemeeter/remote.rb

56 lines
1.3 KiB
Ruby
Raw Normal View History

require_relative "base"
require_relative "kinds"
require_relative "errors"
require_relative "strip"
require_relative "bus"
require_relative "button"
require_relative "vban"
2023-07-14 17:07:56 +01:00
require_relative "command"
2023-07-14 16:12:18 +01:00
require_relative "recorder"
2023-07-15 00:16:54 +01:00
require_relative "device"
2023-07-09 05:50:57 +01:00
require_relative "configs"
module Voicemeeter
module Remote
private
class Remote < Base
2023-07-15 00:16:54 +01:00
attr_reader :strip, :bus, :button, :vban, :command, :recorder, :device
def initialize(kind, **kwargs)
super
@strip = (0...kind.num_strip).map { |i| Strip::Strip.make(self, i) }
@bus = (0...kind.num_bus).map { |i| Bus::Bus.make(self, i) }
@button = (0...kind.num_buttons).map { |i| Button::Button.new(self, i) }
@vban = Vban::Vban.new(self)
2023-07-14 17:07:56 +01:00
@command = Command.new(self)
2023-07-14 16:12:18 +01:00
@recorder = Recorder::Recorder.new(self)
2023-07-15 00:16:54 +01:00
@device = Device.new(self)
end
2023-07-09 05:50:57 +01:00
def configs
Configs.get(kind.name)
end
def run
login
2023-07-14 17:07:56 +01:00
yield(self) if block_given?
logout
2023-07-09 05:50:57 +01:00
end
end
public
def self.new(kind_id, **kwargs)
remotes =
Kinds::ALL.to_h { |kind| [kind.name, Remote.new(kind, **kwargs)] }
unless remotes.key? kind_id
raise Errors::VMError.new("unknown Voicemeeter kind #{kind_id}")
end
remotes[kind_id]
end
end
end