sampleToInt function

int sampleToInt(
  1. double x,
  2. int bits
)

Converts an audio sample x in the range -1, 1 to an unsigned integer of bit width bits.

Implementation

int sampleToInt(double x, int bits) =>
    clamp(((x + 1) * _writeScale(bits)).floor(), (1 << bits) - 1);