#include "Range.h" /* Range16::Range16() { this->range = 0; } Range16::Range16(float f) { // clamp the float range to -1..1 if (f < -1.0F) f = -1.0F; else if (f > 1.0F) f = 1.0F; // map -1..1 to 0..65535 this->range = (unsigned short)((f + 1.0F) * 65535.0F); } Range16::Range16(short s) { // clamp the range to -32767..32767 // This is needed because the representation can support +/-32768 (like 2s // complement) if (s < -32767) s = -32767; else if (s > 32767) s = 32767; this->range = (unsigned short)(s + 32767); } Range16 Range16::operator-(Range16 a) { this->range - a.range; }; Range16 Range16::operator+(Range16 a) { this->range + a.range; }; Range16 &Range16::operator-() { -this->range; } bool Range16::operator==(Range16 a) { this->range == a.range; } bool Range16::operator!=(Range16 a) { return (this->range != a.range); } bool Range16::operator<(Range16 a) { return (this->range < a.range); } bool Range16::operator>(Range16 a) { return (this->range > a.range); } bool Range16::operator<=(Range16 a) { return (this->range <= a.range); } bool Range16::operator>=(Range16 a) { return (this->range >= a.range); } */ template <> RangeUsing::RangeUsing(float f) { this->value = (unsigned char)((f + 1.0f) * 127.0F); } template <> RangeUsing::RangeUsing(float f) { this->value = (unsigned short)((f + 1.0F) * 32767.0F); }