serializeBytes method

ByteData serializeBytes(
  1. int sampleRate,
  2. double tempo,
  3. int correctionFrames
)

Implementation

ByteData serializeBytes(int sampleRate, double tempo, int correctionFrames) {
  final data = ByteData(SCHEDULER_EVENT_SIZE);
  final us = ((1 / tempo) * beat * 60000000).round();
  final frame = ((us * sampleRate) / 1000000).round() + correctionFrames;

  data.setUint32(0, frame, Endian.host);
  data.setUint32(4, type, Endian.host);

  return data;
}