finish method

  1. @override
Blob finish()
override

Implementation

@override
web.Blob finish() {
  final dataSize = numChannels * _numSamples * 2;
  final view = ByteData(44);

  view.setString(0, 'RIFF');
  view.setUint32(4, 36 + dataSize, Endian.little);
  view.setString(8, 'WAVE');
  view.setString(12, 'fmt ');
  view.setUint32(16, 16, Endian.little);
  view.setUint16(20, 1, Endian.little);
  view.setUint16(22, numChannels, Endian.little);
  view.setUint32(24, sampleRate, Endian.little);
  view.setUint32(28, sampleRate * numChannels * 2, Endian.little);
  view.setUint16(32, numChannels * 2, Endian.little);
  view.setUint16(34, 16, Endian.little);
  view.setString(36, 'data');
  view.setUint32(40, dataSize, Endian.little);

  _dataViews.insertAll(0, view.buffer.asUint8List());

  final blob = web.Blob(
      <JSUint8Array>[Uint8List.fromList(_dataViews).toJS].toJS,
      web.BlobPropertyBag(type: 'audio/wav'));

  cleanup();

  return blob;
}