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