From 0e04eb918ec976017276306181282769d8896c83 Mon Sep 17 00:00:00 2001 From: ailurux Date: Thu, 11 Jan 2024 05:54:30 +0000 Subject: wav-codec (#13) here is a wav decoder, enjoy! Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/13 Reviewed-by: cooljqln Co-authored-by: ailurux Co-committed-by: ailurux --- src/codecs/include/sample.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/codecs/include/sample.hpp') diff --git a/src/codecs/include/sample.hpp b/src/codecs/include/sample.hpp index 7e550680..7b3f96a3 100644 --- a/src/codecs/include/sample.hpp +++ b/src/codecs/include/sample.hpp @@ -24,10 +24,6 @@ namespace sample { // 3. Monty from Xiph.org reckons it's all you need. typedef int16_t Sample; -constexpr auto Clip(int64_t v) -> Sample { - return std::clamp(v, INT16_MIN, INT16_MAX); -} - auto shiftWithDither(int64_t src, uint_fast8_t bits) -> Sample; constexpr auto FromSigned(int32_t src, uint_fast8_t bits) -> Sample { @@ -42,7 +38,7 @@ constexpr auto FromSigned(int32_t src, uint_fast8_t bits) -> Sample { constexpr auto FromUnsigned(uint32_t src, uint_fast8_t bits) -> Sample { // Left-align, then substract the max value / 2 to make the sample centred // around zero. - return (src << (sizeof(uint16_t) * 8 - bits)) - (~0UL >> 1); + return (src << (sizeof(uint16_t) * 8 - bits)) - (INT16_MAX+1); } constexpr auto FromFloat(float src) -> Sample { -- cgit v1.2.3