Add Midi,Text In/Out Stream classes

define midi,text values for kind.vban in KindMaps
This commit is contained in:
onyx-and-iris 2023-08-03 12:56:16 +01:00
parent f32bfd5a4d
commit 33635e5f9b
2 changed files with 43 additions and 6 deletions

View File

@ -25,11 +25,11 @@ module Voicemeeter
def to_s = name.to_s.capitalize
end
basic = KindMap.new(:basic, [2, 1], [1, 1], [4, 4], [0, 0], 0, 80)
basic = KindMap.new(:basic, [2, 1], [1, 1], [4, 4, 1, 1], [0, 0], 0, 80)
banana = KindMap.new(:banana, [3, 2], [3, 2], [8, 8], [6, 8], 22, 80)
banana = KindMap.new(:banana, [3, 2], [3, 2], [8, 8, 1, 1], [6, 8], 22, 80)
potato = KindMap.new(:potato, [5, 3], [5, 3], [8, 8], [10, 8], 34, 80)
potato = KindMap.new(:potato, [5, 3], [5, 3], [8, 8, 1, 1], [10, 8], 34, 80)
KIND_MAPS = [basic, banana, potato].to_h { |kind| [kind.name, kind] }

View File

@ -36,6 +36,15 @@ module Voicemeeter
end
end
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
class VbanOutstream < VbanStream
# Represents a Vban OutStream
def initialize(remote, i)
@ -48,14 +57,42 @@ module Voicemeeter
end
end
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
VbanAudioInstream.new(remote, i)
elsif i < vban_out + midi
VbanMidiInstream.new(remote, i)
end
end
end
end
class Base
# Base class for Vban type
attr_reader :instream, :outstream
def initialize(remote)
vban_in, vban_out = remote.kind.vban
@instream = (0...vban_in).map { VbanInstream.new(remote, _1) }
@outstream = (0...vban_out).map { VbanOutstream.new(remote, _1) }
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) }
@remote = remote
end