HART  0.2.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/// @brief Sets number of decimal places for values in cents (frequency deviation)
56/// @details The precision is set via `--rad-decimals` CLI argument
57/// @see CLIConfig::getRadDecimals()
58inline std::ostream& centsPrecision (std::ostream& stream)
59{
60 return stream << std::fixed << std::setprecision (CLIConfig::getInstance().getCentsDecimals());
61}
62
63/// @brief Sets number of decimal places for correlation values
64/// @note Currently is not controllev via CLI arguments
65static inline std::ostream& correlationPrecision (std::ostream& stream)
66{
67 return stream << std::fixed << std::setprecision (4);
68}
69
70/// @}
71
72} // namespace hart
std::ostream & radPrecision(std::ostream &stream)
Sets number of decimal places for values in radians.
std::ostream & centsPrecision(std::ostream &stream)
Sets number of decimal places for values in cents (frequency deviation)
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.
static std::ostream & correlationPrecision(std::ostream &stream)
Sets number of decimal places for correlation values.
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.
Holds values set by the user via CLI interface.
int getHzDecimals() const
int getCentsDecimals() const
int getSecDecimals() const
int getRadDecimals() const
int getDbDecimals() const
static CLIConfig & getInstance()
Get the singleton instance.
int getLinDecimals() const