HART  0.1.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_precision.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iomanip>
4#include <ostream>
6
7namespace hart {
8
9/// @defgroup PrecisionManipulators Precision Manipulators
10/// @brief Stream manipulators to set decimal precision for unit-specific output
11/// @details Precision values come from CLI config (e.g. `--db-decimals`).
12/// Use like: `stream << hart::dbPrecision << myValue;`
13/// @{
14
15/// @brief Sets number of decimal places for linear (sample) values
16/// @details The precision is set via `--lin-decimals` CLI argument
17/// @see CLIConfig::getLinDecimals()
18inline std::ostream& linPrecision (std::ostream& stream)
19{
20 return stream << std::fixed << std::setprecision (CLIConfig::getInstance().getLinDecimals());
21}
22
23/// @brief Sets number of decimal places for values in decibels
24/// @details The precision is set via `--db-decimals` CLI argument
25/// @see CLIConfig::getDbDecimals()
26inline std::ostream& dbPrecision (std::ostream& stream)
27{
28 return stream << std::fixed << std::setprecision (CLIConfig::getInstance().getDbDecimals());
29}
30
31/// @brief Sets number of decimal places for values in seconds
32/// @details The precision is set via `--sec-decimals` CLI argument
33/// @see CLIConfig::getSecDecimals()
34inline std::ostream& secPrecision (std::ostream& stream)
35{
36 return stream << std::fixed << std::setprecision (CLIConfig::getInstance().getSecDecimals());
37}
38
39/// @brief Sets number of decimal places for values in hertz
40/// @details The precision is set via `--hz-decimals` CLI argument
41/// @see CLIConfig::getHzDecimals()
42inline std::ostream& hzPrecision (std::ostream& stream)
43{
44 return stream << std::fixed << std::setprecision (CLIConfig::getInstance().getHzDecimals());
45}
46
47/// @brief Sets number of decimal places for values in radians
48/// @details The precision is set via `--rad-decimals` CLI argument
49/// @see CLIConfig::getRadDecimals()
50inline std::ostream& radPrecision (std::ostream& stream)
51{
52 return stream << std::fixed << std::setprecision (CLIConfig::getInstance().getRadDecimals());
53}
54
55/// @}
56
57} // namespace hart
std::ostream & radPrecision(std::ostream &stream)
Sets number of decimal places for values in radians.
std::ostream & linPrecision(std::ostream &stream)
Sets number of decimal places for linear (sample) values.
std::ostream & secPrecision(std::ostream &stream)
Sets number of decimal places for values in seconds.
std::ostream & hzPrecision(std::ostream &stream)
Sets number of decimal places for values in hertz.
std::ostream & dbPrecision(std::ostream &stream)
Sets number of decimal places for values in decibels.
static CLIConfig & getInstance()