Raffaello / sdl2-hyper-sonic-drivers

'90s sound-cards hardware emulation and files processing.
Apache License 2.0
5 stars 0 forks source link

int32_t, float 32bits #13

Open todo[bot] opened 3 years ago

todo[bot] commented 3 years ago

https://github.com/Raffaello/sdl2-sonic-drivers/blob/42a377e397cfe6e70fc779400d5664809ab983d2/sdl2-sonic-drivers/test/TestWaveGenerators.cpp#L23-L28


This issue was generated by todo based on a TODO comment in 42a377e397cfe6e70fc779400d5664809ab983d2 when #6 was merged. cc @Raffaello.
Raffaello commented 3 years ago

to process audio at float or int32_t without volume is possible with the same size type.

Raffaello commented 3 years ago

float is a problem as it is not an integer number and there are a lot of assumption of integer type being used.

this requires to change slightly the templates. something similar to:

#include <type_traits>

if constexpr (std::is_integral_v<T>) {  // constexpr only necessary on first statement
    ...
} else if (std::is_floating_point_v<T>) {  // automatically constexpr
    ...
}

could be done

Raffaello commented 3 years ago

for float type other constexpr are an issue:

template<typename T> constexpr int32_t unsigned_max = (std::numeric_limits<T>::max() - std::numeric_limits<T>::min());

as it as a int32_t return type and won't match the float type.

float type probably requires a specialization from integers....

Raffaello commented 3 years ago

int32_t introduce overflows and not easily replaceable with just int64_t for eg.