mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 09:50:49 +00:00
override attach_function in CBindings
rename bindings in Base class
This commit is contained in:
parent
ca66af7d84
commit
875a5b6a23
@ -34,11 +34,11 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pdirty?
|
def pdirty?
|
||||||
CBindings.call(:bind_pdirty, ok: [0, 1]) == 1
|
CBindings.call(:bind_is_parameters_dirty, ok: [0, 1]) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def mdirty?
|
def mdirty?
|
||||||
CBindings.call(:bind_mdirty, ok: [0, 1]) == 1
|
CBindings.call(:bind_macro_button_is_dirty, ok: [0, 1]) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -54,7 +54,7 @@ module Voicemeeter
|
|||||||
banana: Kinds::KindEnum::BANANA,
|
banana: Kinds::KindEnum::BANANA,
|
||||||
potato: Install::OS_BITS == 64 ? 6 : Kinds::KindEnum::POTATO
|
potato: Install::OS_BITS == 64 ? 6 : Kinds::KindEnum::POTATO
|
||||||
}
|
}
|
||||||
CBindings.call(:bind_runvm, kinds[@kind.name])
|
CBindings.call(:bind_run_voicemeeter, kinds[@kind.name])
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ module Voicemeeter
|
|||||||
|
|
||||||
def type
|
def type
|
||||||
ckind = FFI::MemoryPointer.new(:long, 1)
|
ckind = FFI::MemoryPointer.new(:long, 1)
|
||||||
CBindings.call(:bind_type, ckind)
|
CBindings.call(:bind_get_voicemeeter_type, ckind)
|
||||||
kinds = {
|
kinds = {
|
||||||
Kinds::KindEnum::BASIC => :basic,
|
Kinds::KindEnum::BASIC => :basic,
|
||||||
Kinds::KindEnum::BANANA => :banana,
|
Kinds::KindEnum::BANANA => :banana,
|
||||||
@ -73,7 +73,7 @@ module Voicemeeter
|
|||||||
|
|
||||||
def version
|
def version
|
||||||
cver = FFI::MemoryPointer.new(:long, 1)
|
cver = FFI::MemoryPointer.new(:long, 1)
|
||||||
CBindings.call(:bind_version, cver)
|
CBindings.call(:bind_get_voicemeeter_version, cver)
|
||||||
[
|
[
|
||||||
(cver.read_long & 0xFF000000) >> 24,
|
(cver.read_long & 0xFF000000) >> 24,
|
||||||
(cver.read_long & 0x00FF0000) >> 16,
|
(cver.read_long & 0x00FF0000) >> 16,
|
||||||
@ -86,7 +86,7 @@ module Voicemeeter
|
|||||||
clear_dirty if @sync
|
clear_dirty if @sync
|
||||||
if is_string
|
if is_string
|
||||||
c_get = FFI::MemoryPointer.new(:string, 512, true)
|
c_get = FFI::MemoryPointer.new(:string, 512, true)
|
||||||
CBindings.call(:bind_get_parameter_string, name, c_get)
|
CBindings.call(:bind_get_parameter_string_a, name, c_get)
|
||||||
c_get.read_string
|
c_get.read_string
|
||||||
else
|
else
|
||||||
c_get = FFI::MemoryPointer.new(:float, 1)
|
c_get = FFI::MemoryPointer.new(:float, 1)
|
||||||
@ -97,7 +97,7 @@ module Voicemeeter
|
|||||||
|
|
||||||
def set(name, value)
|
def set(name, value)
|
||||||
if value.is_a? String
|
if value.is_a? String
|
||||||
CBindings.call(:bind_set_parameter_string, name, value)
|
CBindings.call(:bind_set_parameter_string_a, name, value)
|
||||||
else
|
else
|
||||||
CBindings.call(:bind_set_parameter_float, name, value.to_f)
|
CBindings.call(:bind_set_parameter_float, name, value.to_f)
|
||||||
end
|
end
|
||||||
@ -106,12 +106,12 @@ module Voicemeeter
|
|||||||
def get_buttonstatus(id, mode)
|
def get_buttonstatus(id, mode)
|
||||||
clear_dirty if @sync
|
clear_dirty if @sync
|
||||||
c_get = FFI::MemoryPointer.new(:float, 1)
|
c_get = FFI::MemoryPointer.new(:float, 1)
|
||||||
CBindings.call(:bind_get_buttonstatus, id, c_get, mode)
|
CBindings.call(:bind_macro_button_get_status, id, c_get, mode)
|
||||||
c_get.read_float.to_i
|
c_get.read_float.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_buttonstatus(id, state, mode)
|
def set_buttonstatus(id, state, mode)
|
||||||
CBindings.call(:bind_set_buttonstatus, id, state, mode)
|
CBindings.call(:bind_macro_button_set_status, id, state, mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_level(type_, index)
|
def get_level(type_, index)
|
||||||
@ -125,9 +125,9 @@ module Voicemeeter
|
|||||||
raise VMError.new("dir got: #{dir}, expected in or out")
|
raise VMError.new("dir got: #{dir}, expected in or out")
|
||||||
end
|
end
|
||||||
if dir == :in
|
if dir == :in
|
||||||
CBindings.call(:bind_get_num_indevices, exp: ->(x) { x >= 0 })
|
CBindings.call(:bind_input_get_device_number, exp: ->(x) { x >= 0 })
|
||||||
else
|
else
|
||||||
CBindings.call(:bind_get_num_outdevices, exp: ->(x) { x >= 0 })
|
CBindings.call(:bind_output_get_device_number, exp: ->(x) { x >= 0 })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -139,9 +139,21 @@ module Voicemeeter
|
|||||||
cname = FFI::MemoryPointer.new(:string, 256, true)
|
cname = FFI::MemoryPointer.new(:string, 256, true)
|
||||||
chwid = FFI::MemoryPointer.new(:string, 256, true)
|
chwid = FFI::MemoryPointer.new(:string, 256, true)
|
||||||
if dir == :in
|
if dir == :in
|
||||||
CBindings.call(:bind_get_desc_indevices, index, ctype, cname, chwid)
|
CBindings.call(
|
||||||
|
:bind_input_get_device_desc_a,
|
||||||
|
index,
|
||||||
|
ctype,
|
||||||
|
cname,
|
||||||
|
chwid
|
||||||
|
)
|
||||||
else
|
else
|
||||||
CBindings.call(:bind_get_desc_outdevices, index, ctype, cname, chwid)
|
CBindings.call(
|
||||||
|
:bind_output_get_device_desc_a,
|
||||||
|
index,
|
||||||
|
ctype,
|
||||||
|
cname,
|
||||||
|
chwid
|
||||||
|
)
|
||||||
end
|
end
|
||||||
[cname.read_string, ctype.read_long, chwid.read_string]
|
[cname.read_string, ctype.read_long, chwid.read_string]
|
||||||
end
|
end
|
||||||
@ -182,7 +194,7 @@ module Voicemeeter
|
|||||||
|
|
||||||
def apply_config(name)
|
def apply_config(name)
|
||||||
apply(self.configs[name])
|
apply(self.configs[name])
|
||||||
logger.info("profile #{name} applied!")
|
logger.info "profile #{name} applied!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require_relative "install"
|
require_relative "install"
|
||||||
require_relative "errors"
|
require_relative "errors"
|
||||||
|
require_relative "core_extensions/string/snakecase"
|
||||||
|
|
||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
module CBindings
|
module CBindings
|
||||||
@ -14,76 +15,42 @@ module Voicemeeter
|
|||||||
)
|
)
|
||||||
ffi_convention :stdcall
|
ffi_convention :stdcall
|
||||||
|
|
||||||
attach_function :bind_login, :VBVMR_Login, [], :long
|
def self.attach_function(c_name, args, returns)
|
||||||
attach_function :bind_logout, :VBVMR_Logout, [], :long
|
ruby_name = "bind_#{c_name.to_s.delete_prefix("VBVMR_").snakecase}".to_sym
|
||||||
attach_function :bind_runvm, :VBVMR_RunVoicemeeter, [:long], :long
|
super(ruby_name, c_name, args, returns)
|
||||||
attach_function :bind_type, :VBVMR_GetVoicemeeterType, [:pointer], :long
|
end
|
||||||
attach_function :bind_version,
|
|
||||||
:VBVMR_GetVoicemeeterVersion,
|
|
||||||
[:pointer],
|
|
||||||
:long
|
|
||||||
|
|
||||||
attach_function :bind_mdirty, :VBVMR_MacroButton_IsDirty, [], :long
|
attach_function :VBVMR_Login, [], :long
|
||||||
attach_function :bind_get_buttonstatus,
|
attach_function :VBVMR_Logout, [], :long
|
||||||
:VBVMR_MacroButton_GetStatus,
|
attach_function :VBVMR_RunVoicemeeter, [:long], :long
|
||||||
%i[long pointer long],
|
attach_function :VBVMR_GetVoicemeeterType, [:pointer], :long
|
||||||
:long
|
attach_function :VBVMR_GetVoicemeeterVersion, [:pointer], :long
|
||||||
attach_function :bind_set_buttonstatus,
|
attach_function :VBVMR_MacroButton_IsDirty, [], :long
|
||||||
:VBVMR_MacroButton_SetStatus,
|
attach_function :VBVMR_MacroButton_GetStatus, %i[long pointer long], :long
|
||||||
%i[long float long],
|
attach_function :VBVMR_MacroButton_SetStatus, %i[long float long], :long
|
||||||
:long
|
|
||||||
|
|
||||||
attach_function :bind_pdirty, :VBVMR_IsParametersDirty, [], :long
|
attach_function :VBVMR_IsParametersDirty, [], :long
|
||||||
attach_function :bind_get_parameter_float,
|
attach_function :VBVMR_GetParameterFloat, %i[string pointer], :long
|
||||||
:VBVMR_GetParameterFloat,
|
attach_function :VBVMR_SetParameterFloat, %i[string float], :long
|
||||||
%i[string pointer],
|
|
||||||
:long
|
|
||||||
attach_function :bind_set_parameter_float,
|
|
||||||
:VBVMR_SetParameterFloat,
|
|
||||||
%i[string float],
|
|
||||||
:long
|
|
||||||
|
|
||||||
attach_function :bind_get_parameter_string,
|
attach_function :VBVMR_GetParameterStringA, %i[string pointer], :long
|
||||||
:VBVMR_GetParameterStringA,
|
attach_function :VBVMR_SetParameterStringA, %i[string string], :long
|
||||||
%i[string pointer],
|
|
||||||
:long
|
|
||||||
attach_function :bind_set_parameter_string,
|
|
||||||
:VBVMR_SetParameterStringA,
|
|
||||||
%i[string string],
|
|
||||||
:long
|
|
||||||
|
|
||||||
attach_function :bind_set_parameter_multi,
|
attach_function :VBVMR_SetParameters, [:string], :long
|
||||||
:VBVMR_SetParameters,
|
|
||||||
[:string],
|
|
||||||
:long
|
|
||||||
|
|
||||||
attach_function :bind_get_level,
|
attach_function :VBVMR_GetLevel, %i[long long pointer], :long
|
||||||
:VBVMR_GetLevel,
|
|
||||||
%i[long long pointer],
|
|
||||||
:long
|
|
||||||
|
|
||||||
attach_function :bind_get_num_indevices,
|
attach_function :VBVMR_Input_GetDeviceNumber, [], :long
|
||||||
:VBVMR_Input_GetDeviceNumber,
|
attach_function :VBVMR_Input_GetDeviceDescA,
|
||||||
[],
|
|
||||||
:long
|
|
||||||
attach_function :bind_get_desc_indevices,
|
|
||||||
:VBVMR_Input_GetDeviceDescA,
|
|
||||||
%i[long pointer pointer pointer],
|
%i[long pointer pointer pointer],
|
||||||
:long
|
:long
|
||||||
|
|
||||||
attach_function :bind_get_num_outdevices,
|
attach_function :VBVMR_Output_GetDeviceNumber, [], :long
|
||||||
:VBVMR_Output_GetDeviceNumber,
|
attach_function :VBVMR_Output_GetDeviceDescA,
|
||||||
[],
|
|
||||||
:long
|
|
||||||
attach_function :bind_get_desc_outdevices,
|
|
||||||
:VBVMR_Output_GetDeviceDescA,
|
|
||||||
%i[long pointer pointer pointer],
|
%i[long pointer pointer pointer],
|
||||||
:long
|
:long
|
||||||
|
|
||||||
attach_function :bind_get_midi_message,
|
attach_function :VBVMR_GetMidiMessage, %i[pointer long], :long
|
||||||
:VBVMR_GetMidiMessage,
|
|
||||||
%i[pointer long],
|
|
||||||
:long
|
|
||||||
|
|
||||||
def call(fn, *args, ok: [0], exp: nil)
|
def call(fn, *args, ok: [0], exp: nil)
|
||||||
res = send(fn, *args)
|
res = send(fn, *args)
|
||||||
|
Loading…
Reference in New Issue
Block a user