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 = TYPE_BOOL; |
12 |
} |
13 |
|
14 |
void EffectControl::SetValue(float val) throw (Exception) { |
15 |
if (minValue && val < *minValue) |
16 |
throw Exception("Effect control value smaller than minimum allowed value"); |
17 |
if (maxValue && val > *maxValue) |
18 |
throw Exception("Effect control value greater than maximum allowed value"); |
19 |
value = val; |
20 |
} |
21 |
|
22 |
float& EffectControl::Value() { |
23 |
return value; |
24 |
} |
25 |
|
26 |
EffectControl::Type_t EffectControl::Type() const { |
27 |
return type; |
28 |
} |
29 |
|
30 |
String EffectControl::TypeAsString() const { |
31 |
switch (type) { |
32 |
case TYPE_FLOAT: |
33 |
return "FLOAT"; |
34 |
case TYPE_INT: |
35 |
return "INT"; |
36 |
case TYPE_BOOL: |
37 |
return "BOOL"; |
38 |
default: |
39 |
return "INVALID"; |
40 |
} |
41 |
} |
42 |
|
43 |
String EffectControl::Description() const { |
44 |
return description; |
45 |
} |
46 |
|
47 |
optional<float> EffectControl::DefaultValue() const { |
48 |
return defaultValue; |
49 |
} |
50 |
|
51 |
optional<float> EffectControl::MinValue() const { |
52 |
return minValue; |
53 |
} |
54 |
|
55 |
optional<float> EffectControl::MaxValue() const { |
56 |
return maxValue; |
57 |
} |
58 |
|
59 |
void EffectControl::SetDefaultValue(float val) { |
60 |
defaultValue = val; |
61 |
} |
62 |
|
63 |
void EffectControl::SetMinValue(float val) { |
64 |
minValue = val; |
65 |
} |
66 |
|
67 |
void EffectControl::SetMaxValue(float val) { |
68 |
maxValue = val; |
69 |
} |
70 |
|
71 |
void EffectControl::SetType(Type_t t) { |
72 |
type = t; |
73 |
} |
74 |
|
75 |
void EffectControl::SetDescription(String s) { |
76 |
description = s; |
77 |
} |
78 |
|
79 |
} // namespace LinuxSampler |