Struct hound::WavWriter [] [src]

pub struct WavWriter<W> where
    W: Write + Seek
{ /* fields omitted */ }

A writer that accepts samples and writes the WAVE format.

The writer needs a WavSpec that describes the audio properties. Then samples can be written with write_sample. Channel data is interleaved. The number of samples written must be a multiple of the number of channels. After all samples have been written, the file must be finalized. This can be done by calling finalize. If finalize is not called, the file will be finalized upon drop. However, finalization may fail, and without calling finalize, such a failure cannot be observed.

Methods

impl<W> WavWriter<W> where
    W: Write + Seek
[src]

[src]

Creates a writer that writes the WAVE format to the underlying writer.

The underlying writer is assumed to be at offset 0. WavWriter employs no buffering internally. It is recommended to wrap the writer in a BufWriter to avoid too many write calls. The create() constructor does this automatically.

This writes parts of the header immediately, hence a Result is returned.

[src]

Writes a single sample for one channel.

WAVE interleaves channel data, so the channel that this writes the sample to depends on previous writes. This will return an error if the sample does not fit in the number of bits specified in the WavSpec.

[src]

Create an efficient writer that writes 16-bit integer samples only.

When it is known what the kind of samples will be, many dynamic checks can be omitted. Furthermore, this writer employs buffering internally, which allows omitting return value checks except on flush. The internal buffer will be sized such that exactly num_samples samples can be written to it, and the buffer is recycled across calls to get_i16_writer() if the previous buffer was sufficiently large.

Panics

Panics if the spec does not match a 16 bits per sample integer format.

Attempting to write more than num_samples samples to the writer will panic too.

[src]

Writes the parts of the WAVE format that require knowing all samples.

This method must be called after all samples have been written. If it is not called, the destructor will finalize the file, but any errors that occur in the process cannot be observed in that manner.

impl WavWriter<BufWriter<File>>
[src]

[src]

Creates a writer that writes the WAVE format to a file.

This is a convenience constructor that creates the file, wraps it in a BufWriter, and then constructs a WavWriter from it. The file will be overwritten if it exists.

Trait Implementations

impl<W> Drop for WavWriter<W> where
    W: Write + Seek
[src]

[src]

Executes the destructor for this type. Read more