2023-07-07 02:33:49 +01:00
|
|
|
module Voicemeeter
|
|
|
|
module Vban
|
2023-07-27 10:58:26 +01:00
|
|
|
class VbanStream
|
2023-07-29 22:14:36 +01:00
|
|
|
# Base class for Vban Stream types
|
2023-07-27 10:58:26 +01:00
|
|
|
include IRemote
|
|
|
|
|
2023-07-07 02:33:49 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_accessor_bool :on
|
|
|
|
make_accessor_string :name, :ip
|
|
|
|
make_accessor_int :quality, :route
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"vban.#{direction}stream[#{@index}]"
|
|
|
|
end
|
|
|
|
|
|
|
|
def direction
|
2023-07-27 11:15:04 +01:00
|
|
|
raise "Called abstract method: direction"
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class VbanInstream < VbanStream
|
2023-07-29 22:14:36 +01:00
|
|
|
# Represents a Vban InStream
|
2023-07-07 02:33:49 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_reader_int :sr, :channel, :bit
|
|
|
|
end
|
|
|
|
|
|
|
|
def direction
|
|
|
|
:in
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-03 12:56:16 +01:00
|
|
|
class VbanAudioInstream < VbanInstream; end
|
|
|
|
# Represents a Vban Audio InStream
|
|
|
|
|
|
|
|
class VbanMidiInstream < VbanInstream; end
|
|
|
|
# Represents a Vban Midi InStream
|
|
|
|
|
|
|
|
class VbanTextInstream < VbanInstream; end
|
|
|
|
# Represents a Vban Text InStream
|
|
|
|
|
2023-07-07 02:33:49 +01:00
|
|
|
class VbanOutstream < VbanStream
|
2023-07-29 22:14:36 +01:00
|
|
|
# Represents a Vban OutStream
|
2023-07-07 02:33:49 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_accessor_int :sr, :channel, :bit
|
|
|
|
end
|
|
|
|
|
|
|
|
def direction
|
|
|
|
:out
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-03 12:56:16 +01:00
|
|
|
class VbanAudioOutstream < VbanOutstream; end
|
|
|
|
# Represents a Vban Audio OutStream
|
|
|
|
|
|
|
|
class VbanMidiOutstream < VbanOutstream; end
|
|
|
|
# Represents a Vban Midi OutStream
|
|
|
|
|
|
|
|
class RequestVbanStream
|
|
|
|
def self.for(remote, i, dir)
|
|
|
|
vban_in, vban_out, midi, _ = remote.kind.vban
|
|
|
|
case dir
|
|
|
|
when :in
|
|
|
|
if i < vban_in
|
|
|
|
VbanAudioInstream.new(remote, i)
|
|
|
|
elsif i < vban_in + midi
|
|
|
|
VbanMidiInstream.new(remote, i)
|
|
|
|
else
|
|
|
|
VbanTextInstream.new(remote, i)
|
|
|
|
end
|
|
|
|
when :out
|
|
|
|
if i < vban_out
|
2023-08-09 17:44:08 +01:00
|
|
|
VbanAudioOutstream.new(remote, i)
|
2023-08-03 12:56:16 +01:00
|
|
|
elsif i < vban_out + midi
|
2023-08-09 17:44:08 +01:00
|
|
|
VbanMidiOutstream.new(remote, i)
|
2023-08-03 12:56:16 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class Base
|
|
|
|
# Base class for Vban type
|
2023-07-09 05:50:39 +01:00
|
|
|
attr_reader :instream, :outstream
|
2023-07-07 02:33:49 +01:00
|
|
|
|
|
|
|
def initialize(remote)
|
2023-08-03 12:56:16 +01:00
|
|
|
vban_in, vban_out, midi, text = remote.kind.vban
|
|
|
|
@instream = (0...vban_in + midi + text).map { RequestVbanStream.for(remote, _1, :in) }
|
|
|
|
@outstream = (0...vban_out + midi).map { RequestVbanStream.for(remote, _1, :out) }
|
2023-07-07 02:33:49 +01:00
|
|
|
|
|
|
|
@remote = remote
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
|
|
|
@remote.set("vban.enable", 1)
|
2023-07-09 05:50:39 +01:00
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
|
|
|
|
def disable
|
|
|
|
@remote.set("vban.enable", 0)
|
2023-07-09 05:50:39 +01:00
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|