From a66c3428063017f2233b6b15d5ce6c920d5c9095 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 7 Aug 2023 14:26:04 +1000 Subject: Resampling *basically* working? Just cleanup and buffering issues --- src/codecs/include/sample.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/codecs/include') diff --git a/src/codecs/include/sample.hpp b/src/codecs/include/sample.hpp index 7209673b..f8e08cdc 100644 --- a/src/codecs/include/sample.hpp +++ b/src/codecs/include/sample.hpp @@ -52,8 +52,14 @@ constexpr auto FromMad(mad_fixed_t src) -> Sample { return FromSigned(src >> (MAD_F_FRACBITS + 1 - 24), 24); } -constexpr auto ToSigned16Bit(Sample src) -> uint16_t { +constexpr auto ToSigned16Bit(Sample src) -> int16_t { return src >> 16; } +static constexpr float kFactor = 1.0f / static_cast(INT32_MAX); + +constexpr auto ToFloat(Sample src) -> float { + return src * kFactor; +} + } // namespace sample -- cgit v1.2.3