Skip to content

Commit

Permalink
FloatAudio int24
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 17, 2024
1 parent 3c396f8 commit 89a106a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/AudioTools/CoreAudio/AudioBasic/FloatAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand All @@ -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; }

Expand Down

0 comments on commit 89a106a

Please sign in to comment.