From 89a106a9c3665ef2b428d7fffdf13020b16a5c37 Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Sun, 17 Nov 2024 10:39:32 +0100 Subject: [PATCH] FloatAudio int24 --- ...verter.ino => numberformat-converter-typed.ino} | 0 src/AudioTools/CoreAudio/AudioBasic/FloatAudio.h | 14 +++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) rename examples/tests/conversion/numberformat-converter-typed/{numberformat-converter.ino => numberformat-converter-typed.ino} (100%) diff --git a/examples/tests/conversion/numberformat-converter-typed/numberformat-converter.ino b/examples/tests/conversion/numberformat-converter-typed/numberformat-converter-typed.ino similarity index 100% rename from examples/tests/conversion/numberformat-converter-typed/numberformat-converter.ino rename to examples/tests/conversion/numberformat-converter-typed/numberformat-converter-typed.ino diff --git a/src/AudioTools/CoreAudio/AudioBasic/FloatAudio.h b/src/AudioTools/CoreAudio/AudioBasic/FloatAudio.h index 3e9b24935..78dc86863 100644 --- a/src/AudioTools/CoreAudio/AudioBasic/FloatAudio.h +++ b/src/AudioTools/CoreAudio/AudioBasic/FloatAudio.h @@ -4,7 +4,7 @@ namespace audio_tools { /*** - * A simple float number (in the range of -1.0 to 1.0) the supports the conversion to + * A simple float number (in the range of -1.0 to 1.0) that supports the conversion to * it's corresponding scaled int values. */ @@ -13,15 +13,19 @@ class FloatAudio { FloatAudio() = default; FloatAudio(float in) { this->value = in; } + inline operator float() { return value; } + explicit inline operator int8_t() { return value * 127; } explicit inline operator int16_t() { return value * 32767; } - inline operator float() { return value; } + explicit inline operator int24_3bytes_t() { + return value * 8388607; + } - // explicit inline operator int24_t() { - // return value * 8388607; - // } + explicit inline operator int24_4bytes_t() { + return value * 8388607; + } explicit inline operator int32_t() { return value * 2147483647; }