voicemeeter_api_ruby 4.1.2 → 4.1.5
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.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/base.rb +220 -221
- data/lib/bus.rb +86 -78
- data/lib/button.rb +23 -23
- data/lib/cbindings.rb +115 -118
- data/lib/command.rb +36 -36
- data/lib/configs.rb +80 -81
- data/lib/device.rb +15 -15
- data/lib/errors.rb +30 -28
- data/lib/inst.rb +27 -29
- data/lib/iremote.rb +32 -30
- data/lib/kinds.rb +77 -77
- data/lib/meta.rb +275 -282
- data/lib/recorder.rb +20 -20
- data/lib/runvm.rb +29 -29
- data/lib/strip.rb +120 -116
- data/lib/vban.rb +78 -78
- data/lib/version.rb +3 -3
- data/lib/voicemeeter.rb +86 -86
- metadata +2 -3
- data/lib/mixin.rb +0 -11
data/lib/bus.rb
CHANGED
@@ -1,97 +1,105 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative 'mixin'
|
1
|
+
require_relative "iremote"
|
3
2
|
|
4
3
|
class Bus < IRemote
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
i < p_out ? PhysicalBus.new(remote, i) : VirtualBus.new(remote, i)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(remote, i)
|
24
|
-
super
|
25
|
-
self.make_accessor_bool :mute, :mono, :eq, :sel
|
26
|
-
self.make_accessor_float :gain
|
27
|
-
self.make_accessor_string :label
|
28
|
-
|
29
|
-
@mode = BusModes.new(remote, i)
|
30
|
-
@levels = BusLevels.new(remote, i)
|
31
|
-
end
|
32
|
-
|
33
|
-
def identifier
|
34
|
-
"bus[#{@index}]"
|
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)
|
35
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
|
36
44
|
end
|
37
45
|
|
38
46
|
class PhysicalBus < Bus
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
47
|
+
def initialize(remote, i)
|
48
|
+
super
|
49
|
+
self.make_reader_only :device, :sr
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
53
|
class VirtualBus < Bus
|
46
54
|
end
|
47
55
|
|
48
56
|
class BusModes < IRemote
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
70
78
|
end
|
71
79
|
|
72
80
|
class BusLevels < IRemote
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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) }
|
81
96
|
end
|
97
|
+
vals.map { |x| x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
98
|
+
end
|
82
99
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
else
|
87
|
-
vals = (@init...@offset).map { |i| @remote.get_level(mode, i) }
|
88
|
-
end
|
89
|
-
vals.map { |x| x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
90
|
-
end
|
91
|
-
|
92
|
-
def all
|
93
|
-
getter(3)
|
94
|
-
end
|
100
|
+
def all
|
101
|
+
getter(3)
|
102
|
+
end
|
95
103
|
|
96
|
-
|
104
|
+
def isdirty? = @remote._bus_comp[@init, @offset].any?
|
97
105
|
end
|
data/lib/button.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
|
4
|
-
class MacroButton < IRemote
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
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
CHANGED
@@ -1,128 +1,125 @@
|
|
1
|
-
require
|
2
|
-
require_relative
|
1
|
+
require "ffi"
|
2
|
+
require_relative "inst"
|
3
3
|
|
4
4
|
include InstallationFunctions
|
5
5
|
|
6
6
|
module CBindings
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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?
|
25
109
|
end
|
110
|
+
@retval = retval
|
111
|
+
end
|
26
112
|
|
27
|
-
|
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,
|
71
|
-
:VBVMR_GetLevel,
|
72
|
-
%i[long long pointer],
|
73
|
-
:long
|
74
|
-
|
75
|
-
attach_function :vm_get_num_indevices,
|
76
|
-
:VBVMR_Input_GetDeviceNumber, [], :long
|
77
|
-
attach_function :vm_get_desc_indevices,
|
78
|
-
:VBVMR_Input_GetDeviceDescA, %i[long pointer pointer pointer],
|
79
|
-
:long
|
80
|
-
|
81
|
-
attach_function :vm_get_num_outdevices,
|
82
|
-
:VBVMR_Output_GetDeviceNumber, [], :long
|
83
|
-
attach_function :vm_get_desc_outdevices,
|
84
|
-
:VBVMR_Output_GetDeviceDescA, %i[long pointer pointer pointer],
|
85
|
-
:long
|
86
|
-
|
87
|
-
|
88
|
-
@@cdll =
|
89
|
-
lambda do |func, *args|
|
90
|
-
self.retval = [send("vm_#{func}", *args), func]
|
91
|
-
end
|
92
|
-
|
93
|
-
def clear_polling() = while pdirty? || mdirty?; end
|
94
|
-
|
95
|
-
def polling(func, **kwargs)
|
96
|
-
params = {
|
97
|
-
'get_parameter' => kwargs[:name],
|
98
|
-
'get_buttonstatus' => "mb_#{kwargs[:id]}_#{kwargs[:mode]}",
|
99
|
-
}
|
100
|
-
return @cache.delete(params[func]) if @cache.key? params[func]
|
101
|
-
|
102
|
-
clear_polling if @sync
|
103
|
-
|
104
|
-
yield
|
105
|
-
end
|
113
|
+
public
|
106
114
|
|
107
|
-
|
108
|
-
' Writer validation for CAPI calls '
|
109
|
-
retval, func = *values
|
110
|
-
unless [:get_num_indevices, :get_num_outdevices].include? func
|
111
|
-
raise CAPIErrors.new(retval, func) if retval&.nonzero?
|
112
|
-
end
|
113
|
-
@retval = retval
|
114
|
-
end
|
115
|
-
|
116
|
-
public
|
115
|
+
def pdirty? = vm_pdirty&.nonzero?
|
117
116
|
|
118
|
-
|
117
|
+
def mdirty? = vm_mdirty&.nonzero?
|
119
118
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
)
|
127
|
-
end
|
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
|
128
125
|
end
|
data/lib/command.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
|
4
|
-
class Command < IRemote
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
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
|