From 347dca55bb25f61a0cd2d2b45529944da764e734 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Sun, 15 Apr 2018 14:09:41 +0200 Subject: add more sample types --- src/adlmidi_private.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 271bc5e..b60c7c0 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -153,6 +153,32 @@ inline int32_t adl_cvtS8(int32_t x) { return adl_cvtS16(x) / 256; } +inline int32_t adl_cvtS24(int32_t x) +{ + return adl_cvtS16(x) * 256; +} +inline int32_t adl_cvtS32(int32_t x) +{ + return adl_cvtS16(x) * 65536; +} +inline int32_t adl_cvtU16(int32_t x) +{ + return adl_cvtS16(x) - INT16_MIN; +} +inline int32_t adl_cvtU8(int32_t x) +{ + return adl_cvtS8(x) - INT8_MIN; +} +inline int32_t adl_cvtU24(int32_t x) +{ + enum { int24_min = -(1 << 23) }; + return adl_cvtS24(x) - int24_min; +} +inline int32_t adl_cvtU32(int32_t x) +{ + // unsigned operation because overflow on signed integers is undefined + return (uint32_t)adl_cvtS32(x) - (uint32_t)INT32_MIN; +} /* Smart pointer for C heaps, created with malloc() call. -- cgit v1.2.3