convertBytesToInt16 method

List<int> convertBytesToInt16(
  1. Uint8List bytes, [
  2. dynamic endian = Endian.little
])

Utility method to get PCM data as signed 16 bits integers.

Implementation

List<int> convertBytesToInt16(Uint8List bytes, [endian = Endian.little]) {
  final values = <int>[];

  final data = ByteData.view(bytes.buffer);

  for (var i = 0; i < bytes.length; i += 2) {
    int short = data.getInt16(i, endian);
    values.add(short);
  }

  return values;
}