# write method

int write(

1. EventSink<List<int>> out

)

Write a WAVE file header.

## Implementation

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

      return headerLength;
    }