mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 01:40:49 +00:00
Mixin IRemote methods
added docstrings
This commit is contained in:
parent
ec43297b2d
commit
ce27f46a47
@ -10,6 +10,7 @@ require_relative "logger"
|
||||
|
||||
module Voicemeeter
|
||||
class Base
|
||||
# Base class for Remote types
|
||||
include Logging
|
||||
include Worker
|
||||
prepend Util::Cache
|
||||
|
@ -4,7 +4,9 @@ require_relative "mixins"
|
||||
|
||||
module Voicemeeter
|
||||
module Bus
|
||||
class Bus < IRemote
|
||||
class Base
|
||||
# Base class for Bus types
|
||||
include IRemote
|
||||
include Mixins::Fades
|
||||
include Mixins::Return
|
||||
|
||||
@ -31,13 +33,17 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class PhysicalBus < Bus
|
||||
class PhysicalBus < Base
|
||||
# Represents a Physical Bus
|
||||
end
|
||||
|
||||
class VirtualBus < Bus
|
||||
class VirtualBus < Base
|
||||
# Represents a Virtual Bus
|
||||
end
|
||||
|
||||
class BusEq < IRemote
|
||||
class BusEq
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_bool :on, :ab
|
||||
@ -48,7 +54,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class BusModes < IRemote
|
||||
class BusModes
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_bool :normal,
|
||||
@ -81,7 +89,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class BusLevels < IRemote
|
||||
class BusLevels
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
@init = i * 8
|
||||
@ -110,7 +120,9 @@ module Voicemeeter
|
||||
def isdirty? = @remote.cache[:bus_comp][@init, @offset].any?
|
||||
end
|
||||
|
||||
class BusDevice < IRemote
|
||||
class BusDevice
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_reader_only :name, :sr
|
||||
|
@ -23,7 +23,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class Button < IRemote
|
||||
class Base
|
||||
# Base class for Button types
|
||||
include IRemote
|
||||
include ButtonColorMixin
|
||||
|
||||
def getter(mode)
|
||||
|
@ -5,6 +5,8 @@ require_relative "logger"
|
||||
|
||||
module Voicemeeter
|
||||
module CBindings
|
||||
# Ruby bindings for the C-API functions
|
||||
|
||||
private
|
||||
|
||||
extend Logging
|
||||
|
@ -2,7 +2,9 @@ require_relative "iremote"
|
||||
require_relative "meta"
|
||||
|
||||
module Voicemeeter
|
||||
class Command < IRemote
|
||||
class Command
|
||||
include IRemote
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_action_method :show, :restart, :shutdown
|
||||
|
@ -1,7 +1,8 @@
|
||||
require_relative "iremote"
|
||||
|
||||
module Voicemeeter
|
||||
class Fx < IRemote
|
||||
class Fx
|
||||
include IRemote
|
||||
attr_reader :reverb, :delay
|
||||
|
||||
def initialize(remote)
|
||||
@ -15,7 +16,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class FxReverb < IRemote
|
||||
class FxReverb
|
||||
include IRemote
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_accessor_bool :on, :ab
|
||||
@ -26,7 +29,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class FxDelay < IRemote
|
||||
class FxDelay
|
||||
include IRemote
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_accessor_bool :on, :ab
|
||||
|
@ -5,7 +5,6 @@ require "ffi"
|
||||
module Voicemeeter
|
||||
private
|
||||
|
||||
# stree-ignore
|
||||
module Install
|
||||
OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32
|
||||
|
||||
|
@ -3,7 +3,9 @@ require_relative "meta"
|
||||
require_relative "logger"
|
||||
|
||||
module Voicemeeter
|
||||
class IRemote
|
||||
module IRemote
|
||||
# A commmon interface between the base Remote class and extended classes.
|
||||
|
||||
include Logging
|
||||
include MetaFunctions
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
module Voicemeeter
|
||||
module Kinds
|
||||
# KindMaps that describe the layout for each kind
|
||||
|
||||
private
|
||||
|
||||
KindMap =
|
||||
|
@ -2,7 +2,8 @@ require_relative "iremote"
|
||||
|
||||
module Voicemeeter
|
||||
module Option
|
||||
class Option < IRemote
|
||||
class Base
|
||||
include IRemote
|
||||
attr_reader :delay, :buffer, :mode
|
||||
|
||||
def initialize(remote)
|
||||
@ -20,7 +21,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class OptionDelay < IRemote
|
||||
class OptionDelay
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_bool :on, :ab
|
||||
@ -39,7 +42,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class OptionBuffer < IRemote
|
||||
class OptionBuffer
|
||||
include IRemote
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_accessor_int :mme, :wdm, :ks, :asio
|
||||
@ -50,7 +55,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class OptionMode < IRemote
|
||||
class OptionMode
|
||||
include IRemote
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_accessor_bool :exclusif, :swift
|
||||
|
@ -2,7 +2,9 @@ require_relative "iremote"
|
||||
|
||||
module Voicemeeter
|
||||
module Patch
|
||||
class Patch < IRemote
|
||||
class Base
|
||||
# Base class for Patch types
|
||||
include IRemote
|
||||
attr_reader :asio, :A2, :A3, :A4, :A5, :composite, :insert
|
||||
|
||||
def initialize(remote)
|
||||
@ -19,7 +21,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class PatchAsio < IRemote
|
||||
class PatchAsio
|
||||
include IRemote
|
||||
|
||||
def identifier
|
||||
:patch
|
||||
end
|
||||
@ -50,7 +54,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class PatchComposite < IRemote
|
||||
class PatchComposite
|
||||
include IRemote
|
||||
|
||||
def get
|
||||
getter("composite[#{@index}]").to_i
|
||||
end
|
||||
@ -60,7 +66,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class PatchInsert < IRemote
|
||||
class PatchInsert
|
||||
include IRemote
|
||||
|
||||
def get
|
||||
getter("insert[#{@index}]").to_i == 1
|
||||
end
|
||||
|
@ -14,7 +14,9 @@ module Voicemeeter
|
||||
MP3 = 100
|
||||
end
|
||||
|
||||
class Recorder < IRemote
|
||||
class Base
|
||||
# Base class for Recorder types
|
||||
include IRemote
|
||||
include Mixins::Outputs
|
||||
|
||||
attr_reader :mode, :armstrip, :armbus
|
||||
@ -54,7 +56,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class RecorderMode < IRemote
|
||||
class RecorderMode
|
||||
include IRemote
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_accessor_bool :recbus, :playonload, :loop, :multitrack
|
||||
@ -65,7 +69,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class RecorderArmChannel < IRemote
|
||||
class RecorderArmChannel
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, j)
|
||||
super(remote)
|
||||
@j = j
|
||||
|
@ -15,20 +15,24 @@ require_relative "configs"
|
||||
|
||||
module Voicemeeter
|
||||
module Builder
|
||||
# Builder module for Remote factories.
|
||||
# Defines steps for building a Remote type of a kind.
|
||||
# Defines the base director
|
||||
|
||||
private
|
||||
|
||||
def steps(step)
|
||||
case step
|
||||
when :strip then -> { (0...kind.num_strip).map { Strip::Strip.make(self, _1) } }
|
||||
when :bus then -> { (0...kind.num_bus).map { Bus::Bus.make(self, _1) } }
|
||||
when :button then -> { (0...kind.num_buttons).map { Button::Button.new(self, _1) } }
|
||||
when :vban then -> { Vban::Vban.new(self) }
|
||||
when :strip then -> { (0...kind.num_strip).map { Strip::Base.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::Base.new(self, _1) } }
|
||||
when :vban then -> { Vban::Base.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 :fx then -> { Fx.new(self) }
|
||||
when :patch then -> { Patch::Patch.new(self) }
|
||||
when :option then -> { Option::Option.new(self) }
|
||||
when :patch then -> { Patch::Base.new(self) }
|
||||
when :option then -> { Option::Base.new(self) }
|
||||
end
|
||||
end
|
||||
|
||||
@ -39,6 +43,7 @@ module Voicemeeter
|
||||
|
||||
module Remote
|
||||
class Remote < Base
|
||||
# Concrete class for Remote types
|
||||
include Builder
|
||||
|
||||
public attr_reader :strip, :bus, :button, :vban, :command, :device, :option
|
||||
@ -66,9 +71,11 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
class RemoteBasic < Remote
|
||||
# Concrete class for RemoteBasic types
|
||||
end
|
||||
|
||||
class RemoteBanana < Remote
|
||||
# Concrete class for RemoteBanana types
|
||||
public attr_reader :recorder, :patch
|
||||
|
||||
private def director
|
||||
@ -77,6 +84,7 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
class RemotePotato < Remote
|
||||
# Concrete class for RemotePotato types
|
||||
public attr_reader :recorder, :patch, :fx
|
||||
|
||||
private def director
|
||||
@ -85,6 +93,7 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
class RequestRemote
|
||||
# Factory class for Remote types. Returns a Remote class for a kind.
|
||||
def self.for(kind, **)
|
||||
case kind.name
|
||||
when :basic
|
||||
@ -100,6 +109,7 @@ module Voicemeeter
|
||||
public
|
||||
|
||||
def self.new(kind_id, **)
|
||||
# Interface entry point. Wraps factory class and handles kind errors.
|
||||
kind = Kinds.get(kind_id)
|
||||
rescue KeyError
|
||||
raise Errors::VMError.new "unknown Voicemeeter kind #{kind_id}"
|
||||
|
@ -4,7 +4,9 @@ require_relative "mixins"
|
||||
|
||||
module Voicemeeter
|
||||
module Strip
|
||||
class Strip < IRemote
|
||||
class Base
|
||||
# Base class for Strip types
|
||||
include IRemote
|
||||
include Mixins::Outputs
|
||||
include Mixins::Fades
|
||||
|
||||
@ -31,7 +33,8 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class PhysicalStrip < Strip
|
||||
class PhysicalStrip < Base
|
||||
# Represents a Physical Strip
|
||||
include Mixins::Xy::Pan
|
||||
include Mixins::Xy::Color
|
||||
include Mixins::Xy::Fx
|
||||
@ -51,7 +54,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class StripComp < IRemote
|
||||
class StripComp
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_float :gainin,
|
||||
@ -77,7 +82,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class StripGate < IRemote
|
||||
class StripGate
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_float :threshold, :damping, :attack, :hold, :release
|
||||
@ -97,7 +104,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class StripDenoiser < IRemote
|
||||
class StripDenoiser
|
||||
include IRemote
|
||||
|
||||
def identifier
|
||||
"strip[#{@index}].denoiser"
|
||||
end
|
||||
@ -111,7 +120,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class StripEq < IRemote
|
||||
class StripEq
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_bool :on, :ab
|
||||
@ -122,7 +133,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class StripDevice < IRemote
|
||||
class StripDevice
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_reader_int :sr
|
||||
@ -135,7 +148,8 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class VirtualStrip < Strip
|
||||
class VirtualStrip < Base
|
||||
# Represents a Virtual Strip
|
||||
include Mixins::Xy::Pan
|
||||
include Mixins::Apps
|
||||
|
||||
@ -175,7 +189,9 @@ module Voicemeeter
|
||||
alias_method :high=, :treble=
|
||||
end
|
||||
|
||||
class GainLayer < IRemote
|
||||
class GainLayer
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i, j)
|
||||
super(remote, i)
|
||||
@j = j
|
||||
@ -194,7 +210,9 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class StripLevels < IRemote
|
||||
class StripLevels
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
p_in = remote.kind.phys_in
|
||||
|
@ -1,8 +1,8 @@
|
||||
module Voicemeeter
|
||||
module Util
|
||||
module String
|
||||
def snakecase(string)
|
||||
string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
||||
def snakecase(s)
|
||||
s.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
||||
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
||||
.tr("-", "_")
|
||||
.gsub(/\s/, "_")
|
||||
@ -10,15 +10,17 @@ module Voicemeeter
|
||||
.downcase
|
||||
end
|
||||
|
||||
def camelcase(string)
|
||||
string if string !~ /_/ && string =~ /[A-Z]+.*/
|
||||
string.split("_").map { |e| e.capitalize }.join
|
||||
def camelcase(s)
|
||||
s if s !~ /_/ && s =~ /[A-Z]+.*/
|
||||
s.split("_").map { |e| e.capitalize }.join
|
||||
end
|
||||
|
||||
module_function :snakecase, :camelcase
|
||||
end
|
||||
|
||||
module Cache
|
||||
# Prepended methods, provides wrap-like functionality
|
||||
|
||||
def get(name, is_string = false)
|
||||
return cache.delete(name) if cache.key? name
|
||||
clear_dirty if @sync
|
||||
|
@ -4,7 +4,9 @@ require_relative "errors"
|
||||
|
||||
module Voicemeeter
|
||||
module Vban
|
||||
class VbanStream < IRemote
|
||||
class VbanStream
|
||||
include IRemote
|
||||
|
||||
def initialize(remote, i)
|
||||
super
|
||||
make_accessor_bool :on
|
||||
@ -43,7 +45,8 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
class Vban
|
||||
class Base
|
||||
# Base class for Vban type
|
||||
attr_reader :instream, :outstream
|
||||
|
||||
def initialize(remote)
|
||||
@ -54,12 +57,10 @@ module Voicemeeter
|
||||
@remote = remote
|
||||
end
|
||||
|
||||
# stree-ignore
|
||||
def enable
|
||||
@remote.set("vban.enable", 1)
|
||||
end
|
||||
|
||||
# stree-ignore
|
||||
def disable
|
||||
@remote.set("vban.enable", 0)
|
||||
end
|
||||
|
@ -2,6 +2,8 @@ require_relative "logger"
|
||||
|
||||
module Voicemeeter
|
||||
module Worker
|
||||
# Event threads, provides updates to observers
|
||||
|
||||
include Logging
|
||||
|
||||
def init_producer(que)
|
||||
|
Loading…
Reference in New Issue
Block a user