MCPcopy Create free account
hub / github.com/adamstark/AudioFile / sampleToTwentyFourBitInt

Method sampleToTwentyFourBitInt

AudioFile.h:1406–1420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1404//=============================================================
1405template <class T>
1406int32_t AudioSampleConverter<T>::sampleToTwentyFourBitInt (T sample)
1407{
1408 if constexpr (std::is_floating_point<T>::value)
1409 {
1410 sample = clamp (sample, -1., 1.);
1411 return static_cast<int32_t> (sample * static_cast<T> (8388607.));
1412 }
1413 else
1414 {
1415 if constexpr (std::is_signed_v<T>)
1416 return static_cast<int32_t> (clamp (sample, SignedInt24_Min, SignedInt24_Max));
1417 else
1418 return static_cast<int32_t> (clamp (sample, UnsignedInt24_Min, UnsignedInt24_Max) + SignedInt24_Min);
1419 }
1420}
1421
1422//=============================================================
1423template <class T>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected