20 Int24(int32_t i) : i(i) {}
21 operator int32_t() {
return i;}
23static_assert(
sizeof(Int24) == 3,
"Int24 type must be 3 bytes");
28template <
typename To,
typename From>
39inline float convert(int8_t x) {
return x / 128.f;}
41inline float convert(int16_t x) {
return x / 32768.f;}
43inline float convert(Int24 x) {
return x / 8388608.f;}
45inline float convert(int32_t x) {
return x / 2147483648.f;}
47inline float convert(int64_t x) {
return x / 9223372036854775808.f;}
52inline int8_t
convert(
float x) {
return std::min(std::llround(x * 128.f), 127LL);}
54inline int16_t
convert(
float x) {
return std::min(std::llround(x * 32768.f), 32767LL);}
56inline Int24
convert(
float x) {
return std::min(std::llround(x * 8388608.f), 8388607LL);}
58inline int32_t
convert(
float x) {
return std::min(std::llround(x * 2147483648.f), 2147483647LL);}
60inline int64_t
convert(
float x) {
return std::min(std::llround(x * 9223372036854775808.f), 9223372036854775807LL);}
64template <
typename To,
typename From>
65void convert(
const From* in, To* out,
size_t len) {
66 for (
size_t i = 0; i < len; i++) {
To convert(From x)=delete
Converts between normalized types.
struct __attribute__((packed, aligned(1), gcc_struct)) Int24
24-bit integer, using int32_t for conversions.
Definition convert.hpp:15
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9