Module: Digiproc::CoreExtensions::MathExtension::Decible
- Defined in:
- lib/extensions/core_extensions.rb
Overview
Add methods which are useful when using decible values
Instance Method Summary collapse
-
#db(value) ⇒ Object
db(numeric_input [Numeric]) # => returns 20 * Math.log(numeric_input, 10).
-
#db_power(value) ⇒ Object
db_power(numeric_input [Numeric]) # => returns 10 * Math.log(numeric_input, 10).
-
#mag_from_db(decible) ⇒ Object
input a decible, recieve a magnitude.
-
#power_from_db(decible) ⇒ Object
Input a decible, recieve a magnitude (power).
Instance Method Details
#db(value) ⇒ Object
db(numeric_input [Numeric]) # => returns 20 * Math.log(numeric_input, 10)
54 55 56 |
# File 'lib/extensions/core_extensions.rb', line 54 def db(value) 20 * Math.log(value, 10) end |
#db_power(value) ⇒ Object
db_power(numeric_input [Numeric]) # => returns 10 * Math.log(numeric_input, 10)
60 61 62 |
# File 'lib/extensions/core_extensions.rb', line 60 def db_power(value) 10 * Math.log(value, 10) end |
#mag_from_db(decible) ⇒ Object
input a decible, recieve a magnitude
66 67 68 |
# File 'lib/extensions/core_extensions.rb', line 66 def mag_from_db(decible) 10 ** (decible / 20.0) end |
#power_from_db(decible) ⇒ Object
Input a decible, recieve a magnitude (power)
72 73 74 |
# File 'lib/extensions/core_extensions.rb', line 72 def power_from_db(decible) 10 ** (decible / 10.0) end |