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.
data/lib/bus.rb CHANGED
@@ -1,68 +1,97 @@
1
- require_relative 'iremote'
2
-
3
- class Bus < IRemote
4
- '
5
- Concrete Bus class
6
- '
7
- include Channel_Meta_Functions
8
- include Fades
9
-
10
- attr_accessor :mode
11
-
12
- def self.make(remote, layout_bus)
13
- '
14
- Factory function for Bus classes.
15
- '
16
- p_out, v_out = layout_bus.values
17
- (0...(p_out + v_out)).map do |i|
18
- i < p_out ? PhysicalBus.new(remote, i) : VirtualBus.new(remote, i)
19
- end
20
- end
21
-
22
- def initialize(remote, i)
23
- super
24
- self.make_accessor_bool :mute, :mono, :eq, :sel
25
- self.make_accessor_float :gain
26
- self.make_accessor_string :label
27
-
28
- @mode = BusModes.new(remote, i)
29
- end
30
-
31
- def identifier
32
- "bus[#{@index}]"
33
- end
34
- end
35
-
36
- class PhysicalBus < Bus
37
- def initialize(remote, i)
38
- super
39
- self.make_reader_only :device, :sr
40
- end
41
- end
42
-
43
- class VirtualBus < Bus
44
- end
45
-
46
- class BusModes < IRemote
47
- include Channel_Meta_Functions
48
-
49
- def initialize(remote, i)
50
- super
51
- self.make_bus_modes :normal,
52
- :amix,
53
- :bmix,
54
- :repeat,
55
- :composite,
56
- :tvmix,
57
- :upmix21,
58
- :upmix41,
59
- :upmix61,
60
- :centeronly,
61
- :lfeonly,
62
- :rearonly
63
- end
64
-
65
- def identifier
66
- "bus[#{@index}].mode"
67
- end
68
- end
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
- @@cdll =
90
- lambda do |func, *args|
91
- self.retval = [send("vm_#{func}", *args), func]
92
- end
93
-
94
- def clear_polling() = while pdirty? || mdirty?; end
95
-
96
- def polling(func, **kwargs)
97
- params = {
98
- 'get_parameter' => kwargs[:name],
99
- 'get_buttonstatus' => "mb_#{kwargs[:id]}_#{kwargs[:mode]}",
100
- }
101
- return @cache.delete(params[func]) if @cache.key? params[func]
102
-
103
- clear_polling if @sync
104
-
105
- yield
106
- end
107
-
108
- def retval=(values)
109
- ' Writer validation for CAPI calls '
110
- retval, func = *values
111
- unless [:get_num_indevices, :get_num_outdevices].include? func
112
- raise CAPIErrors.new(retval, func) if retval&.nonzero?
113
- end
114
- @retval = retval
115
- end
116
-
117
- public
118
-
119
- def pdirty?() = vm_pdirty&.nonzero?
120
-
121
- def mdirty?() = vm_mdirty&.nonzero?
122
- end
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