voicemeeter_api_ruby 4.0.0 → 4.1.2
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/CHANGELOG.md +39 -8
- data/README.md +37 -11
- data/lib/base.rb +221 -209
- data/lib/bus.rb +97 -68
- data/lib/button.rb +23 -23
- data/lib/cbindings.rb +128 -122
- data/lib/command.rb +36 -36
- data/lib/configs.rb +81 -79
- data/lib/inst.rb +29 -29
- data/lib/iremote.rb +30 -42
- data/lib/meta.rb +282 -274
- data/lib/mixin.rb +11 -0
- data/lib/recorder.rb +20 -20
- data/lib/runvm.rb +29 -29
- data/lib/strip.rb +131 -86
- data/lib/vban.rb +78 -78
- data/lib/version.rb +3 -3
- data/lib/voicemeeter.rb +86 -86
- metadata +7 -6
data/lib/bus.rb
CHANGED
@@ -1,68 +1,97 @@
|
|
1
|
-
require_relative 'iremote'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
include
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
self.
|
26
|
-
self.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
1
|
+
require_relative 'iremote'
|
2
|
+
require_relative 'mixin'
|
3
|
+
|
4
|
+
class Bus < IRemote
|
5
|
+
'
|
6
|
+
Concrete Bus class
|
7
|
+
'
|
8
|
+
include Channel_Meta_Functions
|
9
|
+
include Fades
|
10
|
+
|
11
|
+
attr_accessor :mode, :levels
|
12
|
+
|
13
|
+
def self.make(remote, layout_bus)
|
14
|
+
'
|
15
|
+
Factory function for Bus classes.
|
16
|
+
'
|
17
|
+
p_out, v_out = layout_bus.values
|
18
|
+
(0...(p_out + v_out)).map do |i|
|
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}]"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class PhysicalBus < Bus
|
39
|
+
def initialize(remote, i)
|
40
|
+
super
|
41
|
+
self.make_reader_only :device, :sr
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class VirtualBus < Bus
|
46
|
+
end
|
47
|
+
|
48
|
+
class BusModes < IRemote
|
49
|
+
include Channel_Meta_Functions
|
50
|
+
|
51
|
+
def initialize(remote, i)
|
52
|
+
super
|
53
|
+
self.make_bus_modes :normal,
|
54
|
+
:amix,
|
55
|
+
:bmix,
|
56
|
+
:repeat,
|
57
|
+
:composite,
|
58
|
+
:tvmix,
|
59
|
+
:upmix21,
|
60
|
+
:upmix41,
|
61
|
+
:upmix61,
|
62
|
+
:centeronly,
|
63
|
+
:lfeonly,
|
64
|
+
:rearonly
|
65
|
+
end
|
66
|
+
|
67
|
+
def identifier
|
68
|
+
"bus[#{@index}].mode"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class BusLevels < IRemote
|
73
|
+
def initialize(remote, i)
|
74
|
+
super
|
75
|
+
@init = i * 8
|
76
|
+
@offset = 8
|
77
|
+
end
|
78
|
+
|
79
|
+
def identifier
|
80
|
+
"bus[#{@index}]"
|
81
|
+
end
|
82
|
+
|
83
|
+
def getter(mode)
|
84
|
+
if @remote.running
|
85
|
+
vals = @remote.cache['bus_level'][@init, @offset]
|
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
|
95
|
+
|
96
|
+
def isdirty?() = @remote._bus_comp[@init, @offset].any?
|
97
|
+
end
|
data/lib/button.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
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
|
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,122 +1,128 @@
|
|
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,
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
'
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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,
|
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
|
106
|
+
|
107
|
+
def retval=(values)
|
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
|
117
|
+
|
118
|
+
def pdirty?() = vm_pdirty&.nonzero?
|
119
|
+
|
120
|
+
def mdirty?() = vm_mdirty&.nonzero?
|
121
|
+
|
122
|
+
def ldirty?
|
123
|
+
@strip_buf, @bus_buf = _get_levels
|
124
|
+
return !(
|
125
|
+
@cache['strip_level'] == @strip_buf && @cache['bus_level'] == @bus_buf
|
126
|
+
)
|
127
|
+
end
|
128
|
+
end
|
data/lib/command.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
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
|
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
|