encode method

Uint8List encode()

Encodes the channel layout to a Uint8List.

Implementation

Uint8List encode() {
  final int dataSize = 12 + 20 * channels.length;
  final ByteData data = ByteData(dataSize);
  data.setInt32(0, channelLayoutTag);
  data.setInt32(4, channelBitmap);
  data.setInt32(8, numberChannelDescriptions);

  int offset = 12;
  for (final ChannelDescription channel in channels) {
    final Uint8List channelData = channel.encode();
    for (int i = 0; i < 20; i++) {
      data.setUint8(offset + i, channelData[i]);
    }
    offset += 20;
  }

  return data.buffer.asUint8List();
}