Class: Voicemeeter::BusLevels

Inherits:
Object
  • Object
show all
Includes:
IRemote
Defined in:
lib/voicemeeter/bus.rb

Instance Method Summary collapse

Methods included from IRemote

#apply, #to_s

Methods included from Logging

#logger

Constructor Details

#initialize(remote, i) ⇒ BusLevels

Returns a new instance of BusLevels.



85
86
87
88
89
# File 'lib/voicemeeter/bus.rb', line 85

def initialize(remote, i)
  super
  @init = i * 8
  @offset = 8
end

Instance Method Details

#allObject



106
107
108
# File 'lib/voicemeeter/bus.rb', line 106

def all
  getter(Mixins::LevelEnum::BUS)
end

#getter(mode) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'lib/voicemeeter/bus.rb', line 95

def getter(mode)
  convert = ->(x) { (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }

  vals = if @remote.running? && @remote.event.ldirty
    @remote.cache[:bus_level][@init, @offset]
  else
    (@init...@init + @offset).map { |i| @remote.get_level(mode, i) }
  end
  vals.map(&convert)
end

#identifierObject



91
92
93
# File 'lib/voicemeeter/bus.rb', line 91

def identifier
  "bus[#{@index}]"
end

#isdirty?Boolean

Returns:

  • (Boolean)


110
# File 'lib/voicemeeter/bus.rb', line 110

def isdirty? = @remote.cache[:bus_comp][@init, @offset].any?