voicemeeter_api_ruby 4.1.5 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/bus.rb DELETED
@@ -1,105 +0,0 @@
1
- require_relative "iremote"
2
-
3
- class Bus < IRemote
4
- "
5
- Concrete Bus class
6
- "
7
- include Channel_Meta_Functions
8
-
9
- attr_accessor :mode, :levels
10
-
11
- def self.make(remote, layout_bus)
12
- "
13
- Factory function for Bus classes.
14
- "
15
- p_out, v_out = layout_bus.values
16
- (0...(p_out + v_out)).map do |i|
17
- i < p_out ? PhysicalBus.new(remote, i) : VirtualBus.new(remote, i)
18
- end
19
- end
20
-
21
- def initialize(remote, i)
22
- super
23
- self.make_accessor_bool :mute, :mono, :eq, :sel
24
- self.make_accessor_float :gain
25
- self.make_accessor_string :label
26
-
27
- @mode = BusModes.new(remote, i)
28
- @levels = BusLevels.new(remote, i)
29
- end
30
-
31
- def identifier
32
- "bus[#{@index}]"
33
- end
34
-
35
- def fadeto(target, time)
36
- self.setter("FadeTo", "(#{target}, #{time})")
37
- sleep(@remote.delay)
38
- end
39
-
40
- def fadeby(change, time)
41
- self.setter("FadeBy", "(#{change}, #{time})")
42
- sleep(@remote.delay)
43
- end
44
- end
45
-
46
- class PhysicalBus < Bus
47
- def initialize(remote, i)
48
- super
49
- self.make_reader_only :device, :sr
50
- end
51
- end
52
-
53
- class VirtualBus < Bus
54
- end
55
-
56
- class BusModes < IRemote
57
- include Channel_Meta_Functions
58
-
59
- def initialize(remote, i)
60
- super
61
- self.make_bus_modes :normal,
62
- :amix,
63
- :bmix,
64
- :repeat,
65
- :composite,
66
- :tvmix,
67
- :upmix21,
68
- :upmix41,
69
- :upmix61,
70
- :centeronly,
71
- :lfeonly,
72
- :rearonly
73
- end
74
-
75
- def identifier
76
- "bus[#{@index}].mode"
77
- end
78
- end
79
-
80
- class BusLevels < IRemote
81
- def initialize(remote, i)
82
- super
83
- @init = i * 8
84
- @offset = 8
85
- end
86
-
87
- def identifier
88
- "bus[#{@index}]"
89
- end
90
-
91
- def getter(mode)
92
- if @remote.running
93
- vals = @remote.cache["bus_level"][@init, @offset]
94
- else
95
- vals = (@init...@offset).map { |i| @remote.get_level(mode, i) }
96
- end
97
- vals.map { |x| x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0 }
98
- end
99
-
100
- def all
101
- getter(3)
102
- end
103
-
104
- def isdirty? = @remote._bus_comp[@init, @offset].any?
105
- end
data/lib/button.rb DELETED
@@ -1,23 +0,0 @@
1
- require_relative "iremote"
2
- require_relative "meta"
3
-
4
- class MacroButton < IRemote
5
- include MacroButton_Meta_Functions
6
-
7
- def self.make(remote, num_buttons)
8
- (0...num_buttons).map { |i| MacroButton.new(remote, i) }
9
- end
10
-
11
- def initialize(remote, i)
12
- super
13
- self.make_accessor_macrobutton :state, :stateonly, :trigger
14
- end
15
-
16
- def getter(mode)
17
- @remote.get_buttonstatus(@index, mode)
18
- end
19
-
20
- def setter(set, mode)
21
- @remote.set_buttonstatus(@index, set, mode)
22
- end
23
- end
data/lib/cbindings.rb DELETED
@@ -1,125 +0,0 @@
1
- require "ffi"
2
- require_relative "inst"
3
-
4
- include InstallationFunctions
5
-
6
- module CBindings
7
- "
8
- Creates Ruby bindings to the C DLL
9
-
10
- Performs other low level tasks
11
- "
12
- extend FFI::Library
13
-
14
- private
15
-
16
- begin
17
- OS_BITS = FFI::Platform::CPU.downcase == "x64" ? 64 : 32
18
- VM_PATH = get_vmpath(OS_BITS)
19
- DLL_NAME = "VoicemeeterRemote#{OS_BITS == 64 ? "64" : ""}.dll"
20
-
21
- self.vm_dll = VM_PATH.join(DLL_NAME)
22
- rescue InstallErrors => error
23
- puts "ERROR: #{error.message}"
24
- raise
25
- end
26
-
27
- ffi_lib @vm_dll
28
- ffi_convention :stdcall
29
-
30
- attach_function :vm_login, :VBVMR_Login, [], :long
31
- attach_function :vm_logout, :VBVMR_Logout, [], :long
32
- attach_function :vm_runvm, :VBVMR_RunVoicemeeter, [:long], :long
33
- attach_function :vm_vmtype, :VBVMR_GetVoicemeeterType, [:pointer], :long
34
- attach_function :vm_vmversion, :VBVMR_GetVoicemeeterVersion, [:pointer], :long
35
-
36
- attach_function :vm_mdirty, :VBVMR_MacroButton_IsDirty, [], :long
37
- attach_function :vm_get_buttonstatus,
38
- :VBVMR_MacroButton_GetStatus,
39
- %i[long pointer long],
40
- :long
41
- attach_function :vm_set_buttonstatus,
42
- :VBVMR_MacroButton_SetStatus,
43
- %i[long float long],
44
- :long
45
-
46
- attach_function :vm_pdirty, :VBVMR_IsParametersDirty, [], :long
47
- attach_function :vm_get_parameter_float,
48
- :VBVMR_GetParameterFloat,
49
- %i[string pointer],
50
- :long
51
- attach_function :vm_set_parameter_float,
52
- :VBVMR_SetParameterFloat,
53
- %i[string float],
54
- :long
55
-
56
- attach_function :vm_get_parameter_string,
57
- :VBVMR_GetParameterStringA,
58
- %i[string pointer],
59
- :long
60
- attach_function :vm_set_parameter_string,
61
- :VBVMR_SetParameterStringA,
62
- %i[string string],
63
- :long
64
-
65
- attach_function :vm_set_parameter_multi,
66
- :VBVMR_SetParameters,
67
- [:string],
68
- :long
69
-
70
- attach_function :vm_get_level, :VBVMR_GetLevel, %i[long long pointer], :long
71
-
72
- attach_function :vm_get_num_indevices, :VBVMR_Input_GetDeviceNumber, [], :long
73
- attach_function :vm_get_desc_indevices,
74
- :VBVMR_Input_GetDeviceDescA,
75
- %i[long pointer pointer pointer],
76
- :long
77
-
78
- attach_function :vm_get_num_outdevices,
79
- :VBVMR_Output_GetDeviceNumber,
80
- [],
81
- :long
82
- attach_function :vm_get_desc_outdevices,
83
- :VBVMR_Output_GetDeviceDescA,
84
- %i[long pointer pointer pointer],
85
- :long
86
-
87
- @@cdll =
88
- lambda { |func, *args| self.retval = [send("vm_#{func}", *args), func] }
89
-
90
- def clear_polling = while pdirty? || mdirty?; end
91
-
92
- def polling(func, **kwargs)
93
- params = {
94
- "get_parameter" => kwargs[:name],
95
- "get_buttonstatus" => "mb_#{kwargs[:id]}_#{kwargs[:mode]}"
96
- }
97
- return @cache.delete(params[func]) if @cache.key? params[func]
98
-
99
- clear_polling if @sync
100
-
101
- yield
102
- end
103
-
104
- def retval=(values)
105
- " Writer validation for CAPI calls "
106
- retval, func = *values
107
- unless %i[get_num_indevices get_num_outdevices].include? func
108
- raise CAPIErrors.new(retval, func) if retval&.nonzero?
109
- end
110
- @retval = retval
111
- end
112
-
113
- public
114
-
115
- def pdirty? = vm_pdirty&.nonzero?
116
-
117
- def mdirty? = vm_mdirty&.nonzero?
118
-
119
- def ldirty?
120
- @strip_buf, @bus_buf = _get_levels
121
- return(
122
- !(@cache["strip_level"] == @strip_buf && @cache["bus_level"] == @bus_buf)
123
- )
124
- end
125
- end
data/lib/command.rb DELETED
@@ -1,36 +0,0 @@
1
- require_relative "iremote"
2
- require_relative "meta"
3
-
4
- class Command < IRemote
5
- include Commands_Meta_Functions
6
-
7
- def initialize(remote)
8
- super
9
- self.make_action_prop :show, :restart, :shutdown
10
- self.make_writer_bool :showvbanchat, :lock
11
- end
12
-
13
- def identifier
14
- :command
15
- end
16
-
17
- def hide
18
- self.setter("show", 0)
19
- end
20
-
21
- def load(value)
22
- raise VMRemoteErrors.new("Expected a string") unless value.is_a? String
23
- self.setter("load", value)
24
- sleep(0.2)
25
- end
26
-
27
- def save(value)
28
- raise VMRemoteErrors.new("Expected a string") unless value.is_a? String
29
- self.setter("save", value)
30
- sleep(0.2)
31
- end
32
-
33
- def reset
34
- @remote.set_config("reset")
35
- end
36
- end
data/lib/configs.rb DELETED
@@ -1,80 +0,0 @@
1
- require "kinds"
2
- require "toml"
3
-
4
- module Configs
5
- private
6
-
7
- @@configs = Hash.new
8
-
9
- class TOMLStrBuilder
10
- def initialize(kind)
11
- @p_in, @v_in = kind[:layout][:strip].values
12
- @p_out, @v_out = kind[:layout][:bus].values
13
- @vs_params =
14
- ["mute = false", "mono = false", "solo = false", "gain = 0.0"] +
15
- (1..@p_out).map { |i| "A#{i} = false" } +
16
- (1..@v_out).map { |i| "B#{i} = false" }
17
-
18
- @ps_params = @vs_params + ["comp = 0.0", "gate = 0.0"]
19
- @bus_params = ["mono = false", "eq = false", "mute = false"]
20
- end
21
-
22
- def build
23
- "
24
- Builds a TOML script for the parser
25
- "
26
- @ps = (0...@p_in).map { |i| ["[strip_#{i}]"] + @ps_params }
27
- @ps.map! { |a| a.map { |s| s.gsub("B1 = false", "B1 = true") } }
28
- @vs = (@p_in...(@p_in + @v_in)).map { |i| ["[strip_#{i}]"] + @vs_params }
29
- @vs.map! { |a| a.map { |s| s.gsub("A1 = false", "A1 = true") } }
30
-
31
- @b = (0...(@p_out + @v_out)).map { |i| ["[bus_#{i}]"] + @bus_params }
32
-
33
- [@ps + @vs + @b].join("\n")
34
- end
35
- end
36
-
37
- def parser(data)
38
- TOML::Parser.new(data).parsed
39
- end
40
-
41
- def get_configs(kind_id)
42
- file_path = File.join(Dir.pwd, "configs", "#{kind_id}")
43
-
44
- if Dir.exist?(file_path)
45
- Dir
46
- .glob(File.join(file_path, "*.toml"))
47
- .to_h do |toml_file|
48
- filename = File.basename(toml_file, ".toml")
49
- puts "loading config #{kind_id}/#{filename} into memory"
50
- [filename, parser(File.read(toml_file))]
51
- end
52
- end
53
- end
54
-
55
- def loader
56
- if @@configs.empty?
57
- builder = TOMLStrBuilder.new(@kind)
58
- puts "loading config reset into memory"
59
- @@configs["reset"] = parser(builder.build)
60
- configs = get_configs(@kind.name.to_s)
61
-
62
- @@configs.merge!(configs) unless configs.nil?
63
- end
64
- end
65
-
66
- public
67
-
68
- def set_config(value)
69
- loader
70
- unless @@configs.key? value
71
- raise VMRemoteErrors.new("No profile with name #{value} was loaded")
72
- end
73
-
74
- self.send("set_multi", @@configs[value])
75
- puts "config #{@kind.name}/#{value} applied!"
76
- sleep(@delay)
77
- end
78
-
79
- alias_method "apply_config", :set_config
80
- end
data/lib/device.rb DELETED
@@ -1,24 +0,0 @@
1
- require_relative "iremote"
2
- require_relative "meta"
3
-
4
- class Device
5
- def initialize(remote)
6
- @remote = remote
7
- end
8
-
9
- def getter(**kwargs)
10
- return @remote.get_num_devices(kwargs[:direction]) if kwargs[:index].nil?
11
-
12
- vals = @remote.get_device_description(kwargs[:index], kwargs[:direction])
13
- types = { 1 => "mme", 3 => "wdm", 4 => "ks", 5 => "asio" }
14
- { name: vals[0], type: types[vals[1]], id: vals[2] }
15
- end
16
-
17
- def ins = getter(direction: "in")
18
-
19
- def outs = getter(direction: "out")
20
-
21
- def input(i) = getter(index: i, direction: "in")
22
-
23
- def output(i) = getter(index: i, direction: "out")
24
- end
data/lib/errors.rb DELETED
@@ -1,41 +0,0 @@
1
- module Errors
2
- class VMRemoteErrors < StandardError
3
- end
4
-
5
- class InstallErrors < VMRemoteErrors
6
- end
7
-
8
- class CAPIErrors < VMRemoteErrors
9
- attr_accessor :value, :func
10
-
11
- def initialize(value, func)
12
- self.value = value
13
- self.func = func
14
- end
15
-
16
- def message
17
- "
18
- When attempting to run function #{@func} the
19
- C API returned value #{@value}. See documentation for further info
20
- "
21
- end
22
- end
23
-
24
- class OutOfBoundsErrors < VMRemoteErrors
25
- attr_accessor :range
26
-
27
- def initialize(range)
28
- self.range = range
29
- end
30
-
31
- def message
32
- if @range.kind_of?(Range)
33
- "Value error, expected value in range (#{range.first}..#{range.last})"
34
- elsif @range.kind_of?(Array)
35
- "Value error, expected one of: #{@range}"
36
- else
37
- "Value error, expected #{@range}"
38
- end
39
- end
40
- end
41
- end
data/lib/inst.rb DELETED
@@ -1,27 +0,0 @@
1
- require "win32/registry"
2
- require "pathname"
3
- require_relative "errors"
4
-
5
- include Errors
6
-
7
- module InstallationFunctions
8
- private
9
-
10
- def get_vmpath(os_bits)
11
- vm_key = "VB:Voicemeeter {17359A74-1236-5467}"
12
- reg_key =
13
- "Software#{os_bits == 64 ? "\\WOW6432Node" : ""}\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
14
- Win32::Registry::HKEY_LOCAL_MACHINE.open(reg_key + vm_key) do |reg|
15
- value = reg["UninstallString"]
16
-
17
- pn = Pathname.new(value)
18
- return pn.dirname
19
- end
20
- raise InstallErrors.new("Could not get the Voicemeeter path")
21
- end
22
-
23
- def vm_dll=(value)
24
- raise InstallErrors.new("Could not fetch the dll file") unless value.file?
25
- @vm_dll = value
26
- end
27
- end
data/lib/iremote.rb DELETED
@@ -1,32 +0,0 @@
1
- require_relative "meta"
2
- require_relative "errors"
3
-
4
- class IRemote
5
- "
6
- Common interface between base class and higher classes.
7
- "
8
- include Meta_Functions
9
-
10
- def initialize(remote, i = nil)
11
- @remote = remote
12
- @index = i
13
- end
14
-
15
- def getter(param, is_string = false)
16
- @remote.get_parameter("#{self.identifier}.#{param}", is_string)
17
- end
18
-
19
- def setter(param, value)
20
- @remote.set_parameter("#{self.identifier}.#{param}", value)
21
- end
22
-
23
- def identifier
24
- raise "Called abstract method: identifier"
25
- end
26
-
27
- def set_multi(param_hash)
28
- param_hash.each { |(key, val)| self.send("#{key}=", val) }
29
- end
30
-
31
- alias_method "apply", :set_multi
32
- end
data/lib/recorder.rb DELETED
@@ -1,20 +0,0 @@
1
- require_relative "iremote"
2
- require_relative "meta"
3
-
4
- class Recorder < IRemote
5
- "
6
- Concrete Recorder class
7
- "
8
-
9
- def initialize(remote)
10
- super
11
- self.make_action_prop :play, :stop, :record, :ff, :rew
12
-
13
- num_A, num_B = remote.kind.layout[:bus].values
14
- self.make_accessor_bool *make_channel_props(num_A, num_B)
15
- end
16
-
17
- def identifier
18
- :recorder
19
- end
20
- end
data/lib/strip.rb DELETED
@@ -1,135 +0,0 @@
1
- require_relative "iremote"
2
-
3
- class Strip < IRemote
4
- "
5
- Concrete Strip class
6
- "
7
- include Channel_Meta_Functions
8
-
9
- attr_accessor :gainlayer, :levels
10
-
11
- def self.make(remote, layout_strip)
12
- "
13
- Factory function for Strip classes.
14
- "
15
- p_in, v_in = layout_strip.values
16
- (0...(p_in + v_in)).map do |i|
17
- i < p_in ? PhysicalStrip.new(remote, i) : VirtualStrip.new(remote, i)
18
- end
19
- end
20
-
21
- def initialize(remote, i)
22
- super
23
- self.make_accessor_bool :solo, :mute, :mono
24
- self.make_accessor_float :gain
25
- self.make_accessor_int :limit
26
- self.make_accessor_string :label
27
-
28
- num_A, num_B = remote.kind.layout[:bus].values
29
- self.make_accessor_bool *make_channel_props(num_A, num_B)
30
-
31
- @gainlayer = (0...8).map { |j| GainLayer.new(remote, i, j) }
32
- @levels = StripLevels.new(remote, i)
33
- end
34
-
35
- def identifier
36
- "strip[#{@index}]"
37
- end
38
-
39
- def fadeto(target, time)
40
- self.setter("FadeTo", "(#{target}, #{time})")
41
- sleep(@remote.delay)
42
- end
43
-
44
- def fadeby(change, time)
45
- self.setter("FadeBy", "(#{change}, #{time})")
46
- sleep(@remote.delay)
47
- end
48
- end
49
-
50
- class PhysicalStrip < Strip
51
- def initialize(remote, i)
52
- super
53
- self.make_accessor_float :comp, :gate, :audibility
54
- self.make_reader_only :device, :sr
55
- end
56
- end
57
-
58
- class VirtualStrip < Strip
59
- def initialize(remote, i)
60
- super
61
- self.make_accessor_bool :mc
62
- self.make_accessor_int :k
63
- self.make_accessor_float :bass, :mid, :treble
64
- end
65
-
66
- def appgain(name, gain)
67
- self.setter("AppGain", "(\"#{name}\", #{gain})")
68
- end
69
-
70
- def appmute(name, mute)
71
- self.setter("AppMute", "(\"#{name}\", #{mute ? 1 : 0})")
72
- end
73
- end
74
-
75
- class GainLayer < IRemote
76
- def initialize(remote, i, j)
77
- super(remote, i)
78
- @j = j
79
- end
80
-
81
- def identifier
82
- "strip[#{@index}]"
83
- end
84
-
85
- def gain
86
- self.getter("gainlayer[#{@j}]")
87
- end
88
-
89
- def gain=(value)
90
- self.setter("gainlayer[#{@j}]", value)
91
- end
92
- end
93
-
94
- class StripLevels < IRemote
95
- def initialize(remote, i)
96
- super
97
- if i < @remote.p_in
98
- @init = i * 2
99
- @offset = 2
100
- else
101
- @init = (@remote.p_in * 2) + ((i - @remote.p_in) * 8)
102
- @offset = 8
103
- end
104
- end
105
-
106
- def identifier
107
- "strip[#{@index}]"
108
- end
109
-
110
- def get_level(mode)
111
- if @remote.running
112
- vals = @remote.cache["strip_level"][@init, @offset]
113
- else
114
- vals = (@init...@offset).map { |i| get_level(mode, i) }
115
- end
116
- vals.map { |x| x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0 }
117
- end
118
-
119
- def prefader
120
- @remote.strip_mode = 0
121
- get_level(0)
122
- end
123
-
124
- def postfader
125
- @remote.strip_mode = 1
126
- get_level(1)
127
- end
128
-
129
- def postmute
130
- @remote.strip_mode = 2
131
- get_level(2)
132
- end
133
-
134
- def isdirty? = @remote._strip_comp[@init, @offset].any?
135
- end