Skip to main content Link Menu Expand (external link) Document Search Copy Copied
write method - WaveHeader class - helper library - Dart API
menu
write

write method

int write(
  1. EventSink<List<int>> out
)

Write a WAVE file header.

@param out {@link java.io.OutputStream} to receive the header. @return number of bytes written. @throws IOException

Implementation

int write(EventSink<List<int>> out) {
  /* RIFF header */
  writeId(out, 'RIFF'); // Chunk ID
  writeInt(out, 36 + mNumBytes); // Chunk Body Size
  writeId(out, 'WAVE'); // RIFF Form Type
  /* fmt chunk */
  writeId(out, 'fmt ');
  writeInt(out,
      16); // Size of the rest of the Subchunk which follows this number. // 18???
  writeint(out, mFormat);
  writeint(out, mNumChannels);
  writeInt(out, mSampleRate);
  writeInt(
      out,
      (mNumChannels * mSampleRate * mBitsPerSample / 8)
          .floor()); // Average Bytes per second
  writeint(out,
      (mNumChannels * mBitsPerSample / 8).floor()); // BlocK Align in bytes
  writeint(out, mBitsPerSample);
  /* data chunk */
  writeId(out, 'data');
  writeInt(out, mNumBytes);

  return headerLength;
}
flutter_sound 9.24.0