tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ModifierCommon.cpp
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14namespace ModifierCommon
15{
16 double getBarFraction (RateType rt) noexcept
17 {
18 constexpr auto dot = 1.5;
19 constexpr auto triplet = 2.0 / 3.0;
20
21 switch (rt)
22 {
23 case fourBars: return 4.0;
24 case twoBars: return 2.0;
25 case bar: return 1.0;
26 case halfT: return 1.0 / 2.0 * triplet;
27 case half: return 1.0 / 2.0;
28 case halfD: return 1.0 / 2.0 * dot;
29 case quarterT: return 1.0 / 4.0 * triplet;
30 case quarter: return 1.0 / 4.0;
31 case quarterD: return 1.0 / 4.0 * dot;
32 case eighthT: return 1.0 / 8.0 * triplet;
33 case eighth: return 1.0 / 8.0;
34 case eighthD: return 1.0 / 8.0 * dot;
35 case sixteenthT: return 1.0 / 16.0 * triplet;
36 case sixteenth: return 1.0 / 16.0;
37 case sixteenthD: return 1.0 / 16.0 * dot;
38 case thirtySecondT: return 1.0 / 32.0 * triplet;
39 case thirtySecond: return 1.0 / 32.0;
40 case thirtySecondD: return 1.0 / 32.0 * dot;
41 case sixtyFourthT: return 1.0 / 64.0 * triplet;
42 case sixtyFourth: return 1.0 / 64.0;
43 case sixtyFourthD: return 1.0 / 64.0 * dot;
44 case hertz:
45 default: return 1.0;
46 };
47 }
48}
49
50}} // namespace tracktion { inline namespace engine
double getBarFraction(RateType rt) noexcept
Returns the fraction of a bar to be used for a given rate type.