|
electro 0.3.0
Type-safe electrical units library modeled after std::chrono
|
An absolute point on a logarithmic scale, relative to a reference. More...
#include <electro/decibel.hpp>
Public Types | |
| using | reference = Reference |
| The reference tag type. | |
| using | rep = Rep |
| The representation type. | |
| using | precision = typename Precision::type |
| The offset precision, in dB, as a std::ratio. | |
| using | offset = gain< Rep, Precision > |
| The gain type measuring the offset from the reference. | |
Public Member Functions | |
| constexpr | level ()=default |
| Constructs a level at the reference point (0 dB offset). | |
| level (const level &)=default | |
| template<typename Rep2 > requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>) | |
| constexpr | level (const Rep2 &r) |
| Constructs from an offset count in dB. | |
| constexpr | level (const offset &o) |
| Constructs from an offset relative to the reference. | |
| template<typename Rep2 , typename Precision2 > requires std::convertible_to<gain<Rep2, Precision2>, offset> | |
| constexpr | level (const level< Reference, Rep2, Precision2 > &l) |
| Converts from a level with the same reference. | |
| template<typename Rep2 , typename Precision2 > requires (!std::is_same_v<level, level<Reference, Rep2, Precision2>>) && (!std::convertible_to<gain<Rep2, Precision2>, offset>) && std::constructible_from<offset, gain<Rep2, Precision2>> | |
| constexpr | level (const level< Reference, Rep2, Precision2 > &l) |
| Explicit constructor for lossy precision conversions. | |
| ~level ()=default | |
| level & | operator= (const level &)=default |
| constexpr offset | offset_from_reference () const |
| Returns the offset from the reference point. | |
| constexpr rep | count () const |
| Returns the raw offset count, in units of Precision. | |
| constexpr level | operator- () const |
| Reflects the level about its reference point. | |
| constexpr level | operator+ () const |
| constexpr level & | operator+= (const offset &o) |
| constexpr level & | operator-= (const offset &o) |
Static Public Member Functions | |
| static constexpr level | reference_level () noexcept |
| Returns the reference point itself (a 0 dB offset). | |
| static constexpr level | min () noexcept |
| Returns the minimum representable level. | |
| static constexpr level | max () noexcept |
| Returns the maximum representable level. | |
An absolute point on a logarithmic scale, relative to a reference.
The time_point analog: a level plus or minus a gain is a level, and the difference of two levels is a gain. Adding two levels, or scaling a level by a scalar, is deliberately ill-formed.
| Reference | The reference tag (milliwatt_reference, ...). |
| Rep | Arithmetic type for the offset count. |
| Precision | A std::ratio giving the offset precision, in dB. |
Definition at line 212 of file decibel.hpp.
The gain type measuring the offset from the reference.
Definition at line 223 of file decibel.hpp.
The offset precision, in dB, as a std::ratio.
Definition at line 221 of file decibel.hpp.
The reference tag type.
Definition at line 217 of file decibel.hpp.
The representation type.
Definition at line 219 of file decibel.hpp.
|
constexprdefault |
Constructs a level at the reference point (0 dB offset).
Referenced by electro::level< Reference, Rep, Precision >::max(), electro::level< Reference, Rep, Precision >::min(), electro::level< Reference, Rep, Precision >::operator-(), and electro::level< Reference, Rep, Precision >::reference_level().
|
default |
|
inlineexplicitconstexpr |
Constructs from an offset count in dB.
Always explicit: a bare number is not a level.
| Rep2 | The source representation type. |
| r | The offset from the reference, in units of Precision. |
Definition at line 239 of file decibel.hpp.
|
inlineexplicitconstexpr |
Constructs from an offset relative to the reference.
Definition at line 243 of file decibel.hpp.
|
inlineconstexpr |
Converts from a level with the same reference.
Implicit when the conversion is lossless, mirroring quantity.
Definition at line 253 of file decibel.hpp.
|
inlineexplicitconstexpr |
Explicit constructor for lossy precision conversions.
Definition at line 261 of file decibel.hpp.
|
default |
Returns the raw offset count, in units of Precision.
Definition at line 271 of file decibel.hpp.
References electro::quantity< Unit, Rep, Precision >::count().
|
inlinestaticconstexprnoexcept |
Returns the maximum representable level.
Definition at line 301 of file decibel.hpp.
References electro::level< Reference, Rep, Precision >::level(), and electro::quantity< Unit, Rep, Precision >::max().
|
inlinestaticconstexprnoexcept |
Returns the minimum representable level.
Definition at line 298 of file decibel.hpp.
References electro::level< Reference, Rep, Precision >::level(), and electro::quantity< Unit, Rep, Precision >::min().
|
inlineconstexpr |
Returns the offset from the reference point.
Definition at line 268 of file decibel.hpp.
|
inlineconstexpr |
Definition at line 282 of file decibel.hpp.
|
inlineconstexpr |
Definition at line 284 of file decibel.hpp.
References electro::treat_as_inexact_v.
|
inlineconstexpr |
Reflects the level about its reference point.
Provided so that negative literals such as -73_dBm parse. Note that std::chrono::time_point offers no such operator; a level is an absolute point, and negating one is only meaningful as "the same magnitude of
offset, on the other side of the reference".
Definition at line 281 of file decibel.hpp.
References electro::level< Reference, Rep, Precision >::level().
|
inlineconstexpr |
Definition at line 289 of file decibel.hpp.
References electro::treat_as_inexact_v.
|
default |
|
inlinestaticconstexprnoexcept |
Returns the reference point itself (a 0 dB offset).
Definition at line 295 of file decibel.hpp.
References electro::level< Reference, Rep, Precision >::level(), and electro::quantity< Unit, Rep, Precision >::zero().