diff --git a/lib/voicemeeter/bus.rb b/lib/voicemeeter/bus.rb index 72906bc..9adfb97 100644 --- a/lib/voicemeeter/bus.rb +++ b/lib/voicemeeter/bus.rb @@ -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 diff --git a/lib/voicemeeter/strip.rb b/lib/voicemeeter/strip.rb index a46e530..2451053 100644 --- a/lib/voicemeeter/strip.rb +++ b/lib/voicemeeter/strip.rb @@ -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