ni-media

audio::ostream

The base class for all audio output streams.

unformatted output operations

Inherited from std::ostream

⚠️ Using these operations should be avoided. They are provided for maximum flexibility if clients need to operate on the raw pcm data. In most use cases, formatted output operations can and should be used as they provide type safety and are optimized for best performance.

positioning operations

Inherited from std::ostream.

⚠️ Using these operations should be avoided. They are provided for maximum flexibility if clients need to operate on the raw pcm data. It is the clients reponsibility to ensure that the position is aligned withing a sample or frame. Therefore it is recommended to use sample based positioning operations instead.

state functions

Inherited from std::basic_ios.

formatted output operations

These operations inserts one or more samples into the stream, by converting the sequence of samples to a pcm data sequence which is then insterted into the stream. The sample format can be any floating point type (i.e. float, double) or integral type (e.g int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t).

⚠️ It is highly recommended to use the range-based version instead of the value-based version, as this will result in a better performance (during pcm conversion).

I.e. clients should stream block wise:

void fill(audio::ostream& stream, const std::vector<float>& samples)
{
    stream << samples;
}

rather than sample wise:

void fill(audio::istream& stream, const std::vector<float>& samples)
{
    for (auto sample : samples)
    {
        stream << sample;
    }
}

sample based positioning operations

audio specific operations