pass convert as block to map

This commit is contained in:
onyx-and-iris 2023-07-25 10:20:31 +01:00
parent dced3bc183
commit 53f2c1847f
2 changed files with 6 additions and 2 deletions

View File

@ -93,12 +93,14 @@ module Voicemeeter
end
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 { |x| (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
vals.map(&convert)
end
def all

View File

@ -212,13 +212,15 @@ module Voicemeeter
end
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 { |x| (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
vals.map(&convert)
end
def prefader