Skip to content

Audio IO

audio_reader_flac

audio_reader_flac class

template <typename T> audio_reader_flac

FLAC format reader

Source code
template <typename T>
struct audio_reader_flac : audio_reader<T>
{
    /// @brief Constructs FLAC reader
    audio_reader_flac(std::shared_ptr<abstract_reader<>>&& reader);
    ~audio_reader_flac() override;

    /// @brief Reads and decodes audio data
    size_t read(T* data, size_t size) override;

    /// @brief Seeks to specific sample
    bool seek(imax offset, seek_origin origin) override;

    /// @brief Returns audio format description
    const audio_format_and_length& format() const override { return fmt; }

    /// @brief Returns current position
    imax tell() const override { return position; }

private:
    std::shared_ptr<abstract_reader<>> reader;
    std::unique_ptr<internal_generic::flac_file, internal_generic::flac_file_deleter> f;
    audio_format_and_length fmt;
    imax position = 0;
}

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L191

audio_reader_flac<T> function

audio_reader_flac(
    std::shared_ptr<abstract_reader<>> &&reader)

Constructs FLAC reader

Source code
audio_reader_flac(std::shared_ptr<abstract_reader<>>&& reader)

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L194

read function

size_t read(T *data, size_t size) override

Reads and decodes audio data

Source code
size_t read(T* data, size_t size) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L198

seek function

bool seek(imax offset, seek_origin origin) override

Seeks to specific sample

Source code
bool seek(imax offset, seek_origin origin) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L201

format function

const audio_format_and_length &format() const override

Returns audio format description

Source code
const audio_format_and_length& format() const override { return fmt; }

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L204

tell function

imax tell() const override

Returns current position

Source code
imax tell() const override { return position; }

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L207

audio_reader_mp3

audio_reader_mp3 class

template <typename T> audio_reader_mp3

MP3 format reader

Source code
template <typename T>
struct audio_reader_mp3 : audio_reader<T>
{
    /// @brief Constructs MP3 reader
    audio_reader_mp3(std::shared_ptr<abstract_reader<>>&& reader);
    ~audio_reader_mp3() override;

    /// @brief Reads and decodes audio data
    size_t read(T* data, size_t size) override;

    /// @brief Seeks to specific sample
    bool seek(imax offset, seek_origin origin) override;

    mp3_config config{ 0, 0 };

    /// @brief Returns audio format description
    const audio_format_and_length& format() const override { return fmt; }

    /// @brief Returns current position
    imax tell() const override { return position; }

private:
    std::shared_ptr<abstract_reader<>> reader;
    std::unique_ptr<internal_generic::mp3_file, internal_generic::mp3_file_deleter> f;
    audio_format_and_length fmt;
    imax position = 0;
}

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L242

audio_reader_mp3<T> function

audio_reader_mp3(
    std::shared_ptr<abstract_reader<>> &&reader)

Constructs MP3 reader

Source code
audio_reader_mp3(std::shared_ptr<abstract_reader<>>&& reader)

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L245

read function

size_t read(T *data, size_t size) override

Reads and decodes audio data

Source code
size_t read(T* data, size_t size) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L249

seek function

bool seek(imax offset, seek_origin origin) override

Seeks to specific sample

Source code
bool seek(imax offset, seek_origin origin) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L252

format function

const audio_format_and_length &format() const override

Returns audio format description

Source code
const audio_format_and_length& format() const override { return fmt; }

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L257

tell function

imax tell() const override

Returns current position

Source code
imax tell() const override { return position; }

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L260

audio_reader_wav

audio_reader_wav class

template <typename T> audio_reader_wav

WAV format reader

Source code
template <typename T>
struct audio_reader_wav : audio_reader<T>
{
    using audio_reader<T>::read;

    /// @brief Constructs WAV reader
    audio_reader_wav(std::shared_ptr<abstract_reader<>>&& reader);
    ~audio_reader_wav() override;

    /// @brief Reads and decodes audio data
    size_t read(T* data, size_t size) override;

    /// @brief Seeks to specific sample
    bool seek(imax offset, seek_origin origin) override;

    /// @brief Returns audio format description
    const audio_format_and_length& format() const override { return fmt; }

    /// @brief Returns current position
    imax tell() const override { return position; }

private:
    std::shared_ptr<abstract_reader<>> reader;
    std::unique_ptr<internal_generic::wav_file> f;
    audio_format_and_length fmt;
    imax position = 0;
}

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L144

audio_reader_wav<T> function

audio_reader_wav(
    std::shared_ptr<abstract_reader<>> &&reader)

Constructs WAV reader

Source code
audio_reader_wav(std::shared_ptr<abstract_reader<>>&& reader)

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L149

read function

size_t read(T *data, size_t size) override

Reads and decodes audio data

Source code
size_t read(T* data, size_t size) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L153

seek function

bool seek(imax offset, seek_origin origin) override

Seeks to specific sample

Source code
bool seek(imax offset, seek_origin origin) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L156

format function

const audio_format_and_length &format() const override

Returns audio format description

Source code
const audio_format_and_length& format() const override { return fmt; }

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L159

tell function

imax tell() const override

Returns current position

Source code
imax tell() const override { return position; }

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L162

audio_writer_wav

audio_writer_wav class

template <typename T> audio_writer_wav

WAV format writer

Source code
template <typename T>
struct audio_writer_wav : audio_writer<T>
{
    /// @brief Constructs WAV writer using target writer and format
    audio_writer_wav(std::shared_ptr<abstract_writer<>>&& writer, const audio_format& fmt);
    ~audio_writer_wav() override;

    using audio_writer<T>::write;

    /// @brief Write data to underlying binary writer
    /// data is PCM samples in interleaved format
    /// size is the number of samples (PCM frames * channels)
    size_t write(const T* data, size_t size) override;

    void close() override;

    const audio_format_and_length& format() const override { return fmt; }

    imax tell() const override { return fmt.length; }

    bool seek(imax, seek_origin) override { return false; }

private:
    std::shared_ptr<abstract_writer<>> writer;
    std::unique_ptr<internal_generic::wav_file, internal_generic::wav_file_deleter> f;
    audio_format_and_length fmt;
}

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L109

audio_writer_wav<T> function

audio_writer_wav(
    std::shared_ptr<abstract_writer<>> &&writer,
    const audio_format &fmt)

Constructs WAV writer using target writer and format

Source code
audio_writer_wav(std::shared_ptr<abstract_writer<>>&& writer, const audio_format& fmt)

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L112

write function

size_t write(const T *data, size_t size) override

Write data to underlying binary writer data is PCM samples in interleaved format size is the number of samples (PCM frames * channels)

Source code
size_t write(const T* data, size_t size) override

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L120

close function

virtual void close() = 0

Finishes writing and closes underlying writer

Source code
virtual void close() = 0

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L93

format function

virtual const audio_format_and_length &format() const = 0

Returns audio format description

Source code
virtual const audio_format_and_length& format() const = 0

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L73

virtual const audio_format_and_length &format() const = 0

Returns audio format description

Source code
virtual const audio_format_and_length& format() const = 0

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L90

read function

using abstract_reader<T>::read

Reads interleaved audio

Source code
using abstract_reader<T>::read

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L59

write function

using abstract_writer<T>::write

Writes interleaved audio

Source code
using abstract_writer<T>::write

https://github.com/kfrlib/kfr/blob//include/kfr/io/audiofile.hpp#L80


Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/