3#define INT24_MAX 8388607
4#define INT24_MIN -8388608
5#define UINT24_MAX 16777215
11 return (1.0f<sample)? 1.0f
12 : (-1.0f<sample)? sample
17MIXED_EXPORT inline float mixed_from_double(
double sample){
18 return (1.0<sample)? 1.0f
19 : (-1.0<sample)? (
float)sample
26 ? -(sample/(float)INT8_MIN)
27 : +(sample/(float)INT8_MAX);
31MIXED_EXPORT inline float mixed_from_uint8(uint8_t sample){
32 return ((
float)sample)/((float)UINT8_MAX/2)-1;
36MIXED_EXPORT inline float mixed_from_int16(int16_t sample){
38 ? -(sample/(float)INT16_MIN)
39 : +(sample/(float)INT16_MAX);
43MIXED_EXPORT inline float mixed_from_uint16(uint16_t sample){
44 return ((
float)sample)/((float)UINT16_MAX/2)-1;
56 return ((
double)sample)/((double)
UINT24_MAX/2)-1;
60MIXED_EXPORT inline float mixed_from_int32(int32_t sample){
62 ? -(sample/(double)INT32_MIN)
63 : +(sample/(double)INT32_MAX);
67MIXED_EXPORT inline float mixed_from_uint32(uint32_t sample){
68 return mixed_from_double(((
double)sample-0x80000000L)/((
double)0x80000000L));
73 return (1.0f<=sample)? 1.0f
74 : (-1.0f<=sample)? sample
80 return (1.0f<=sample)? 1.0
81 : (-1.0f<=sample)? (
double)sample
87 return (1.0f<=sample)? INT8_MAX
88 : (-1.0f<=sample)? sample*0x80
94 return (1.0f<=sample)? UINT8_MAX
95 : (-1.0f<=sample)? (sample+1)*0x80
100MIXED_EXPORT inline int16_t mixed_to_int16(
float sample){
101 return (1.0f<=sample)? INT16_MAX
102 : (-1.0f<=sample)? sample*0x8000
107MIXED_EXPORT inline uint16_t mixed_to_uint16(
float sample){
108 return (1.0f<=sample)? UINT16_MAX
109 : (-1.0f<=sample)? (sample+1)*0x8000
116 : (-1.0f<=sample)? sample*0x800000
123 : (-1.0f<=sample)? round((sample+1)*((float)
UINT24_MAX/2))
128MIXED_EXPORT inline int32_t mixed_to_int32(
float sample){
129 return (1.0f<=sample)? INT32_MAX
130 : (-1.0f<=sample)? sample*0x80000000L
135MIXED_EXPORT inline uint32_t mixed_to_uint32(
float sample){
136 return (1.0f<=sample)? UINT32_MAX
137 : (-1.0f<=sample)? (sample+1)*0x80000000L
#define MIXED_EXPORT
Definition mixed.h:22
int32_t int24_t
Definition mixed_encoding.h:6
#define INT24_MAX
Definition mixed_encoding.h:3
#define UINT24_MAX
Definition mixed_encoding.h:5
#define INT24_MIN
Definition mixed_encoding.h:4
__attribute__((always_inline)) MIXED_EXPORT inline float mixed_from_float(float sample)
Definition mixed_encoding.h:9
uint32_t uint24_t
Definition mixed_encoding.h:7