mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 18:00:48 +00:00
command class implemented
This commit is contained in:
parent
ecdf9fa4cc
commit
2f93fc14f9
36
lib/voicemeeter/command.rb
Normal file
36
lib/voicemeeter/command.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
require_relative "iremote"
|
||||||
|
require_relative "meta"
|
||||||
|
|
||||||
|
module Voicemeeter
|
||||||
|
class Command < IRemote
|
||||||
|
def initialize(remote)
|
||||||
|
super
|
||||||
|
make_action_method :show, :restart, :shutdown
|
||||||
|
make_writer_bool :showvbanchat, :lock
|
||||||
|
end
|
||||||
|
|
||||||
|
def identifier
|
||||||
|
:command
|
||||||
|
end
|
||||||
|
|
||||||
|
def hide
|
||||||
|
setter("show", 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
def load(value)
|
||||||
|
raise VMError.new("load got: #{value}, but expected a string") unless value.is_a? String
|
||||||
|
setter("load", value)
|
||||||
|
sleep(0.2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def save(value)
|
||||||
|
raise VMError.new("save got: #{value}, but expected a string") unless value.is_a? String
|
||||||
|
setter("save", value)
|
||||||
|
sleep(0.2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset
|
||||||
|
@remote.apply_config(:reset)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -49,6 +49,14 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
# writer methods
|
# writer methods
|
||||||
|
def make_writer_bool(*params)
|
||||||
|
params.each do |param|
|
||||||
|
define_singleton_method("#{param}=") do |value|
|
||||||
|
setter(param, value && 1 || 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def make_writer_string(*params)
|
def make_writer_string(*params)
|
||||||
params.each do |param|
|
params.each do |param|
|
||||||
define_singleton_method("#{param}=") { |value| setter(param, value) }
|
define_singleton_method("#{param}=") { |value| setter(param, value) }
|
||||||
|
@ -5,6 +5,7 @@ require_relative "strip"
|
|||||||
require_relative "bus"
|
require_relative "bus"
|
||||||
require_relative "button"
|
require_relative "button"
|
||||||
require_relative "vban"
|
require_relative "vban"
|
||||||
|
require_relative "command"
|
||||||
require_relative "recorder"
|
require_relative "recorder"
|
||||||
require_relative "configs"
|
require_relative "configs"
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ module Voicemeeter
|
|||||||
private
|
private
|
||||||
|
|
||||||
class Remote < Base
|
class Remote < Base
|
||||||
attr_reader :strip, :bus, :button, :vban, :recorder
|
attr_reader :strip, :bus, :button, :vban, :command, :recorder
|
||||||
|
|
||||||
def initialize(kind, **kwargs)
|
def initialize(kind, **kwargs)
|
||||||
super
|
super
|
||||||
@ -21,6 +22,7 @@ module Voicemeeter
|
|||||||
@bus = (0...kind.num_bus).map { |i| Bus::Bus.make(self, i) }
|
@bus = (0...kind.num_bus).map { |i| Bus::Bus.make(self, i) }
|
||||||
@button = (0...kind.num_buttons).map { |i| Button::Button.new(self, i) }
|
@button = (0...kind.num_buttons).map { |i| Button::Button.new(self, i) }
|
||||||
@vban = Vban::Vban.new(self)
|
@vban = Vban::Vban.new(self)
|
||||||
|
@command = Command.new(self)
|
||||||
@recorder = Recorder::Recorder.new(self)
|
@recorder = Recorder::Recorder.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ module Voicemeeter
|
|||||||
def run
|
def run
|
||||||
login
|
login
|
||||||
|
|
||||||
yield if block_given?
|
yield(self) if block_given?
|
||||||
|
|
||||||
logout
|
logout
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user