This is a snapshot of a work-in-progress documentation theme. If you feel lost, miss something, or want to see the original Doxygen docs instead, head over to the archived version of this documentation page.

Magnum::Audio::AbstractImporter class

Base for audio importer plugins.

Provides interface for importing various audio formats. See Loading and using plugins for more information and *Importer classes in Audio namespace for available importer plugins.

Subclassing

Plugin implements function doFeatures(), doIsOpened(), one of or both doOpenData() and doOpenFile() functions, function doClose() and data access functions doFormat(), doFrequency() and doData().

You don't need to do most of the redundant sanity checks, these things are checked by the implementation:

  • Functions doOpenData() and doOpenFile() are called after the previous file was closed, function doClose() is called only if there is any file opened.
  • Function doOpenData() is called only if Feature::OpenData is supported.
  • All do*() implementations working on opened file are called only if there is any file opened.

Plugin interface string is "cz.mosra.magnum.Audio.AbstractImporter/0.1".

Derived classes

class AnyImporter
Any audio importer plugin.
class DrFlacImporter
FLAC audio importer plugin using dr_flac.
class DrWavImporter
WAV audio importer plugin using dr_wav.
class StbVorbisImporter
OGG audio importer plugin using stb_vorbis.
class WavImporter
WAV importer plugin.

Public types

enum class Feature: UnsignedByte { OpenData = 1 << 0 }
Features supported by this importer.
using Features = Containers::EnumSet<Feature>
Features supported by this importer.

Constructors, destructors, conversion operators

AbstractImporter() explicit
Default constructor.
AbstractImporter(PluginManager::Manager<AbstractImporter>& manager) explicit
Constructor with access to plugin manager.
AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.

Public functions

auto features() const -> Features
Features supported by this importer.
auto isOpened() const -> bool
Whether any file is opened.
auto openData(Containers::ArrayView<const char> data) -> bool
Open raw data.
auto openFile(const std::string& filename) -> bool
Open file.
void close()
Close file.

Protected functions

auto doFeatures() const -> Features pure virtual
Implementation for features()
auto doIsOpened() const -> bool pure virtual
Implementation for isOpened()
void doOpenData(Containers::ArrayView<const char> data) virtual
Implementation for openData()
void doOpenFile(const std::string& filename) virtual
Implementation for openFile()
void doClose() pure virtual
Implementation for close()
auto doFormat() const -> Buffer::Format pure virtual
Implementation for format()
auto doFrequency() const -> UnsignedInt pure virtual
Implementation for frequency()
auto doData() -> Containers::Array<char> pure virtual
Implementation for data()

Data access

auto format() const -> Buffer::Format
Sample format.
auto frequency() const -> UnsignedInt
Sample frequency.
auto data() -> Containers::Array<char>
Sample data.

Enum documentation

enum class Magnum::Audio::AbstractImporter::Feature: UnsignedByte

Features supported by this importer.

Enumerators
OpenData

Opening files from raw data using openData()

Typedef documentation

typedef Containers::EnumSet<Feature> Magnum::Audio::AbstractImporter::Features

Features supported by this importer.

Function documentation

bool Magnum::Audio::AbstractImporter::openData(Containers::ArrayView<const char> data)

Open raw data.

Closes previous file, if it was opened, and tries to open given file. Available only if Feature::OpenData is supported. Returns true on success, false otherwise.

bool Magnum::Audio::AbstractImporter::openFile(const std::string& filename)

Open file.

Closes previous file, if it was opened, and tries to open given file. Returns true on success, false otherwise.

void Magnum::Audio::AbstractImporter::doOpenFile(const std::string& filename) virtual protected

Implementation for openFile()

If Feature::OpenData is supported, default implementation opens the file and calls doOpenData() with its contents.