MCPcopy Create free account
hub / github.com/davy7125/polyphone / floatToInt24

Method floatToInt24

sources/core/utils.cpp:232–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232qint32 Utils::floatToInt24(float f)
233{
234 // Limit the input
235 if (f > 1.0f)
236 f = 1.0f;
237 else if (f < -1.0f)
238 f = -1.0f;
239
240 f = f * 8388607.5f /*(.5f + 0x7FFFFF)*/ - .5f;
241 qint32 result = static_cast<qint32>(f + (f > 0 ? 0.5f : -0.5f));
242
243 // Limit the output
244 if (result > 8388607)
245 return 8388607;
246 else if (result < -8388608)
247 return -8388608;
248
249 return result;
250}
251
252float Utils::int24ToFloat(qint32 i)
253{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected