class AudioStream::Decibel

Public Class Methods

create(val) click to toggle source
# File lib/audio_stream/decibel.rb, line 24
def self.create(val)
  if self===val
    val
  else
    new(db: val.to_f)
  end
end
db(db) click to toggle source
# File lib/audio_stream/decibel.rb, line 16
def self.db(db)
  new(db: db)
end
mag(mag) click to toggle source
# File lib/audio_stream/decibel.rb, line 20
def self.mag(mag)
  new(mag: mag)
end
new(db: nil, mag: nil) click to toggle source
# File lib/audio_stream/decibel.rb, line 3
def initialize(db: nil, mag: nil)
  @db = db
  @mag = mag
end

Public Instance Methods

db() click to toggle source
# File lib/audio_stream/decibel.rb, line 8
def db
  @db || 20 * Math.log10(@mag)
end
mag() click to toggle source
# File lib/audio_stream/decibel.rb, line 12
def mag
  @mag || 10 ** (@db / 20.0)
end