| 1457 | //============================================================= |
| 1458 | template <class T> |
| 1459 | uint8_t AudioSampleConverter<T>::sampleToUnsignedByte (T sample) |
| 1460 | { |
| 1461 | if constexpr (std::is_floating_point<T>::value) |
| 1462 | { |
| 1463 | sample = clamp (sample, -1., 1.); |
| 1464 | sample = (sample + static_cast<T> (1.)) / static_cast<T> (2.); |
| 1465 | return static_cast<uint8_t> (1 + (sample * 254)); |
| 1466 | } |
| 1467 | else |
| 1468 | { |
| 1469 | if constexpr (std::is_signed_v<T>) |
| 1470 | return static_cast<uint8_t> (clamp (sample, -128, 127) + 128); |
| 1471 | else |
| 1472 | return static_cast<uint8_t> (clamp (sample, 0, 255)); |
| 1473 | } |
| 1474 | } |
| 1475 | |
| 1476 | //============================================================= |
| 1477 | template <class T> |
nothing calls this directly
no outgoing calls
no test coverage detected