Logarithmics#

class ValueType(value)#

Bases: Enum

An enumeration.

LIN = 0#

Linear number.

DB = 1#

Logarithmic number.

class Logarithmic(value, value_type=ValueType.DB, conversion=DbConversionType.POWER)#

Bases: float

Representation of a logarithmic number.

Logarithmic numbers represent Decibel (dB) parameters within Hermes’ API. However, they will always act as their linear value when being interacted with, in order to preserve compatibility with any internal equation, since equations internally assume all parameters to be linear.

Note that therefore,

a = Logarithmic(10)
b = Logarithmic(20)

c = a + b
print(c)
>>> 20dB

will return in the output \(20.41392685158225\) instead of \(30\), since internally the linear representations will be summed. Instead, use the multiplication operator to sum Logarithmics, i.e.

a = Logarithmic(10)
b = Logarithmic(20)

c = a * b
print(c)
>>> 30dB
Parameters:
  • value (Union[float, int]) – Value of the logarithmic number.

  • value_type (ValueType, optional) – Assumed type of value. Decibels by default.

  • conversion (DbConversionType, optional) – Conversion of logarithmic scale. Power by default.

classmethod From_Tuple(linear, logarithmic, conversion=DbConversionType.POWER)#
Return type:

Logarithmic

property value_db: float#

Logarithmic value of represented number.

Returns: Logarithmic value.

property conversion: DbConversionType#

Logarithmic conversion type.

Returns: Conversion type.

class LogarithmicSequence(values: Sequence[float | int] | None = None, value_type: ValueType = ValueType.DB, conversion: DbConversionType = DbConversionType.POWER)#

Bases: ndarray

A sequence of logarithmic numbers.

Parameters:
  • values (Sequence[Union[float, int]], optional) – Initial content of the represented sequence. If not provided, the sequence will be initialized as empty.

  • value_type (ValueType, optional) – Assumed type of value. Decibels by default.

  • conversion (DbConversionType, optional) – Conversion of logarithmic scale. Power by default.

property conversion: DbConversionType#

Logarithmic conversion type.

Returns: Conversion type.

tolist()#

Convert to list representation.

Returns: List of logarithmics.

Return type:

List[Logarithmic]

dB(*values, conversion=DbConversionType.POWER)#

Represent scalar value as logarithmic number.

Parameters:
  • *values (Tuple[Union[int, float]]) – Value or sequence of values to be represented as logarithmic.

  • conversion (DbConversionType, optional) – Conversion of logarithmic scale. Power by default.

Return type:

Union[Logarithmic, LogarithmicSequence]

Returns: The logarithmic representation of *values.