VCTR
Loading...
Searching...
No Matches
Decibels.h
1/*
2 ==============================================================================
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
5 Copyright 2022- by sonible GmbH.
6
7 This file is part of VCTR - Versatile Container Templates Reconceptualized.
8
9 VCTR is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License version 3
11 only, as published by the Free Software Foundation.
12
13 VCTR is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License version 3 for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 version 3 along with VCTR. If not, see <https://www.gnu.org/licenses/>.
20 ==============================================================================
21*/
22
23namespace vctr::detail
24{
25template <is::constant C>
26struct InvertedConstant
27{
28 static constexpr double value = 1.0 / double (C::value);
29};
30
31} // namespace vctr::detail
32
33namespace vctr::expressions
34{
35
36template <size_t extent, class SrcType, class DecibelConstant, class MinDb>
37using MagToDb = ClampByConstant<extent,
38 MultiplyVecByConstant<extent,
39 Log10<extent, SrcType>,
40 DecibelConstant>,
41 MinDb,
42 DisabledConstant>;
43
44template <size_t extent, class SrcType, class DecibelConstant>
45using DBToMag = PowConstantBase<extent,
46 MultiplyVecByConstant<extent,
47 SrcType,
48 detail::InvertedConstant<DecibelConstant>>,
49 Constant<10>>;
50
51} // namespace vctr::expressions
52
53namespace vctr
54{
55
60struct dBFS : Constant<20> {};
61
66struct dBVoltage : Constant<20> {};
67
72struct dBPower : Constant<10> {};
73
84template <is::constant DecibelConstant, auto minDb = -100>
86
96template <is::constant DecibelConstant>
98
99} // namespace vctr
Constrains the type to be a class that defines a static const value field.
Definition: GenericConcepts.h:114
constexpr ExpressionChainBuilderWithRuntimeArgs< expressions::MagToDb, detail::RuntimeArgChain< std::tuple<>, std::tuple<>, std::tuple<> >, DecibelConstant, Constant< minDb > > magToDb
Converts the source magnitude into a decibel representation.
Definition: Decibels.h:85
constexpr ExpressionChainBuilderWithRuntimeArgs< expressions::DBToMag, detail::RuntimeArgChain< std::tuple<>, std::tuple<>, std::tuple<> >, DecibelConstant > dbToMag
Converts the source decibel values into their magnitude representation.
Definition: Decibels.h:97
The main namespace of the VCTR project.
Definition: Array.h:24
A simple helper struct to pass a constant as argument wrapped in a struct with a single public static...
Definition: ExpressionChainBuilder.h:104
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:136
Decibel constant dbFS to be passed to dbToMag or magToDb.
Definition: Decibels.h:60
Decibel constant dbPower to be passed to dbToMag or magToDb.
Definition: Decibels.h:72
Decibel constant dbVoltage to be passed to dbToMag or magToDb.
Definition: Decibels.h:66