class EE::Audio::SoundFileFactory¶
Overview¶
Manages and instantiates sound file readers and writers. More…
#include <soundfilefactory.hpp> class SoundFileFactory { public: // structs struct ReaderFactory; struct WriterFactory; // methods template <typename T> static void registerReader(); template <typename T> static void unregisterReader(); template <typename T> static void registerWriter(); template <typename T> static void unregisterWriter(); static SoundFileReader* createReaderFromFilename(const std::string& filename); static SoundFileReader* createReaderFromMemory(const void* data, std::size_t sizeInBytes); static SoundFileReader* createReaderFromStream(IOStream& stream); static SoundFileWriter* createWriterFromFilename(const std::string& filename); };
Detailed Documentation¶
Manages and instantiates sound file readers and writers.
This class is where all the sound file readers and writers are registered. You should normally only need to use its registration and unregistration functions; readers/writers creation and manipulation are wrapped into the higher-level classes InputSoundFile and OutputSoundFile.
To register a new reader (writer) use the SoundFileFactory::registerReader (registerWriter) static function. You don’t have to call the unregisterReader (unregisterWriter) function, unless you want to unregister a format before your application ends (typically, when a plugin is unloaded).
Usage example:
SoundFileFactory::registerReader<MySoundFileReader>(); SoundFileFactory::registerWriter<MySoundFileWriter>();
See also:
InputSoundFile, OutputSoundFile, SoundFileReader, SoundFileWriter
Methods¶
template <typename T> static void registerReader()
Register a new reader.
See also:
template <typename T> static void unregisterReader()
Unregister a reader.
See also:
template <typename T> static void registerWriter()
Register a new writer.
See also:
template <typename T> static void unregisterWriter()
Unregister a writer.
See also:
static SoundFileReader* createReaderFromFilename(const std::string& filename)
Instantiate the right reader for the given file on disk.
It’s up to the caller to release the returned reader
Parameters:
filename |
Path of the sound file |
Returns:
A new sound file reader that can read the given file, or null if no reader can handle it
See also:
createReaderFromMemory, createReaderFromStream
static SoundFileReader* createReaderFromMemory(const void* data, std::size_t sizeInBytes)
Instantiate the right codec for the given file in memory.
It’s up to the caller to release the returned reader
Parameters:
data |
Pointer to the file data in memory |
sizeInBytes |
Total size of the file data, in bytes |
Returns:
A new sound file codec that can read the given file, or null if no codec can handle it
See also:
createReaderFromFilename, createReaderFromStream
static SoundFileReader* createReaderFromStream(IOStream& stream)
Instantiate the right codec for the given file in stream.
It’s up to the caller to release the returned reader
Parameters:
stream |
Source stream to read from |
Returns:
A new sound file codec that can read the given file, or null if no codec can handle it
See also:
createReaderFromFilename, createReaderFromMemory
static SoundFileWriter* createWriterFromFilename(const std::string& filename)
Instantiate the right writer for the given file on disk.
It’s up to the caller to release the returned writer
Parameters:
filename |
Path of the sound file |
Returns:
A new sound file writer that can write given file, or null if no writer can handle it