for (int i = size * mp->mChannels; i > 0; --i) { volatile double in = *input++; volatile double out; if (in <= -1.0) { out = -32768.0; qDebug("FromatConvertet toInt: double -> S16: input overflow %f", in); } else if (in >= 1.0) { out = 32767.0; qDebug("FromatConvertet toInt: double -> S16: input overflow %f", in); } else out = in * 32767.0; if (out > 32767.0 || out < -32768.0) qDebug("FromatConvertet toInt: double -> S16, overflow: %f -> %f, %u", in, out, mp->mDepth); *buffer++ = qToLittleEndian((qint16)floor(out)); }