decode method

(int, int) decode(
  1. String value
)

Implementation

(int, int) decode(String value) {
  final bytes = hex.decode(value);

  if (bytes.first == 0) {
    return (0, 0);
  }

  final firstByte = bytes[0];
  final secondByte = bytes[1] << 8;
  final encoded = firstByte + secondByte;
  final period = 2 << (encoded % (1 << 4));
  final quantizeFactor = max(period >> 12, 1);
  final phase = (encoded >> 4) * quantizeFactor;

  return (phase, period);
}