32 jassert (value >= 0 && value <= 127);
35 :
int (
jmap<float> (
float (value - 64), 0.0f, 63.0f, 0.0f, 8191.0f)) + 8192;
42 jassert (value >= 0 && value <= 16383);
48 jassert (0.0f <= value && value <= 1.0f);
54 jassert (-1.0f <= value && value <= 1.0f);
55 return {
roundToInt (((value + 1.0f) * 16383.0f) / 2.0f) };
65 return normalisedValue >> 7;
70 return normalisedValue;
76 return (normalisedValue < 8192)
77 ?
jmap<float> (
float (normalisedValue), 0.0f, 8192.0f, -1.0f, 0.0f)
78 :
jmap<float> (
float (normalisedValue), 8192.0f, 16383.0f, 0.0f, 1.0f);
83 return jmap<float> (
float (normalisedValue), 0.0f, 16383.0f, 0.0f, 1.0f);
89 return normalisedValue ==
other.normalisedValue;
94 return ! operator== (
other);
109 void runTest()
override
111 beginTest (
"comparison operator");
118 expect (
value1 == value2);
122 beginTest (
"special values");
134 beginTest (
"zero/minimum value");
142 beginTest (
"maximum value");
150 beginTest (
"centre value");
158 beginTest (
"value halfway between min and centre");
This class represents a single value for any of the MPE dimensions of control.
float asSignedFloat() const noexcept
Retrieves the current value mapped to a float between -1.0f and 1.0f.
static MPEValue maxValue() noexcept
Constructs an MPEValue corresponding to the maximum value.
static MPEValue centreValue() noexcept
Constructs an MPEValue corresponding to the centre value.
static MPEValue from14BitInt(int value) noexcept
Constructs an MPEValue from an integer between 0 and 16383 (using 14-bit precision).
bool operator==(const MPEValue &other) const noexcept
Returns true if two values are equal.
static MPEValue fromUnsignedFloat(float value) noexcept
Constructs an MPEValue from a float between 0.0f and 1.0f.
static MPEValue fromSignedFloat(float value) noexcept
Constructs an MPEValue from a float between -1.0f and 1.0f.
static MPEValue minValue() noexcept
Constructs an MPEValue corresponding to the minimum value.
float asUnsignedFloat() const noexcept
Retrieves the current value mapped to a float between 0.0f and 1.0f.
MPEValue() noexcept
Default constructor.
int as7BitInt() const noexcept
Retrieves the current value as an integer between 0 and 127.
int as14BitInt() const noexcept
Retrieves the current value as an integer between 0 and 16383.
static MPEValue from7BitInt(int value) noexcept
Constructs an MPEValue from an integer between 0 and 127 (using 7-bit precision).
bool operator!=(const MPEValue &other) const noexcept
Returns true if two values are not equal.
This is a base class for classes that perform a unit test.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.