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
|
|
|
|
class Bus < 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-14 01:46:00 +01:00
|
|
|
p_out = remote.kind.phys_out
|
2023-07-14 11:44:49 +01:00
|
|
|
(i < p_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
|
|
|
|
|
|
|
|
class PhysicalBus < Bus
|
|
|
|
end
|
|
|
|
|
|
|
|
class VirtualBus < Bus
|
|
|
|
end
|
2023-07-09 19:44:27 +01:00
|
|
|
|
|
|
|
class BusEq < IRemote
|
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
make_accessor_bool :on, :ab
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}].eq"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BusModes < IRemote
|
|
|
|
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
|
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|
2023-07-14 01:46:00 +01:00
|
|
|
|
|
|
|
class BusLevels < IRemote
|
|
|
|
def initialize(remote, i)
|
|
|
|
super
|
|
|
|
@init = i * 8
|
|
|
|
@offset = 8
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}]"
|
|
|
|
end
|
|
|
|
|
|
|
|
def getter(mode)
|
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-14 11:44:49 +01:00
|
|
|
vals.map { |x| (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
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
|
|
|
|
|
|
|
|
class BusDevice < IRemote
|
|
|
|
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
|