1 |
/* |
2 |
Copyright (C) 2010 Christian Schoenebeck |
3 |
*/ |
4 |
|
5 |
#include "EffectControl.h" |
6 |
|
7 |
namespace LinuxSampler { |
8 |
|
9 |
EffectControl::EffectControl() { |
10 |
value = 0.0f; |
11 |
type = EFFECT_TYPE_BOOL; |
12 |
} |
13 |
|
14 |
EffectControl::~EffectControl() { |
15 |
} |
16 |
|
17 |
void EffectControl::SetValue(float val) throw (Exception) { |
18 |
if (minValue && val < *minValue) |
19 |
throw Exception("Effect control value smaller than minimum allowed value"); |
20 |
if (maxValue && val > *maxValue) |
21 |
throw Exception("Effect control value greater than maximum allowed value"); |
22 |
value = val; |
23 |
} |
24 |
|
25 |
float& EffectControl::Value() { |
26 |
return value; |
27 |
} |
28 |
|
29 |
EffectControl::Type_t EffectControl::Type() const { |
30 |
return type; |
31 |
} |
32 |
|
33 |
String EffectControl::TypeAsString() const { |
34 |
switch (type) { |
35 |
case EFFECT_TYPE_FLOAT: |
36 |
return "FLOAT"; |
37 |
case EFFECT_TYPE_INT: |
38 |
return "INT"; |
39 |
case EFFECT_TYPE_BOOL: |
40 |
return "BOOL"; |
41 |
default: |
42 |
return "INVALID"; |
43 |
} |
44 |
} |
45 |
|
46 |
String EffectControl::Description() const { |
47 |
return description; |
48 |
} |
49 |
|
50 |
optional<float> EffectControl::DefaultValue() const { |
51 |
return defaultValue; |
52 |
} |
53 |
|
54 |
optional<float> EffectControl::MinValue() const { |
55 |
return minValue; |
56 |
} |
57 |
|
58 |
optional<float> EffectControl::MaxValue() const { |
59 |
return maxValue; |
60 |
} |
61 |
|
62 |
std::vector<float> EffectControl::Possibilities() const { |
63 |
return possibilities; |
64 |
} |
65 |
|
66 |
void EffectControl::SetDefaultValue(float val) { |
67 |
defaultValue = val; |
68 |
} |
69 |
|
70 |
void EffectControl::SetMinValue(float val) { |
71 |
minValue = val; |
72 |
} |
73 |
|
74 |
void EffectControl::SetMaxValue(float val) { |
75 |
maxValue = val; |
76 |
} |
77 |
|
78 |
void EffectControl::SetPossibilities(const std::vector<float>& v) { |
79 |
possibilities = v; |
80 |
} |
81 |
|
82 |
void EffectControl::SetType(Type_t t) { |
83 |
type = t; |
84 |
} |
85 |
|
86 |
void EffectControl::SetDescription(String s) { |
87 |
description = s; |
88 |
} |
89 |
|
90 |
} // namespace LinuxSampler |