mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-15 23:00:48 +00:00
run through standard
This commit is contained in:
parent
d2160535a3
commit
6ccdfafc27
@ -8,17 +8,21 @@ module Voicemeeter
|
|||||||
|
|
||||||
extend FFI::Library
|
extend FFI::Library
|
||||||
|
|
||||||
VM_PATH = Install.get_vmpath()
|
VM_PATH = Install.get_vmpath
|
||||||
|
|
||||||
ffi_lib VM_PATH.join(
|
ffi_lib VM_PATH.join(
|
||||||
"VoicemeeterRemote#{Install::OS_BITS == 64 ? "64" : "32"}.dll"
|
"VoicemeeterRemote#{(Install::OS_BITS == 64) ? "64" : "32"}.dll"
|
||||||
)
|
)
|
||||||
ffi_convention :stdcall
|
ffi_convention :stdcall
|
||||||
|
|
||||||
|
class << self
|
||||||
|
private
|
||||||
|
|
||||||
def self.attach_function(c_name, args, returns)
|
def self.attach_function(c_name, args, returns)
|
||||||
ruby_name = "bind_#{c_name.to_s.delete_prefix("VBVMR_").snakecase}".to_sym
|
ruby_name = "bind_#{c_name.to_s.delete_prefix("VBVMR_").snakecase}".to_sym
|
||||||
super(ruby_name, c_name, args, returns)
|
super(ruby_name, c_name, args, returns)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
attach_function :VBVMR_Login, [], :long
|
attach_function :VBVMR_Login, [], :long
|
||||||
attach_function :VBVMR_Logout, [], :long
|
attach_function :VBVMR_Logout, [], :long
|
||||||
|
@ -15,7 +15,7 @@ module Voicemeeter
|
|||||||
|
|
||||||
def initialize(kind)
|
def initialize(kind)
|
||||||
@kind = kind
|
@kind = kind
|
||||||
@configs = Hash.new
|
@configs = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
@ -7,17 +7,17 @@ module Voicemeeter
|
|||||||
|
|
||||||
# stree-ignore
|
# stree-ignore
|
||||||
module Install
|
module Install
|
||||||
OS_BITS = FFI::Platform::CPU.downcase == "x64" ? 64 : 32
|
OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32
|
||||||
|
|
||||||
def get_vmpath()
|
def get_vmpath
|
||||||
reg_key = [
|
reg_key = [
|
||||||
:Software,
|
:Software,
|
||||||
(OS_BITS == 64 ? :WOW6432Node : nil),
|
((OS_BITS == 64) ? :WOW6432Node : nil),
|
||||||
:Microsoft,
|
:Microsoft,
|
||||||
:Windows,
|
:Windows,
|
||||||
:CurrentVersion,
|
:CurrentVersion,
|
||||||
:Uninstall,
|
:Uninstall,
|
||||||
:'VB:Voicemeeter {17359A74-1236-5467}'
|
:"VB:Voicemeeter {17359A74-1236-5467}"
|
||||||
]
|
]
|
||||||
|
|
||||||
Win32::Registry::HKEY_LOCAL_MACHINE.open(
|
Win32::Registry::HKEY_LOCAL_MACHINE.open(
|
||||||
|
@ -4,11 +4,8 @@ require "easy_logging"
|
|||||||
|
|
||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
class IRemote
|
class IRemote
|
||||||
"
|
|
||||||
Common interface between base class and higher classes.
|
|
||||||
"
|
|
||||||
include EasyLogging
|
include EasyLogging
|
||||||
include Meta_Functions
|
include MetaFunctions
|
||||||
|
|
||||||
def initialize(remote, i = nil)
|
def initialize(remote, i = nil)
|
||||||
@remote = remote
|
@remote = remote
|
||||||
@ -40,20 +37,14 @@ module Voicemeeter
|
|||||||
def apply(params)
|
def apply(params)
|
||||||
params.each do |key, val|
|
params.each do |key, val|
|
||||||
if val.is_a? Hash
|
if val.is_a? Hash
|
||||||
target = self.send(key)
|
target = send(key)
|
||||||
target.apply(val)
|
target.apply(val)
|
||||||
|
elsif key == :mode
|
||||||
|
mode.send("#{val}=", true)
|
||||||
else
|
else
|
||||||
if key == :mode
|
send("#{key}=", val)
|
||||||
self.mode.send("#{val}=", true)
|
|
||||||
else
|
|
||||||
self.send("#{key}=", val)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(method, *args)
|
|
||||||
logger.debug "Unknown method #{method} for #{self}."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -5,14 +5,22 @@ module Voicemeeter
|
|||||||
KindMap =
|
KindMap =
|
||||||
Data.define(:name, :ins, :outs, :vban, :asio, :insert, :num_buttons) do
|
Data.define(:name, :ins, :outs, :vban, :asio, :insert, :num_buttons) do
|
||||||
def phys_in = ins[0]
|
def phys_in = ins[0]
|
||||||
|
|
||||||
def virt_in = ins[1]
|
def virt_in = ins[1]
|
||||||
|
|
||||||
def phys_out = outs[0]
|
def phys_out = outs[0]
|
||||||
|
|
||||||
def virt_out = outs[1]
|
def virt_out = outs[1]
|
||||||
|
|
||||||
def num_strip = ins.sum
|
def num_strip = ins.sum
|
||||||
|
|
||||||
def num_bus = outs.sum
|
def num_bus = outs.sum
|
||||||
|
|
||||||
def num_strip_levels = 2 * phys_in + 8 * virt_in
|
def num_strip_levels = 2 * phys_in + 8 * virt_in
|
||||||
|
|
||||||
def num_bus_levels = 8 * (phys_out + virt_out)
|
def num_bus_levels = 8 * (phys_out + virt_out)
|
||||||
def to_s = "#{name}".capitalize
|
|
||||||
|
def to_s = name.to_s.capitalize
|
||||||
end
|
end
|
||||||
|
|
||||||
basic = KindMap.new(:basic, [2, 1], [1, 1], [4, 4], [0, 0], 0, 80)
|
basic = KindMap.new(:basic, [2, 1], [1, 1], [4, 4], [0, 0], 0, 80)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
module Meta_Functions
|
module MetaFunctions
|
||||||
# Accessor methods
|
# Accessor methods
|
||||||
def make_accessor_bool(*params)
|
def make_accessor_bool(*params)
|
||||||
params.each do |param|
|
params.each do |param|
|
||||||
|
@ -3,7 +3,7 @@ module Voicemeeter
|
|||||||
attr_accessor :cache, :current, :channel
|
attr_accessor :cache, :current, :channel
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@cache = Hash.new
|
@cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(key)
|
def get(key)
|
||||||
|
@ -2,12 +2,12 @@ module Voicemeeter
|
|||||||
module Mixins
|
module Mixins
|
||||||
module Fades
|
module Fades
|
||||||
def fadeto(target, time)
|
def fadeto(target, time)
|
||||||
self.setter("FadeTo", "(#{target}, #{time})")
|
setter("FadeTo", "(#{target}, #{time})")
|
||||||
sleep(@remote.delay)
|
sleep(@remote.delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fadeby(change, time)
|
def fadeby(change, time)
|
||||||
self.setter("FadeBy", "(#{change}, #{time})")
|
setter("FadeBy", "(#{change}, #{time})")
|
||||||
sleep(@remote.delay)
|
sleep(@remote.delay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -21,11 +21,11 @@ module Voicemeeter
|
|||||||
|
|
||||||
module Apps
|
module Apps
|
||||||
def appgain(name, gain)
|
def appgain(name, gain)
|
||||||
self.setter("AppGain", "(\"#{name}\", #{gain})")
|
setter("AppGain", "(\"#{name}\", #{gain})")
|
||||||
end
|
end
|
||||||
|
|
||||||
def appmute(name, mute)
|
def appmute(name, mute)
|
||||||
self.setter("AppMute", "(\"#{name}\", #{mute ? 1 : 0})")
|
setter("AppMute", "(\"#{name}\", #{mute ? 1 : 0})")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -33,12 +33,12 @@ module Voicemeeter
|
|||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
super
|
super
|
||||||
remote, *rem = args
|
remote, *rem = args
|
||||||
num_A, num_B = remote.kind.outs
|
num_a, num_b = remote.kind.outs
|
||||||
channels =
|
channels =
|
||||||
(1..(num_A + num_B)).map do |i|
|
(1..(num_a + num_b)).map do |i|
|
||||||
i <= num_A ? "A#{i}" : "B#{i - num_A}"
|
(i <= num_a) ? "A#{i}" : "B#{i - num_a}"
|
||||||
end
|
end
|
||||||
make_accessor_bool *channels
|
make_accessor_bool(*channels)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,13 +38,6 @@ module Voicemeeter
|
|||||||
public
|
public
|
||||||
|
|
||||||
def self.new(kind_id, **kwargs)
|
def self.new(kind_id, **kwargs)
|
||||||
"
|
|
||||||
Factory method for remotes
|
|
||||||
|
|
||||||
Wraps factory expression and handles errors
|
|
||||||
|
|
||||||
Returns a Remote class of a Kind
|
|
||||||
"
|
|
||||||
remotes =
|
remotes =
|
||||||
Kinds::ALL.to_h { |kind| [kind.name, Remote.new(kind, **kwargs)] }
|
Kinds::ALL.to_h { |kind| [kind.name, Remote.new(kind, **kwargs)] }
|
||||||
unless remotes.key? kind_id
|
unless remotes.key? kind_id
|
||||||
|
@ -11,13 +11,8 @@ module Voicemeeter
|
|||||||
attr_reader :gainlayer, :levels
|
attr_reader :gainlayer, :levels
|
||||||
|
|
||||||
def self.make(remote, i)
|
def self.make(remote, i)
|
||||||
"
|
|
||||||
Factory function for Strip classes.
|
|
||||||
|
|
||||||
Returns a PhysicalStrip or VirtualStrip class
|
|
||||||
"
|
|
||||||
p_in = remote.kind.phys_in
|
p_in = remote.kind.phys_in
|
||||||
i < p_in ? PhysicalStrip.new(remote, i) : VirtualStrip.new(remote, i)
|
(i < p_in) ? PhysicalStrip.new(remote, i) : VirtualStrip.new(remote, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(remote, i)
|
def initialize(remote, i)
|
||||||
@ -190,17 +185,15 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gain
|
def gain
|
||||||
self.getter("gainlayer[#{@j}]")
|
getter("gainlayer[#{@j}]")
|
||||||
end
|
end
|
||||||
|
|
||||||
def gain=(value)
|
def gain=(value)
|
||||||
self.setter("gainlayer[#{@j}]", value)
|
setter("gainlayer[#{@j}]", value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class StripLevels < IRemote
|
class StripLevels < IRemote
|
||||||
attr_reader :prefader, :postfader, :postmute
|
|
||||||
|
|
||||||
def initialize(remote, i)
|
def initialize(remote, i)
|
||||||
super
|
super
|
||||||
p_in = remote.kind.phys_in
|
p_in = remote.kind.phys_in
|
||||||
@ -219,13 +212,12 @@ module Voicemeeter
|
|||||||
|
|
||||||
def get_level(mode)
|
def get_level(mode)
|
||||||
@remote.cache[:strip_mode] = mode
|
@remote.cache[:strip_mode] = mode
|
||||||
if @remote.running && @remote.event.ldirty
|
vals = if @remote.running && @remote.event.ldirty
|
||||||
vals = @remote.cache[:strip_level][@init, @offset]
|
@remote.cache[:strip_level][@init, @offset]
|
||||||
else
|
else
|
||||||
vals =
|
|
||||||
(@init...@init + @offset).map { |i| @remote.get_level(mode, i) }
|
(@init...@init + @offset).map { |i| @remote.get_level(mode, i) }
|
||||||
end
|
end
|
||||||
vals.map { |x| x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
vals.map { |x| (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
||||||
end
|
end
|
||||||
|
|
||||||
def prefader
|
def prefader
|
||||||
|
@ -5,9 +5,6 @@ require_relative "errors"
|
|||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
module Vban
|
module Vban
|
||||||
class VbanStream < IRemote
|
class VbanStream < IRemote
|
||||||
"
|
|
||||||
A class representing a VBAN stream
|
|
||||||
"
|
|
||||||
def initialize(remote, i)
|
def initialize(remote, i)
|
||||||
super
|
super
|
||||||
make_accessor_bool :on
|
make_accessor_bool :on
|
||||||
@ -25,9 +22,6 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
class VbanInstream < VbanStream
|
class VbanInstream < VbanStream
|
||||||
"
|
|
||||||
A subclass representing a VBAN Instream
|
|
||||||
"
|
|
||||||
def initialize(remote, i)
|
def initialize(remote, i)
|
||||||
super
|
super
|
||||||
make_reader_int :sr, :channel, :bit
|
make_reader_int :sr, :channel, :bit
|
||||||
@ -39,9 +33,6 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
class VbanOutstream < VbanStream
|
class VbanOutstream < VbanStream
|
||||||
"
|
|
||||||
A subclass representing a VBAN Outstream
|
|
||||||
"
|
|
||||||
def initialize(remote, i)
|
def initialize(remote, i)
|
||||||
super
|
super
|
||||||
make_accessor_int :sr, :channel, :bit
|
make_accessor_int :sr, :channel, :bit
|
||||||
@ -56,11 +47,6 @@ module Voicemeeter
|
|||||||
attr_reader :instream, :outstream
|
attr_reader :instream, :outstream
|
||||||
|
|
||||||
def initialize(remote)
|
def initialize(remote)
|
||||||
"
|
|
||||||
Initializes a Vban class
|
|
||||||
|
|
||||||
Creates an array for each in/out stream and sets as class attributes
|
|
||||||
"
|
|
||||||
vban_in, vban_out = remote.kind.vban
|
vban_in, vban_out = remote.kind.vban
|
||||||
@instream = []
|
@instream = []
|
||||||
vban_in.times { |i| @instream << VbanInstream.new(remote, i) }
|
vban_in.times { |i| @instream << VbanInstream.new(remote, i) }
|
||||||
|
Loading…
Reference in New Issue
Block a user