2023-07-07 02:33:49 +01:00
|
|
|
module Voicemeeter
|
|
|
|
module Bus
|
2023-08-29 14:07:52 +01:00
|
|
|
# Base class for Bus
|
2023-07-27 10:58:26 +01:00
|
|
|
class Base
|
|
|
|
include IRemote
|
2023-07-09 19:44:27 +01:00
|
|
|
include Mixins::Fades
|
|
|
|
include Mixins::Return
|
2023-08-30 12:27:50 +01:00
|
|
|
extend MetaFunctions
|
2023-07-09 19:44:27 +01:00
|
|
|
|
2023-07-14 01:46:00 +01:00
|
|
|
attr_reader :eq, :mode, :levels
|
2023-08-30 12:27:50 +01:00
|
|
|
attr_accessor_bool :mute, :mono, :sel, :monitor
|
|
|
|
attr_accessor_float :gain
|
|
|
|
attr_accessor_string :label
|
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
|
|
|
|
@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
|
|
|
# Represents a Physical Bus
|
2023-08-29 11:21:05 +01:00
|
|
|
class PhysicalBus < Base; end
|
2023-07-07 02:33:49 +01:00
|
|
|
|
2023-08-01 23:41:23 +01:00
|
|
|
# Represents a Virtual Bus
|
2023-08-29 11:21:05 +01:00
|
|
|
class VirtualBus < Base; end
|
2023-07-09 19:44:27 +01:00
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class BusEq
|
|
|
|
include IRemote
|
2023-08-30 12:27:50 +01:00
|
|
|
extend MetaFunctions
|
2023-07-27 10:58:26 +01:00
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
attr_accessor_bool :on, :ab
|
2023-07-09 19:44:27 +01:00
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}].eq"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
class BusModes
|
|
|
|
include IRemote
|
2023-08-30 12:27:50 +01:00
|
|
|
extend MetaFunctions
|
2023-07-27 10:58:26 +01:00
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
attr_accessor_bool :normal,
|
|
|
|
:amix,
|
|
|
|
:bmix,
|
|
|
|
:repeat,
|
|
|
|
:composite,
|
|
|
|
:tvmix,
|
|
|
|
:upmix21,
|
|
|
|
:upmix41,
|
|
|
|
:upmix61,
|
|
|
|
:centeronly,
|
|
|
|
:lfeonly,
|
|
|
|
:rearonly
|
2023-07-09 19:44:27 +01:00
|
|
|
|
|
|
|
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-08-10 14:40:22 +01:00
|
|
|
vals = if @remote.running? && @remote.event.ldirty
|
2023-07-14 11:44:49 +01:00
|
|
|
@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-08-30 12:45:55 +01:00
|
|
|
extend MetaFunctions
|
2023-07-27 10:58:26 +01:00
|
|
|
|
2023-08-30 12:45:55 +01:00
|
|
|
attr_reader_int :sr
|
|
|
|
attr_reader_string :name
|
|
|
|
attr_writer_string :wdm, :ks, :mme, :asio
|
2023-07-14 01:46:00 +01:00
|
|
|
|
|
|
|
def identifier
|
|
|
|
"bus[#{@index}].device"
|
|
|
|
end
|
|
|
|
end
|
2023-07-07 02:33:49 +01:00
|
|
|
end
|