Rename audio::convert to audio::pack and add audio::unpack
This commit is contained in:
parent
47231dfd92
commit
c4ead52fd6
1 changed files with 10 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ namespace psemek::audio
|
||||||
}
|
}
|
||||||
|
|
||||||
// maps [-1, 1] range to samples
|
// maps [-1, 1] range to samples
|
||||||
inline sample convert(float v)
|
inline sample pack(float v)
|
||||||
{
|
{
|
||||||
static auto const min = static_cast<float>(std::numeric_limits<sample>::min());
|
static auto const min = static_cast<float>(std::numeric_limits<sample>::min());
|
||||||
static auto const max = static_cast<float>(std::numeric_limits<sample>::max());
|
static auto const max = static_cast<float>(std::numeric_limits<sample>::max());
|
||||||
|
|
@ -27,4 +27,13 @@ namespace psemek::audio
|
||||||
return clamp(min + (v * 0.5f + 0.5f) * (max - min));
|
return clamp(min + (v * 0.5f + 0.5f) * (max - min));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// maps samples to [-1, 1] range
|
||||||
|
inline float unpack(sample s)
|
||||||
|
{
|
||||||
|
static auto const min = static_cast<float>(std::numeric_limits<sample>::min());
|
||||||
|
static auto const max = static_cast<float>(std::numeric_limits<sample>::max());
|
||||||
|
|
||||||
|
return 2.f * (s - min) / (max - min) - 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue