-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAttenuator.h
69 lines (55 loc) · 1.76 KB
/
Attenuator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef ATTENUATOR_H
#define ATTENUATOR_H
#include <QMap>
#include <QVector>
#include <QString>
#include <QStringList>
///
/// \brief The Attenuator class.
/// Provides a list of attenuation values supported by the attenuator
/// and converts attenuation to a specific control code for the attenuator.
///
class Attenuator
{
friend class AttenuatorLoader;
private:
QMap<int, int> _attenToControlCodeMap;
QMap<int, int> _controlCodeToAttenMap;
QMap<int, int> _attenToIndexMap;
QVector<int> _attenuations;
protected:
void AddControlCode(int attenuation_db, int code);
void Clear();
public:
Attenuator();
const QVector<int> GetAttenuations();
int GetControlCode(int attenuation_db);
int GetControlCodeByIndex(int index);
int GetIndex(int attenuation_db);
int GetAttenuationByCode(int controlCode);
bool CanAttenuateBy(int attenuation_db);
int GetMaxAttenuation();
};
enum AttenuatorType
{
AttenuatorType_Standard,
AttenuatorType_Fa,
AttenuatorType_Custom,
};
class AttenuatorLoader
{
public:
void static Load(Attenuator &atten, AttenuatorType type, const QString &config);
void static LoadStandard(Attenuator &atten);
void static LoadFa(Attenuator &atten);
void static LoadCustom(Attenuator &atten, const QString &config);
bool static IsCustomConfigValid(const QString &config);
QString static GetEmptyCustomConfig();
private:
static const int _maxCustomStages;
static const int _maxStageAtten;
static const char _customStageConfigSeparator;
bool static TryParseConfig(const QString &config, QVector<int> &stages);
int static GetControlCodeByFaIndex(int index, int *attenuation_db);
};
#endif // ATTENUATOR_H