Class: Voicemeeter::Strip::StripLevels

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

Instance Method Summary collapse

Methods included from IRemote

#apply, #to_s

Methods included from Logging

#logger

Constructor Details

#initialize(remote, i) ⇒ StripLevels

Returns a new instance of StripLevels.



202
203
204
205
206
207
208
209
210
211
212
# File 'lib/voicemeeter/strip.rb', line 202

def initialize(remote, i)
  super
  p_in = remote.kind.phys_in
  if i < p_in
    @init = i * 2
    @offset = 2
  else
    @init = (p_in * 2) + ((i - p_in) * 8)
    @offset = 8
  end
end

Instance Method Details

#get_level(mode) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
# File 'lib/voicemeeter/strip.rb', line 218

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

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

#identifierObject



214
215
216
# File 'lib/voicemeeter/strip.rb', line 214

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

#isdirty?Boolean

Returns:

  • (Boolean)


242
# File 'lib/voicemeeter/strip.rb', line 242

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

#postfaderObject



234
235
236
# File 'lib/voicemeeter/strip.rb', line 234

def postfader
  get_level(Mixins::LevelEnum::POSTFADER)
end

#postmuteObject



238
239
240
# File 'lib/voicemeeter/strip.rb', line 238

def postmute
  get_level(Mixins::LevelEnum::POSTMUTE)
end

#prefaderObject



230
231
232
# File 'lib/voicemeeter/strip.rb', line 230

def prefader
  get_level(Mixins::LevelEnum::PREFADER)
end