Mixin IRemote methods

added docstrings
This commit is contained in:
onyx-and-iris 2023-07-27 10:58:26 +01:00
parent ec43297b2d
commit ce27f46a47
17 changed files with 132 additions and 51 deletions

View File

@ -10,6 +10,7 @@ require_relative "logger"
module Voicemeeter module Voicemeeter
class Base class Base
# Base class for Remote types
include Logging include Logging
include Worker include Worker
prepend Util::Cache prepend Util::Cache

View File

@ -4,7 +4,9 @@ require_relative "mixins"
module Voicemeeter module Voicemeeter
module Bus module Bus
class Bus < IRemote class Base
# Base class for Bus types
include IRemote
include Mixins::Fades include Mixins::Fades
include Mixins::Return include Mixins::Return
@ -31,13 +33,17 @@ module Voicemeeter
end end
end end
class PhysicalBus < Bus class PhysicalBus < Base
# Represents a Physical Bus
end end
class VirtualBus < Bus class VirtualBus < Base
# Represents a Virtual Bus
end end
class BusEq < IRemote class BusEq
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_bool :on, :ab make_accessor_bool :on, :ab
@ -48,7 +54,9 @@ module Voicemeeter
end end
end end
class BusModes < IRemote class BusModes
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_bool :normal, make_accessor_bool :normal,
@ -81,7 +89,9 @@ module Voicemeeter
end end
end end
class BusLevels < IRemote class BusLevels
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
@init = i * 8 @init = i * 8
@ -110,7 +120,9 @@ module Voicemeeter
def isdirty? = @remote.cache[:bus_comp][@init, @offset].any? def isdirty? = @remote.cache[:bus_comp][@init, @offset].any?
end end
class BusDevice < IRemote class BusDevice
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_reader_only :name, :sr make_reader_only :name, :sr

View File

@ -23,7 +23,9 @@ module Voicemeeter
end end
end end
class Button < IRemote class Base
# Base class for Button types
include IRemote
include ButtonColorMixin include ButtonColorMixin
def getter(mode) def getter(mode)

View File

@ -5,6 +5,8 @@ require_relative "logger"
module Voicemeeter module Voicemeeter
module CBindings module CBindings
# Ruby bindings for the C-API functions
private private
extend Logging extend Logging

View File

@ -2,7 +2,9 @@ require_relative "iremote"
require_relative "meta" require_relative "meta"
module Voicemeeter module Voicemeeter
class Command < IRemote class Command
include IRemote
def initialize(remote) def initialize(remote)
super super
make_action_method :show, :restart, :shutdown make_action_method :show, :restart, :shutdown

View File

@ -1,7 +1,8 @@
require_relative "iremote" require_relative "iremote"
module Voicemeeter module Voicemeeter
class Fx < IRemote class Fx
include IRemote
attr_reader :reverb, :delay attr_reader :reverb, :delay
def initialize(remote) def initialize(remote)
@ -15,7 +16,9 @@ module Voicemeeter
end end
end end
class FxReverb < IRemote class FxReverb
include IRemote
def initialize(remote) def initialize(remote)
super super
make_accessor_bool :on, :ab make_accessor_bool :on, :ab
@ -26,7 +29,9 @@ module Voicemeeter
end end
end end
class FxDelay < IRemote class FxDelay
include IRemote
def initialize(remote) def initialize(remote)
super super
make_accessor_bool :on, :ab make_accessor_bool :on, :ab

View File

@ -5,7 +5,6 @@ require "ffi"
module Voicemeeter module Voicemeeter
private private
# stree-ignore
module Install module Install
OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32 OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32

View File

@ -3,7 +3,9 @@ require_relative "meta"
require_relative "logger" require_relative "logger"
module Voicemeeter module Voicemeeter
class IRemote module IRemote
# A commmon interface between the base Remote class and extended classes.
include Logging include Logging
include MetaFunctions include MetaFunctions

View File

@ -1,5 +1,7 @@
module Voicemeeter module Voicemeeter
module Kinds module Kinds
# KindMaps that describe the layout for each kind
private private
KindMap = KindMap =

View File

@ -2,7 +2,8 @@ require_relative "iremote"
module Voicemeeter module Voicemeeter
module Option module Option
class Option < IRemote class Base
include IRemote
attr_reader :delay, :buffer, :mode attr_reader :delay, :buffer, :mode
def initialize(remote) def initialize(remote)
@ -20,7 +21,9 @@ module Voicemeeter
end end
end end
class OptionDelay < IRemote class OptionDelay
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_bool :on, :ab make_accessor_bool :on, :ab
@ -39,7 +42,9 @@ module Voicemeeter
end end
end end
class OptionBuffer < IRemote class OptionBuffer
include IRemote
def initialize(remote) def initialize(remote)
super super
make_accessor_int :mme, :wdm, :ks, :asio make_accessor_int :mme, :wdm, :ks, :asio
@ -50,7 +55,9 @@ module Voicemeeter
end end
end end
class OptionMode < IRemote class OptionMode
include IRemote
def initialize(remote) def initialize(remote)
super super
make_accessor_bool :exclusif, :swift make_accessor_bool :exclusif, :swift

View File

@ -2,7 +2,9 @@ require_relative "iremote"
module Voicemeeter module Voicemeeter
module Patch module Patch
class Patch < IRemote class Base
# Base class for Patch types
include IRemote
attr_reader :asio, :A2, :A3, :A4, :A5, :composite, :insert attr_reader :asio, :A2, :A3, :A4, :A5, :composite, :insert
def initialize(remote) def initialize(remote)
@ -19,7 +21,9 @@ module Voicemeeter
end end
end end
class PatchAsio < IRemote class PatchAsio
include IRemote
def identifier def identifier
:patch :patch
end end
@ -50,7 +54,9 @@ module Voicemeeter
end end
end end
class PatchComposite < IRemote class PatchComposite
include IRemote
def get def get
getter("composite[#{@index}]").to_i getter("composite[#{@index}]").to_i
end end
@ -60,7 +66,9 @@ module Voicemeeter
end end
end end
class PatchInsert < IRemote class PatchInsert
include IRemote
def get def get
getter("insert[#{@index}]").to_i == 1 getter("insert[#{@index}]").to_i == 1
end end

View File

@ -14,7 +14,9 @@ module Voicemeeter
MP3 = 100 MP3 = 100
end end
class Recorder < IRemote class Base
# Base class for Recorder types
include IRemote
include Mixins::Outputs include Mixins::Outputs
attr_reader :mode, :armstrip, :armbus attr_reader :mode, :armstrip, :armbus
@ -54,7 +56,9 @@ module Voicemeeter
end end
end end
class RecorderMode < IRemote class RecorderMode
include IRemote
def initialize(remote) def initialize(remote)
super super
make_accessor_bool :recbus, :playonload, :loop, :multitrack make_accessor_bool :recbus, :playonload, :loop, :multitrack
@ -65,7 +69,9 @@ module Voicemeeter
end end
end end
class RecorderArmChannel < IRemote class RecorderArmChannel
include IRemote
def initialize(remote, j) def initialize(remote, j)
super(remote) super(remote)
@j = j @j = j

View File

@ -15,20 +15,24 @@ require_relative "configs"
module Voicemeeter module Voicemeeter
module Builder module Builder
# Builder module for Remote factories.
# Defines steps for building a Remote type of a kind.
# Defines the base director
private private
def steps(step) def steps(step)
case step case step
when :strip then -> { (0...kind.num_strip).map { Strip::Strip.make(self, _1) } } when :strip then -> { (0...kind.num_strip).map { Strip::Base.make(self, _1) } }
when :bus then -> { (0...kind.num_bus).map { Bus::Bus.make(self, _1) } } when :bus then -> { (0...kind.num_bus).map { Bus::Base.make(self, _1) } }
when :button then -> { (0...kind.num_buttons).map { Button::Button.new(self, _1) } } when :button then -> { (0...kind.num_buttons).map { Button::Base.new(self, _1) } }
when :vban then -> { Vban::Vban.new(self) } when :vban then -> { Vban::Base.new(self) }
when :command then -> { Command.new(self) } when :command then -> { Command.new(self) }
when :recorder then -> { Recorder::Recorder.new(self) } when :recorder then -> { Recorder::Base.new(self) }
when :device then -> { Device.new(self) } when :device then -> { Device.new(self) }
when :fx then -> { Fx.new(self) } when :fx then -> { Fx.new(self) }
when :patch then -> { Patch::Patch.new(self) } when :patch then -> { Patch::Base.new(self) }
when :option then -> { Option::Option.new(self) } when :option then -> { Option::Base.new(self) }
end end
end end
@ -39,6 +43,7 @@ module Voicemeeter
module Remote module Remote
class Remote < Base class Remote < Base
# Concrete class for Remote types
include Builder include Builder
public attr_reader :strip, :bus, :button, :vban, :command, :device, :option public attr_reader :strip, :bus, :button, :vban, :command, :device, :option
@ -66,9 +71,11 @@ module Voicemeeter
end end
class RemoteBasic < Remote class RemoteBasic < Remote
# Concrete class for RemoteBasic types
end end
class RemoteBanana < Remote class RemoteBanana < Remote
# Concrete class for RemoteBanana types
public attr_reader :recorder, :patch public attr_reader :recorder, :patch
private def director private def director
@ -77,6 +84,7 @@ module Voicemeeter
end end
class RemotePotato < Remote class RemotePotato < Remote
# Concrete class for RemotePotato types
public attr_reader :recorder, :patch, :fx public attr_reader :recorder, :patch, :fx
private def director private def director
@ -85,6 +93,7 @@ module Voicemeeter
end end
class RequestRemote class RequestRemote
# Factory class for Remote types. Returns a Remote class for a kind.
def self.for(kind, **) def self.for(kind, **)
case kind.name case kind.name
when :basic when :basic
@ -100,6 +109,7 @@ module Voicemeeter
public public
def self.new(kind_id, **) def self.new(kind_id, **)
# Interface entry point. Wraps factory class and handles kind errors.
kind = Kinds.get(kind_id) kind = Kinds.get(kind_id)
rescue KeyError rescue KeyError
raise Errors::VMError.new "unknown Voicemeeter kind #{kind_id}" raise Errors::VMError.new "unknown Voicemeeter kind #{kind_id}"

View File

@ -4,7 +4,9 @@ require_relative "mixins"
module Voicemeeter module Voicemeeter
module Strip module Strip
class Strip < IRemote class Base
# Base class for Strip types
include IRemote
include Mixins::Outputs include Mixins::Outputs
include Mixins::Fades include Mixins::Fades
@ -31,7 +33,8 @@ module Voicemeeter
end end
end end
class PhysicalStrip < Strip class PhysicalStrip < Base
# Represents a Physical Strip
include Mixins::Xy::Pan include Mixins::Xy::Pan
include Mixins::Xy::Color include Mixins::Xy::Color
include Mixins::Xy::Fx include Mixins::Xy::Fx
@ -51,7 +54,9 @@ module Voicemeeter
end end
end end
class StripComp < IRemote class StripComp
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_float :gainin, make_accessor_float :gainin,
@ -77,7 +82,9 @@ module Voicemeeter
end end
end end
class StripGate < IRemote class StripGate
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_float :threshold, :damping, :attack, :hold, :release make_accessor_float :threshold, :damping, :attack, :hold, :release
@ -97,7 +104,9 @@ module Voicemeeter
end end
end end
class StripDenoiser < IRemote class StripDenoiser
include IRemote
def identifier def identifier
"strip[#{@index}].denoiser" "strip[#{@index}].denoiser"
end end
@ -111,7 +120,9 @@ module Voicemeeter
end end
end end
class StripEq < IRemote class StripEq
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_bool :on, :ab make_accessor_bool :on, :ab
@ -122,7 +133,9 @@ module Voicemeeter
end end
end end
class StripDevice < IRemote class StripDevice
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_reader_int :sr make_reader_int :sr
@ -135,7 +148,8 @@ module Voicemeeter
end end
end end
class VirtualStrip < Strip class VirtualStrip < Base
# Represents a Virtual Strip
include Mixins::Xy::Pan include Mixins::Xy::Pan
include Mixins::Apps include Mixins::Apps
@ -175,7 +189,9 @@ module Voicemeeter
alias_method :high=, :treble= alias_method :high=, :treble=
end end
class GainLayer < IRemote class GainLayer
include IRemote
def initialize(remote, i, j) def initialize(remote, i, j)
super(remote, i) super(remote, i)
@j = j @j = j
@ -194,7 +210,9 @@ module Voicemeeter
end end
end end
class StripLevels < IRemote class StripLevels
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
p_in = remote.kind.phys_in p_in = remote.kind.phys_in

View File

@ -1,8 +1,8 @@
module Voicemeeter module Voicemeeter
module Util module Util
module String module String
def snakecase(string) def snakecase(s)
string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') s.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr("-", "_") .tr("-", "_")
.gsub(/\s/, "_") .gsub(/\s/, "_")
@ -10,15 +10,17 @@ module Voicemeeter
.downcase .downcase
end end
def camelcase(string) def camelcase(s)
string if string !~ /_/ && string =~ /[A-Z]+.*/ s if s !~ /_/ && s =~ /[A-Z]+.*/
string.split("_").map { |e| e.capitalize }.join s.split("_").map { |e| e.capitalize }.join
end end
module_function :snakecase, :camelcase module_function :snakecase, :camelcase
end end
module Cache module Cache
# Prepended methods, provides wrap-like functionality
def get(name, is_string = false) def get(name, is_string = false)
return cache.delete(name) if cache.key? name return cache.delete(name) if cache.key? name
clear_dirty if @sync clear_dirty if @sync

View File

@ -4,7 +4,9 @@ require_relative "errors"
module Voicemeeter module Voicemeeter
module Vban module Vban
class VbanStream < IRemote class VbanStream
include IRemote
def initialize(remote, i) def initialize(remote, i)
super super
make_accessor_bool :on make_accessor_bool :on
@ -43,7 +45,8 @@ module Voicemeeter
end end
end end
class Vban class Base
# Base class for Vban type
attr_reader :instream, :outstream attr_reader :instream, :outstream
def initialize(remote) def initialize(remote)
@ -54,12 +57,10 @@ module Voicemeeter
@remote = remote @remote = remote
end end
# stree-ignore
def enable def enable
@remote.set("vban.enable", 1) @remote.set("vban.enable", 1)
end end
# stree-ignore
def disable def disable
@remote.set("vban.enable", 0) @remote.set("vban.enable", 0)
end end

View File

@ -2,6 +2,8 @@ require_relative "logger"
module Voicemeeter module Voicemeeter
module Worker module Worker
# Event threads, provides updates to observers
include Logging include Logging
def init_producer(que) def init_producer(que)