2023-07-07 02:33:49 +01:00
|
|
|
require_relative "iremote"
|
|
|
|
require_relative "kinds"
|
2023-07-09 19:44:27 +01:00
|
|
|
require_relative "mixins"
|
2023-07-07 02:33:49 +01:00
|
|
|
|
|
|
|
module Voicemeeter
|
|
|
|
module Bus
|
2023-07-27 10:58:26 +01:00
|
|
|
class Base
|
|
|
|
# Base class for Bus types
|
|
|
|
include IRemote
|
2023-07-09 19:44:27 +01:00
|
|
|
include Mixins::Fades
|
|
|
|
include Mixins::Return
|
|
|
|
|
2023-07-14 01:46:00 +01:00
|
|
|
attr_reader :eq, :mode, :levels
|
2023-07-09 19:44:27 +01:00
|
|
|
|
2023-07-07 02:33:49 +01:00
|
|
|
def self.make(remote, i)
|
2023-07-29 18:06:34 +01:00
|
|
|
(i < remote.kind.phys_out) ? PhysicalBus.new(remote, i) : VirtualBus.new(remote, i)
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|
2023-07-09 19:44:27 +01:00
|
|
|
|
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_accessor_bool :mute, :mono, :sel, :monitor
|
|
|
|
make_accessor_float :gain
|
|
|
|
make_accessor_string :label
|
|
|
|
|
|
|
|
@eq = BusEq.new(remote, i)
|
|
|
|
@mode = BusModes.new(remote, i)
|
2023-07-14 01:46:00 +01:00
|
|
|
@levels = BusLevels.new(remote, i)
|
2023-07-09 19:44:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}]"
|
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|
|
|
|
|
2023-08-01 23:41:23 +01:00
|
|
|
class PhysicalBus < Base; end
|
|
|
|
# Represents a Physical Bus
|
2023-07-07 02:33:49 +01:00
|
|
|
|
2023-08-01 23:41:23 +01:00
|
|
|
class VirtualBus < Base; end
|
|
|
|
# Represents a Virtual Bus
|
2023-07-09 19:44:27 +01:00
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class BusEq
|
|
|
|
include IRemote
|
|
|
|
|
2023-07-09 19:44:27 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_accessor_bool :on, :ab
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}].eq"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class BusModes
|
|
|
|
include IRemote
|
|
|
|
|
2023-07-09 19:44:27 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_accessor_bool :normal,
|
2023-07-14 11:44:49 +01:00
|
|
|
:amix,
|
|
|
|
:bmix,
|
|
|
|
:repeat,
|
|
|
|
:composite,
|
|
|
|
:tvmix,
|
|
|
|
:upmix21,
|
|
|
|
:upmix41,
|
|
|
|
:upmix61,
|
|
|
|
:centeronly,
|
|
|
|
:lfeonly,
|
|
|
|
:rearonly
|
2023-07-09 19:44:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}].mode"
|
|
|
|
end
|
2023-07-18 10:34:51 +01:00
|
|
|
|
|
|
|
def get
|
|
|
|
sleep(@remote.delay)
|
|
|
|
%i[amix bmix repeat composite tvmix upmix21 upmix41 upmix61 centeronly lfeonly rearonly].each do |mode|
|
|
|
|
if send(mode)
|
|
|
|
return mode
|
|
|
|
end
|
|
|
|
end
|
|
|
|
:normal
|
|
|
|
end
|
2023-07-09 19:44:27 +01:00
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|
2023-07-14 01:46:00 +01:00
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class BusLevels
|
|
|
|
include IRemote
|
|
|
|
|
2023-07-14 01:46:00 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
@init = i * 8
|
|
|
|
@offset = 8
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}]"
|
|
|
|
end
|
|
|
|
|
|
|
|
def getter(mode)
|
2023-07-25 10:20:31 +01:00
|
|
|
convert = ->(x) { (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
|
|
|
|
2023-07-14 11:44:49 +01:00
|
|
|
vals = if @remote.running && @remote.event.ldirty
|
|
|
|
@remote.cache[:bus_level][@init, @offset]
|
2023-07-14 01:46:00 +01:00
|
|
|
else
|
2023-07-14 11:44:49 +01:00
|
|
|
(@init...@init + @offset).map { |i| @remote.get_level(mode, i) }
|
2023-07-14 01:46:00 +01:00
|
|
|
end
|
2023-07-25 10:20:31 +01:00
|
|
|
vals.map(&convert)
|
2023-07-14 01:46:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
|
|
|
getter(Mixins::LevelEnum::BUS)
|
|
|
|
end
|
|
|
|
|
|
|
|
def isdirty? = @remote.cache[:bus_comp][@init, @offset].any?
|
|
|
|
end
|
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class BusDevice
|
|
|
|
include IRemote
|
|
|
|
|
2023-07-14 01:46:00 +01:00
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_reader_only :name, :sr
|
|
|
|
make_writer_only :wdm, :ks, :mme, :asio
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}].device"
|
|
|
|
end
|
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|