The OpenD Programming Language

WavWriter.this

Opens the file with the given header params.

Make sure you pass the correct params to header, except, if you have a seekable stream, the data length can be zero and it will be fixed when you close. If you have a non-seekable stream though, you must give the size up front.

If you need to go to memory, the best way is to just append your data to your own buffer, then create a WavFileHeader separately and prepend it. Wav files are simple, aside from the header and maybe a terminating byte (which isn't really important anyway), there's nothing special going on.

  1. this(string filename, WavFileHeader header)
    struct WavWriter
  2. this(WavFileHeader header)

Throws

Exception on error from open.

auto writer = WavWriter("myfile.wav", WavFileHeader(44100, 2, 16));
writer.write(shortSamples);

Meta