mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-15 15:00:46 +00:00
run files through standard
This commit is contained in:
parent
91253385e6
commit
e3b72b9c45
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"standardRuby.commandPath": "C:\\Ruby32-x64\\bin\\standardrb.bat"
|
||||
}
|
@ -8,6 +8,7 @@ require "easy_logging"
|
||||
|
||||
module Voicemeeter
|
||||
class Base
|
||||
include EasyLogging
|
||||
include Worker
|
||||
include Events::Callbacks
|
||||
|
||||
@ -25,10 +26,9 @@ module Voicemeeter
|
||||
Events::Tracker.new(
|
||||
**(kwargs.select { |k, _| %i[pdirty mdirty ldirty midi].include? k })
|
||||
)
|
||||
@callbacks = Array.new
|
||||
@running = false
|
||||
@callbacks = []
|
||||
@que = Queue.new
|
||||
@cache = { strip_mode: 0 }
|
||||
@cache = {strip_mode: 0}
|
||||
end
|
||||
|
||||
def to_s
|
||||
@ -36,7 +36,7 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def login
|
||||
self.runvm if CBindings.call(:bind_login, ok: [0, 1]) == 1
|
||||
runvm if CBindings.call(:bind_login, ok: [0, 1]) == 1
|
||||
clear_dirty
|
||||
logger.info "Successfully logged into #{self} version #{version}"
|
||||
if event.any?
|
||||
@ -79,7 +79,7 @@ module Voicemeeter
|
||||
kinds = {
|
||||
basic: Kinds::KindEnum::BASIC,
|
||||
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_run_voicemeeter, kinds[kind.name])
|
||||
sleep(1)
|
||||
|
@ -11,13 +11,8 @@ module Voicemeeter
|
||||
attr_reader :eq, :mode, :levels
|
||||
|
||||
def self.make(remote, i)
|
||||
"
|
||||
Factory function for Bus classes.
|
||||
|
||||
Returns a PhysicalBus or VirtualBus class
|
||||
"
|
||||
p_out = remote.kind.phys_out
|
||||
i < p_out ? PhysicalBus.new(remote, i) : VirtualBus.new(remote, i)
|
||||
(i < p_out) ? PhysicalBus.new(remote, i) : VirtualBus.new(remote, i)
|
||||
end
|
||||
|
||||
def initialize(remote, i)
|
||||
@ -88,12 +83,12 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def getter(mode)
|
||||
if @remote.running && @remote.event.ldirty
|
||||
vals = @remote.cache[:bus_level][@init, @offset]
|
||||
vals = if @remote.running && @remote.event.ldirty
|
||||
@remote.cache[:bus_level][@init, @offset]
|
||||
else
|
||||
vals = (@init...@init + @offset).map { |i| @remote.get_level(mode, i) }
|
||||
(@init...@init + @offset).map { |i| @remote.get_level(mode, i) }
|
||||
end
|
||||
vals.map { |x| x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
||||
vals.map { |x| (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
||||
end
|
||||
|
||||
def all
|
||||
|
@ -1,3 +1,5 @@
|
||||
require "easy_logging"
|
||||
|
||||
module Voicemeeter
|
||||
module Events
|
||||
module Callbacks
|
||||
@ -16,13 +18,15 @@ module Voicemeeter
|
||||
if callback.respond_to? :on_update
|
||||
callback.on_update { event.to_s[3..] }
|
||||
else
|
||||
callback.call if callback.name == event
|
||||
callback.call # if callback == event
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Tracker
|
||||
include EasyLogging
|
||||
|
||||
attr_reader :pdirty, :mdirty, :midi, :ldirty
|
||||
|
||||
def initialize(pdirty: false, mdirty: false, midi: false, ldirty: false)
|
||||
@ -33,15 +37,15 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{self.class.name.split("::").last}"
|
||||
self.class.name.split("::").last.to_s
|
||||
end
|
||||
|
||||
def info(msg = nil)
|
||||
info_msg = msg ? ["#{msg} events."] : []
|
||||
if any?
|
||||
info_msg += ["Now listening for #{get.join(", ")} events"]
|
||||
info_msg += if any?
|
||||
["Now listening for #{get.join(", ")} events"]
|
||||
else
|
||||
info_msg += ["Not listening for any events"]
|
||||
["Not listening for any events"]
|
||||
end
|
||||
logger.info(info_msg.join(" "))
|
||||
end
|
||||
@ -67,7 +71,7 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def get
|
||||
%w[pdirty mdirty midi ldirty].reject { |ev| !send("#{ev}") }
|
||||
%w[pdirty mdirty midi ldirty].reject { |ev| !send(ev.to_s) }
|
||||
end
|
||||
|
||||
def any?
|
||||
|
@ -13,6 +13,7 @@ module Voicemeeter
|
||||
que << :ldirty if event.ldirty
|
||||
sleep(@ratelimit)
|
||||
end
|
||||
logger.debug("closing producer thread")
|
||||
que << :stop
|
||||
end
|
||||
end
|
||||
@ -25,8 +26,8 @@ module Voicemeeter
|
||||
loop do
|
||||
e_from_que = @que.pop
|
||||
if e_from_que == :stop
|
||||
logger.debug("closing worker thread")
|
||||
break
|
||||
logger.debug("closing #{self} thread")
|
||||
end
|
||||
on_event :on_pdirty if e_from_que == :pdirty && pdirty?
|
||||
on_event :on_mdirty if e_from_que == :mdirty && mdirty?
|
||||
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path("lib/voicemeeter/version", __dir__)
|
||||
lib = File.expand_path("./lib")
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "voicemeeter"
|
||||
@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
|
||||
spec.add_runtime_dependency "ffi", "~> 1.9", ">= 1.9.10"
|
||||
spec.add_runtime_dependency "easy_logging", "~> 0.4.0"
|
||||
spec.add_development_dependency "rspec", "~> 3.4"
|
||||
spec.add_development_dependency "standard", "~> 1.30"
|
||||
spec.required_ruby_version = ">= 3.0"
|
||||
spec.metadata = {
|
||||
"source_code_uri" => "https://github.com/onyx-and-iris/voicemeeter-rb.git"
|
||||
|
Loading…
Reference in New Issue
Block a user