# SFML - Simple and Fast Multimedia Library

SFML 3.0.0

- Main Page
- Topics
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
sf::SoundFileFactory Class Reference
Audio module

Manages and instantiates sound file readers and writers. More...

`#include <SFML/Audio/SoundFileFactory.hpp>`

## Static Public Member Functions

template<typename T >
static void | registerReader ()
| Register a new reader.
template<typename T >
static void | unregisterReader ()
| Unregister a reader.
template<typename T >
static bool | isReaderRegistered ()
| Check if a reader is registered.
template<typename T >
static void | registerWriter ()
| Register a new writer.
template<typename T >
static void | unregisterWriter ()
| Unregister a writer.
template<typename T >
static bool | isWriterRegistered ()
| Check if a writer is registered.
static std::unique_ptr< SoundFileReader > | createReaderFromFilename (const std::filesystem::path &filename)
| Instantiate the right reader for the given file on disk.
static std::unique_ptr< SoundFileReader > | createReaderFromMemory (const void *data, std::size_t sizeInBytes)
| Instantiate the right codec for the given file in memory.
static std::unique_ptr< SoundFileReader > | createReaderFromStream (InputStream &stream)
| Instantiate the right codec for the given file in stream.
static std::unique_ptr< SoundFileWriter > | createWriterFromFilename (const std::filesystem::path &filename)
| Instantiate the right writer for the given file on disk.

## Detailed Description

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 `sf::InputSoundFile` and `sf::OutputSoundFile`.

To register a new reader (writer) use the `sf::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:

sf::SoundFileFactory::registerReader<MySoundFileReader>();
assert(sf::SoundFileFactory::isReaderRegistered<MySoundFileReader>());
sf::SoundFileFactory::registerWriter<MySoundFileWriter>();
assert(sf::SoundFileFactory::isWriterRegistered<MySoundFileWriter>());
sf::SoundFileFactory::registerWriter
static void registerWriter()
Register a new writer.
sf::SoundFileFactory::registerReader
static void registerReader()
Register a new reader.
sf::SoundFileFactory::isReaderRegistered
static bool isReaderRegistered()
Check if a reader is registered.
sf::SoundFileFactory::isWriterRegistered
static bool isWriterRegistered()
Check if a writer is registered.

See also
  `sf::InputSoundFile`, `sf::OutputSoundFile`, `sf::SoundFileReader`, `sf::SoundFileWriter`

Definition at line 49 of file SoundFileFactory.hpp.

## Member Function Documentation

## ◆ createReaderFromFilename()

static std::unique_ptr< SoundFileReader > sf::SoundFileFactory::createReaderFromFilename | ( | const std::filesystem::path & | filename | ) |

staticnodiscard

Instantiate the right reader for the given file on disk.

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`

## ◆ createReaderFromMemory()

static std::unique_ptr< SoundFileReader > sf::SoundFileFactory::createReaderFromMemory | ( | const void * | data,
|  | std::size_t | sizeInBytes )

staticnodiscard

Instantiate the right codec for the given file in memory.

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`

## ◆ createReaderFromStream()

static std::unique_ptr< SoundFileReader > sf::SoundFileFactory::createReaderFromStream | ( | InputStream & | stream | ) |

staticnodiscard

Instantiate the right codec for the given file in stream.

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`

## ◆ createWriterFromFilename()

static std::unique_ptr< SoundFileWriter > sf::SoundFileFactory::createWriterFromFilename | ( | const std::filesystem::path & | filename | ) |

staticnodiscard

Instantiate the right writer for the given file on disk.

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

## ◆ isReaderRegistered()

template<typename T >

static bool sf::SoundFileFactory::isReaderRegistered | ( |  | ) |

staticnodiscard

Check if a reader is registered.

## ◆ isWriterRegistered()

template<typename T >

static bool sf::SoundFileFactory::isWriterRegistered | ( |  | ) |

staticnodiscard

Check if a writer is registered.

## ◆ registerReader()

template<typename T >

static void sf::SoundFileFactory::registerReader | ( |  | ) |

static

Register a new reader.

See also
  `unregisterReader`

## ◆ registerWriter()

template<typename T >

static void sf::SoundFileFactory::registerWriter | ( |  | ) |

static

Register a new writer.

See also
  `unregisterWriter`

## ◆ unregisterReader()

template<typename T >

static void sf::SoundFileFactory::unregisterReader | ( |  | ) |

static

Unregister a reader.

See also
  `registerReader`

## ◆ unregisterWriter()

template<typename T >

static void sf::SoundFileFactory::unregisterWriter | ( |  | ) |

static

Unregister a writer.

See also
  `registerWriter`

The documentation for this class was generated from the following file:

- SoundFileFactory.hpp