Converts an audio sample x in the range -1, 1 to an unsigned integer of bit width bits.
x
-1, 1
bits
int sampleToInt(double x, int bits) => clamp(((x + 1) * _writeScale(bits)).floor(), (1 << bits) - 1);