| AAX SDK 2.8.0 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_SampleRateUtils.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 * Copyright 2009-2015, 2023-2024 Avid Technology, Inc.
4 * All rights reserved.
5 *
6 * This file is part of the Avid AAX SDK.
7 *
8 * The AAX SDK is subject to commercial or open-source licensing.
9 *
10 * By using the AAX SDK, you agree to the terms of both the Avid AAX SDK License
11 * Agreement and Avid Privacy Policy.
12 *
13 * AAX SDK License: https://developer.avid.com/aax
14 * Privacy Policy: https://www.avid.com/legal/privacy-policy-statement
15 *
16 * Or: You may also use this code under the terms of the GPL v3 (see
17 * www.gnu.org/licenses).
18 *
19 * THE AAX SDK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 * EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 * DISCLAIMED.
22 */
23
30/*================================================================================================*/
31#pragma once
32
33 enum ESRUtils
34{
35 eSRUtils_48kRangeCoarse = 48000,
36 eSRUtils_96kRangeCoarse = 96000,
37 eSRUtils_192kRangeCoarse = 192000,
38 eSRUtils_48kRangeMin = 0,
39 eSRUtils_48kRangeMax = 51000,
40 eSRUtils_96kRangeMin = eSRUtils_48kRangeMax+1,
41 eSRUtils_96kRangeMax = 102000,
42 eSRUtils_192kRangeMin = eSRUtils_96kRangeMax+1,
43 eSRUtils_192kRangeMax = 204000,
44 eSRUtils_48kIndex = 0,
45 eSRUtils_96kIndex = 1,
46 eSRUtils_192kIndex = 2
47};
48
49 inline int CoarseSampleRate (int iRate)
50{
51 const int aCoarseRate =
52
53 ((iRate >= eSRUtils_48kRangeMin) && (iRate <= eSRUtils_48kRangeMax)) ? eSRUtils_48kRangeCoarse :
54 ((iRate >= eSRUtils_96kRangeMin) && (iRate <= eSRUtils_96kRangeMax)) ? eSRUtils_96kRangeCoarse :
55 ((iRate >= eSRUtils_192kRangeMin) && (iRate <= eSRUtils_192kRangeMax)) ? eSRUtils_192kRangeCoarse :
56 0;
57
58 if (aCoarseRate == 0)
59 {
60// throw std::runtime_error ("unrecognized sample rate");
61 }
62 return aCoarseRate;
63}
64
65//Returns 1 for 48k, 2 for 96k, and 4 for 192k gross samples rate.
66 inline int CoarseSampleRateFactor (int iRate)
67{
68 const int kMinCoarseSampleRate=eSRUtils_48kRangeCoarse;
69
70 int aCoarseRateFactor = CoarseSampleRate (iRate)/kMinCoarseSampleRate;
71
72 return aCoarseRateFactor;
73}
74
75//Returns 0 for 48k, 1 for 96k, and 2 for 192k gross samples rate.
76 inline int CoarseSampleRateIndex (int iRate)
77{
78// const long kMinGrossSampleRate=eSRUtils_48kRangeCoarse;
79 int aGrossRateIndex = 0;
80
81 switch ( CoarseSampleRate (iRate) )
82 {
83 default:
84 case eSRUtils_48kRangeCoarse:
85 aGrossRateIndex = 0;
86 break;
87 case eSRUtils_96kRangeCoarse:
88 aGrossRateIndex = 1;
89 break;
90 case eSRUtils_192kRangeCoarse:
91 aGrossRateIndex = 2;
92 break;
93// default:
94// throw std::runtime_error ("unrecognized sample rate");
95 }
96
97 return aGrossRateIndex;
98}
CoarseSampleRateIndex
int CoarseSampleRateIndex(int iRate)
Definition: AAX_SampleRateUtils.h:76
ESRUtils
ESRUtils
Definition: AAX_SampleRateUtils.h:34
eSRUtils_96kIndex
@ eSRUtils_96kIndex
Definition: AAX_SampleRateUtils.h:45
eSRUtils_48kRangeMax
@ eSRUtils_48kRangeMax
Definition: AAX_SampleRateUtils.h:39
eSRUtils_96kRangeCoarse
@ eSRUtils_96kRangeCoarse
Definition: AAX_SampleRateUtils.h:36
eSRUtils_192kRangeMin
@ eSRUtils_192kRangeMin
Definition: AAX_SampleRateUtils.h:42
eSRUtils_96kRangeMin
@ eSRUtils_96kRangeMin
Definition: AAX_SampleRateUtils.h:40
eSRUtils_48kIndex
@ eSRUtils_48kIndex
Definition: AAX_SampleRateUtils.h:44
eSRUtils_192kRangeMax
@ eSRUtils_192kRangeMax
Definition: AAX_SampleRateUtils.h:43
eSRUtils_96kRangeMax
@ eSRUtils_96kRangeMax
Definition: AAX_SampleRateUtils.h:41
eSRUtils_192kRangeCoarse
@ eSRUtils_192kRangeCoarse
Definition: AAX_SampleRateUtils.h:37
eSRUtils_48kRangeCoarse
@ eSRUtils_48kRangeCoarse
Definition: AAX_SampleRateUtils.h:35
eSRUtils_48kRangeMin
@ eSRUtils_48kRangeMin
Definition: AAX_SampleRateUtils.h:38
eSRUtils_192kIndex
@ eSRUtils_192kIndex
Definition: AAX_SampleRateUtils.h:46
CoarseSampleRateFactor
int CoarseSampleRateFactor(int iRate)
Definition: AAX_SampleRateUtils.h:66
CoarseSampleRate
int CoarseSampleRate(int iRate)
Definition: AAX_SampleRateUtils.h:49