mirror of
				https://github.com/onyx-and-iris/voicemeeter-rb.git
				synced 2025-11-04 06:01:46 +00:00 
			
		
		
		
	run through standard
This commit is contained in:
		
							parent
							
								
									d2160535a3
								
							
						
					
					
						commit
						6ccdfafc27
					
				@ -8,17 +8,21 @@ module Voicemeeter
 | 
			
		||||
 | 
			
		||||
    extend FFI::Library
 | 
			
		||||
 | 
			
		||||
    VM_PATH = Install.get_vmpath()
 | 
			
		||||
    VM_PATH = Install.get_vmpath
 | 
			
		||||
 | 
			
		||||
    ffi_lib VM_PATH.join(
 | 
			
		||||
              "VoicemeeterRemote#{Install::OS_BITS == 64 ? "64" : "32"}.dll"
 | 
			
		||||
      "VoicemeeterRemote#{(Install::OS_BITS == 64) ? "64" : "32"}.dll"
 | 
			
		||||
    )
 | 
			
		||||
    ffi_convention :stdcall
 | 
			
		||||
 | 
			
		||||
    class << self
 | 
			
		||||
      private
 | 
			
		||||
 | 
			
		||||
      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
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    attach_function :VBVMR_Login, [], :long
 | 
			
		||||
    attach_function :VBVMR_Logout, [], :long
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ module Voicemeeter
 | 
			
		||||
 | 
			
		||||
      def initialize(kind)
 | 
			
		||||
        @kind = kind
 | 
			
		||||
        @configs = Hash.new
 | 
			
		||||
        @configs = {}
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def to_s
 | 
			
		||||
 | 
			
		||||
@ -7,17 +7,17 @@ module Voicemeeter
 | 
			
		||||
 | 
			
		||||
  # stree-ignore
 | 
			
		||||
  module Install
 | 
			
		||||
    OS_BITS = FFI::Platform::CPU.downcase == "x64" ? 64 : 32
 | 
			
		||||
    OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32
 | 
			
		||||
 | 
			
		||||
    def get_vmpath()
 | 
			
		||||
    def get_vmpath
 | 
			
		||||
      reg_key = [
 | 
			
		||||
        :Software,
 | 
			
		||||
        (OS_BITS == 64 ? :WOW6432Node : nil),
 | 
			
		||||
        ((OS_BITS == 64) ? :WOW6432Node : nil),
 | 
			
		||||
        :Microsoft,
 | 
			
		||||
        :Windows,
 | 
			
		||||
        :CurrentVersion,
 | 
			
		||||
        :Uninstall,
 | 
			
		||||
        :'VB:Voicemeeter {17359A74-1236-5467}'
 | 
			
		||||
        :"VB:Voicemeeter {17359A74-1236-5467}"
 | 
			
		||||
      ]
 | 
			
		||||
 | 
			
		||||
      Win32::Registry::HKEY_LOCAL_MACHINE.open(
 | 
			
		||||
 | 
			
		||||
@ -4,11 +4,8 @@ require "easy_logging"
 | 
			
		||||
 | 
			
		||||
module Voicemeeter
 | 
			
		||||
  class IRemote
 | 
			
		||||
    "
 | 
			
		||||
    Common interface between base class and higher classes.
 | 
			
		||||
    "
 | 
			
		||||
    include EasyLogging
 | 
			
		||||
    include Meta_Functions
 | 
			
		||||
    include MetaFunctions
 | 
			
		||||
 | 
			
		||||
    def initialize(remote, i = nil)
 | 
			
		||||
      @remote = remote
 | 
			
		||||
@ -40,20 +37,14 @@ module Voicemeeter
 | 
			
		||||
    def apply(params)
 | 
			
		||||
      params.each do |key, val|
 | 
			
		||||
        if val.is_a? Hash
 | 
			
		||||
          target = self.send(key)
 | 
			
		||||
          target = send(key)
 | 
			
		||||
          target.apply(val)
 | 
			
		||||
        elsif key == :mode
 | 
			
		||||
          mode.send("#{val}=", true)
 | 
			
		||||
        else
 | 
			
		||||
          if key == :mode
 | 
			
		||||
            self.mode.send("#{val}=", true)
 | 
			
		||||
          else
 | 
			
		||||
            self.send("#{key}=", val)
 | 
			
		||||
          send("#{key}=", val)
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
    def method_missing(method, *args)
 | 
			
		||||
      logger.debug "Unknown method #{method} for #{self}."
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -5,14 +5,22 @@ module Voicemeeter
 | 
			
		||||
    KindMap =
 | 
			
		||||
      Data.define(:name, :ins, :outs, :vban, :asio, :insert, :num_buttons) do
 | 
			
		||||
        def phys_in = ins[0]
 | 
			
		||||
 | 
			
		||||
        def virt_in = ins[1]
 | 
			
		||||
 | 
			
		||||
        def phys_out = outs[0]
 | 
			
		||||
 | 
			
		||||
        def virt_out = outs[1]
 | 
			
		||||
 | 
			
		||||
        def num_strip = ins.sum
 | 
			
		||||
 | 
			
		||||
        def num_bus = outs.sum
 | 
			
		||||
 | 
			
		||||
        def num_strip_levels = 2 * phys_in + 8 * virt_in
 | 
			
		||||
 | 
			
		||||
        def num_bus_levels = 8 * (phys_out + virt_out)
 | 
			
		||||
        def to_s = "#{name}".capitalize
 | 
			
		||||
 | 
			
		||||
        def to_s = name.to_s.capitalize
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
    basic = KindMap.new(:basic, [2, 1], [1, 1], [4, 4], [0, 0], 0, 80)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
module Voicemeeter
 | 
			
		||||
  module Meta_Functions
 | 
			
		||||
  module MetaFunctions
 | 
			
		||||
    # Accessor methods
 | 
			
		||||
    def make_accessor_bool(*params)
 | 
			
		||||
      params.each do |param|
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@ module Voicemeeter
 | 
			
		||||
    attr_accessor :cache, :current, :channel
 | 
			
		||||
 | 
			
		||||
    def initialize
 | 
			
		||||
      @cache = Hash.new
 | 
			
		||||
      @cache = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def get(key)
 | 
			
		||||
 | 
			
		||||
@ -2,12 +2,12 @@ module Voicemeeter
 | 
			
		||||
  module Mixins
 | 
			
		||||
    module Fades
 | 
			
		||||
      def fadeto(target, time)
 | 
			
		||||
        self.setter("FadeTo", "(#{target}, #{time})")
 | 
			
		||||
        setter("FadeTo", "(#{target}, #{time})")
 | 
			
		||||
        sleep(@remote.delay)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def fadeby(change, time)
 | 
			
		||||
        self.setter("FadeBy", "(#{change}, #{time})")
 | 
			
		||||
        setter("FadeBy", "(#{change}, #{time})")
 | 
			
		||||
        sleep(@remote.delay)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@ -21,11 +21,11 @@ module Voicemeeter
 | 
			
		||||
 | 
			
		||||
    module Apps
 | 
			
		||||
      def appgain(name, gain)
 | 
			
		||||
        self.setter("AppGain", "(\"#{name}\", #{gain})")
 | 
			
		||||
        setter("AppGain", "(\"#{name}\", #{gain})")
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def appmute(name, mute)
 | 
			
		||||
        self.setter("AppMute", "(\"#{name}\", #{mute ? 1 : 0})")
 | 
			
		||||
        setter("AppMute", "(\"#{name}\", #{mute ? 1 : 0})")
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -33,12 +33,12 @@ module Voicemeeter
 | 
			
		||||
      def initialize(*args)
 | 
			
		||||
        super
 | 
			
		||||
        remote, *rem = args
 | 
			
		||||
        num_A, num_B = remote.kind.outs
 | 
			
		||||
        num_a, num_b = remote.kind.outs
 | 
			
		||||
        channels =
 | 
			
		||||
          (1..(num_A + num_B)).map do |i|
 | 
			
		||||
            i <= num_A ? "A#{i}" : "B#{i - num_A}"
 | 
			
		||||
          (1..(num_a + num_b)).map do |i|
 | 
			
		||||
            (i <= num_a) ? "A#{i}" : "B#{i - num_a}"
 | 
			
		||||
          end
 | 
			
		||||
        make_accessor_bool *channels
 | 
			
		||||
        make_accessor_bool(*channels)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -38,13 +38,6 @@ module Voicemeeter
 | 
			
		||||
    public
 | 
			
		||||
 | 
			
		||||
    def self.new(kind_id, **kwargs)
 | 
			
		||||
      "
 | 
			
		||||
      Factory method for remotes
 | 
			
		||||
 | 
			
		||||
      Wraps factory expression and handles errors
 | 
			
		||||
 | 
			
		||||
      Returns a Remote class of a Kind
 | 
			
		||||
      "
 | 
			
		||||
      remotes =
 | 
			
		||||
        Kinds::ALL.to_h { |kind| [kind.name, Remote.new(kind, **kwargs)] }
 | 
			
		||||
      unless remotes.key? kind_id
 | 
			
		||||
 | 
			
		||||
@ -11,13 +11,8 @@ module Voicemeeter
 | 
			
		||||
      attr_reader :gainlayer, :levels
 | 
			
		||||
 | 
			
		||||
      def self.make(remote, i)
 | 
			
		||||
        "
 | 
			
		||||
        Factory function for Strip classes.
 | 
			
		||||
 | 
			
		||||
        Returns a PhysicalStrip or VirtualStrip class
 | 
			
		||||
        "
 | 
			
		||||
        p_in = remote.kind.phys_in
 | 
			
		||||
        i < p_in ? PhysicalStrip.new(remote, i) : VirtualStrip.new(remote, i)
 | 
			
		||||
        (i < p_in) ? PhysicalStrip.new(remote, i) : VirtualStrip.new(remote, i)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def initialize(remote, i)
 | 
			
		||||
@ -190,17 +185,15 @@ module Voicemeeter
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def gain
 | 
			
		||||
        self.getter("gainlayer[#{@j}]")
 | 
			
		||||
        getter("gainlayer[#{@j}]")
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def gain=(value)
 | 
			
		||||
        self.setter("gainlayer[#{@j}]", value)
 | 
			
		||||
        setter("gainlayer[#{@j}]", value)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    class StripLevels < IRemote
 | 
			
		||||
      attr_reader :prefader, :postfader, :postmute
 | 
			
		||||
 | 
			
		||||
      def initialize(remote, i)
 | 
			
		||||
        super
 | 
			
		||||
        p_in = remote.kind.phys_in
 | 
			
		||||
@ -219,13 +212,12 @@ module Voicemeeter
 | 
			
		||||
 | 
			
		||||
      def get_level(mode)
 | 
			
		||||
        @remote.cache[:strip_mode] = mode
 | 
			
		||||
        if @remote.running && @remote.event.ldirty
 | 
			
		||||
          vals = @remote.cache[:strip_level][@init, @offset]
 | 
			
		||||
        vals = if @remote.running && @remote.event.ldirty
 | 
			
		||||
          @remote.cache[:strip_level][@init, @offset]
 | 
			
		||||
        else
 | 
			
		||||
          vals =
 | 
			
		||||
          (@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 prefader
 | 
			
		||||
 | 
			
		||||
@ -5,9 +5,6 @@ require_relative "errors"
 | 
			
		||||
module Voicemeeter
 | 
			
		||||
  module Vban
 | 
			
		||||
    class VbanStream < IRemote
 | 
			
		||||
      "
 | 
			
		||||
      A class representing a VBAN stream
 | 
			
		||||
      "
 | 
			
		||||
      def initialize(remote, i)
 | 
			
		||||
        super
 | 
			
		||||
        make_accessor_bool :on
 | 
			
		||||
@ -25,9 +22,6 @@ module Voicemeeter
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    class VbanInstream < VbanStream
 | 
			
		||||
      "
 | 
			
		||||
      A subclass representing a VBAN Instream
 | 
			
		||||
      "
 | 
			
		||||
      def initialize(remote, i)
 | 
			
		||||
        super
 | 
			
		||||
        make_reader_int :sr, :channel, :bit
 | 
			
		||||
@ -39,9 +33,6 @@ module Voicemeeter
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    class VbanOutstream < VbanStream
 | 
			
		||||
      "
 | 
			
		||||
      A subclass representing a VBAN Outstream
 | 
			
		||||
      "
 | 
			
		||||
      def initialize(remote, i)
 | 
			
		||||
        super
 | 
			
		||||
        make_accessor_int :sr, :channel, :bit
 | 
			
		||||
@ -56,11 +47,6 @@ module Voicemeeter
 | 
			
		||||
      attr_reader :instream, :outstream
 | 
			
		||||
 | 
			
		||||
      def initialize(remote)
 | 
			
		||||
        "
 | 
			
		||||
        Initializes a Vban class
 | 
			
		||||
 | 
			
		||||
        Creates an array for each in/out stream and sets as class attributes
 | 
			
		||||
        "
 | 
			
		||||
        vban_in, vban_out = remote.kind.vban
 | 
			
		||||
        @instream = []
 | 
			
		||||
        vban_in.times { |i| @instream << VbanInstream.new(remote, i) }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user