feedInt16 method

Future<int> feedInt16({
  1. required List<Int16List> data,
})

Implementation

Future<int> feedInt16({required List<t.Int16List> data}) async {
  if (codec != Codec.pcm16) {
    callback!.log(
      Level.error,
      'Cannot feed with feedInt16 on a Codec <> pcm16',
    );
    throw Exception('Cannot feed with Float32 with interleaved mode');
  }
  if (interleaved) {
    callback!.log(
      Level.error,
      'Cannot feed with feedInt16 with interleaved mode',
    );
    throw Exception('Cannot feed with Float32 with interleaved mode');
  }
  if (data.length != numChannels) {
    callback!.log(
      Level.error,
      'feedFloat32() : data length (${data.length}) != the number of channels ($numChannels)',
    );
    throw Exception(
      'feedFloat32() : data length (${data.length}) != the number of channels ($numChannels)',
    );
  }
  List<JSAny> r = [];
  for (int channel = 0; channel < data.length; ++channel) {
    r.add(data[channel].toJS);
  }
  postMessage('SEND_FEED_I16', r.toJS);

  return 0;
}