encodeToBytes method

Uint8List encodeToBytes(
  1. int phase,
  2. int period
)

Implementation

Uint8List encodeToBytes(final int phase, final int period) {
  if (phase == 0 && period == 0) {
    return Uint8List.fromList([0x00]);
  }

  final quantizeFactor = max(period >> 12, 1);
  final encoded = min(15, max(1, _getTrailingZeros(period) - 1)) | (phase ~/ quantizeFactor << 4);
  return Uint8List.fromList(_littleIntToUint8List(encoded, 2));
}