Device class implemented

This commit is contained in:
onyx-and-iris 2023-07-15 00:16:54 +01:00
parent 077a14fe62
commit 24edb0b134
2 changed files with 33 additions and 1 deletions

30
lib/voicemeeter/device.rb Normal file
View File

@ -0,0 +1,30 @@
require_relative "iremote"
require_relative "meta"
module Voicemeeter
class Device
def initialize(remote)
@remote = remote
end
def to_s
"#{self.class.name.split("::").last}#{@index}#{@remote.kind}"
end
def getter(**kwargs)
return @remote.get_num_devices(kwargs[:direction]) if kwargs[:index].nil?
vals = @remote.get_device_description(kwargs[:index], kwargs[:direction])
types = {1 => "mme", 3 => "wdm", 4 => "ks", 5 => "asio"}
{name: vals[0], type: types[vals[1]], id: vals[2]}
end
def ins = getter(direction: :in)
def outs = getter(direction: :out)
def input(i) = getter(index: i, direction: :in)
def output(i) = getter(index: i, direction: :out)
end
end

View File

@ -7,6 +7,7 @@ require_relative "button"
require_relative "vban" require_relative "vban"
require_relative "command" require_relative "command"
require_relative "recorder" require_relative "recorder"
require_relative "device"
require_relative "configs" require_relative "configs"
module Voicemeeter module Voicemeeter
@ -14,7 +15,7 @@ module Voicemeeter
private private
class Remote < Base class Remote < Base
attr_reader :strip, :bus, :button, :vban, :command, :recorder attr_reader :strip, :bus, :button, :vban, :command, :recorder, :device
def initialize(kind, **kwargs) def initialize(kind, **kwargs)
super super
@ -24,6 +25,7 @@ module Voicemeeter
@vban = Vban::Vban.new(self) @vban = Vban::Vban.new(self)
@command = Command.new(self) @command = Command.new(self)
@recorder = Recorder::Recorder.new(self) @recorder = Recorder::Recorder.new(self)
@device = Device.new(self)
end end
def configs def configs