2023-07-07 02:36:35 +01:00
|
|
|
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-16 23:30:24 +01:00
|
|
|
require_relative "fx"
|
2023-07-17 07:10:08 +01:00
|
|
|
require_relative "patch"
|
2023-07-17 06:30:09 +01:00
|
|
|
require_relative "option"
|
2023-07-09 05:50:57 +01:00
|
|
|
require_relative "configs"
|
2023-07-07 02:36:35 +01:00
|
|
|
|
|
|
|
module Voicemeeter
|
2023-07-20 09:50:16 +01:00
|
|
|
module Builder
|
2023-07-07 02:36:35 +01:00
|
|
|
private
|
|
|
|
|
2023-07-20 09:50:16 +01:00
|
|
|
def steps
|
|
|
|
{
|
2023-07-22 13:05:38 +01:00
|
|
|
strip: -> { (0...kind.num_strip).map { Strip::Strip.make(self, _1) } },
|
|
|
|
bus: -> { (0...kind.num_bus).map { Bus::Bus.make(self, _1) } },
|
|
|
|
button: -> { (0...kind.num_buttons).map { Button::Button.new(self, _1) } },
|
2023-07-20 09:50:16 +01:00
|
|
|
vban: -> { Vban::Vban.new(self) },
|
|
|
|
command: -> { Command.new(self) },
|
|
|
|
recorder: -> { Recorder::Recorder.new(self) },
|
|
|
|
device: -> { Device.new(self) },
|
|
|
|
fx: -> { Fx.new(self) },
|
|
|
|
patch: -> { Patch::Patch.new(self) },
|
|
|
|
option: -> { Option::Option.new(self) }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def director
|
|
|
|
[:strip, :bus, :button, :vban, :command, :device, :option]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Remote
|
2023-07-07 02:36:35 +01:00
|
|
|
class Remote < Base
|
2023-07-20 09:50:16 +01:00
|
|
|
include Builder
|
|
|
|
|
2023-07-22 10:08:18 +01:00
|
|
|
public attr_reader :strip, :bus, :button, :vban, :command, :device, :option
|
|
|
|
private attr_writer :strip, :bus, :button, :vban, :command, :device, :option
|
|
|
|
|
2023-07-22 16:44:34 +01:00
|
|
|
def initialize(kind, **)
|
2023-07-07 02:36:35 +01:00
|
|
|
super
|
2023-07-22 10:08:18 +01:00
|
|
|
steps.select { |k, v| director.include? k }.each do |k, v|
|
|
|
|
send("#{k}=", v.call)
|
|
|
|
end
|
2023-07-07 02:36:35 +01:00
|
|
|
end
|
2023-07-09 05:50:57 +01:00
|
|
|
|
|
|
|
def configs
|
2023-07-14 01:46:46 +01:00
|
|
|
Configs.get(kind.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
login
|
2023-07-21 14:37:17 +01:00
|
|
|
if event.any?
|
|
|
|
init_event_threads
|
|
|
|
end
|
2023-07-14 01:46:46 +01:00
|
|
|
|
2023-07-14 17:07:56 +01:00
|
|
|
yield(self) if block_given?
|
2023-07-21 14:37:17 +01:00
|
|
|
ensure
|
|
|
|
end_event_threads
|
2023-07-14 01:46:46 +01:00
|
|
|
logout
|
2023-07-09 05:50:57 +01:00
|
|
|
end
|
2023-07-07 02:36:35 +01:00
|
|
|
end
|
|
|
|
|
2023-07-16 22:33:02 +01:00
|
|
|
class RemoteBasic < Remote
|
|
|
|
end
|
|
|
|
|
|
|
|
class RemoteBanana < Remote
|
2023-07-22 10:08:18 +01:00
|
|
|
public attr_reader :recorder, :patch
|
|
|
|
private attr_writer :recorder, :patch
|
2023-07-20 09:50:16 +01:00
|
|
|
|
|
|
|
private def director
|
|
|
|
super.append(:recorder, :patch)
|
|
|
|
end
|
2023-07-16 22:33:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
class RemotePotato < Remote
|
2023-07-22 10:08:18 +01:00
|
|
|
public attr_reader :recorder, :patch, :fx
|
|
|
|
private attr_writer :recorder, :patch, :fx
|
2023-07-20 09:50:16 +01:00
|
|
|
|
|
|
|
private def director
|
|
|
|
super.append(:recorder, :patch, :fx)
|
|
|
|
end
|
2023-07-16 22:33:02 +01:00
|
|
|
end
|
|
|
|
|
2023-07-22 10:08:18 +01:00
|
|
|
class RequestRemote
|
2023-07-22 16:44:34 +01:00
|
|
|
def self.for(kind, **)
|
2023-07-22 10:08:18 +01:00
|
|
|
case kind.name
|
|
|
|
when :basic
|
2023-07-22 16:44:34 +01:00
|
|
|
RemoteBasic.new(kind, **)
|
2023-07-22 10:08:18 +01:00
|
|
|
when :banana
|
2023-07-22 16:44:34 +01:00
|
|
|
RemoteBanana.new(kind, **)
|
2023-07-22 10:08:18 +01:00
|
|
|
when :potato
|
2023-07-22 16:44:34 +01:00
|
|
|
RemotePotato.new(kind, **)
|
2023-07-22 10:08:18 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-07 02:36:35 +01:00
|
|
|
public
|
|
|
|
|
2023-07-22 16:44:34 +01:00
|
|
|
def self.new(kind_id, **)
|
2023-07-16 22:33:02 +01:00
|
|
|
kind = Kinds.get(kind_id)
|
|
|
|
rescue KeyError
|
|
|
|
raise Errors::VMError.new "unknown Voicemeeter kind #{kind_id}"
|
|
|
|
else
|
2023-07-22 16:44:34 +01:00
|
|
|
RequestRemote.for(kind, **)
|
2023-07-07 02:36:35 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|