encode method

dynamic encode(
  1. int phase,
  2. int period
)

Implementation

encode(int phase, int period) {
  if (phase == 0 && period == 0) {
    return '00';
  }

  final quantizeFactor = max(period >> 12, 1);
  final encoded = min(15, max(1, _getTrailingZeros(period) - 1)) |
      (phase ~/ quantizeFactor << 4);

  return hex.encode(_littleIntToUint8List(encoded, 2));
}