Skip to content

Codec

Audio file reader and writer.

Detailed Description

The Codec class is used to implement an audio file reader and writer. This is the base class for all audio codecs, each implementation should allow building decoders and encoders.

The Codec class follows the plugin architecture, and thus, you are able to create your own codecs and register them to the Engine by inheriting from this class and by implementing the necessary dependencies.

Classes

Type Name
class Decoder
Audio file reader.
class Encoder
Audio file writer.

Public Functions

Type Name
virtual bool CanHandleFile (std::shared_ptr< File > file) const = 0
Checks whether this codec can handle the file at the given path.
Codec (AmString name)
Create a new codec instance.
virtual std::shared_ptr< Decoder > CreateDecoder () = 0
Creates a new instance of the decoder associated with this codec.
virtual std::shared_ptr< Encoder > CreateEncoder () = 0
Creates a new instance of the encoder associated with this codec.
const AmString & GetName () const
Gets the name of this codec.
virtual ~Codec ()
Default destructor.

Public Static Functions

Type Name
std::shared_ptr< Codec > Find (const AmString & name)
Look up a codec by name.
std::shared_ptr< Codec > FindForFile (std::shared_ptr< File > file)
Finds the codec which can handle the given file.
const std::map< AmString, std::shared_ptr< Codec > > & GetRegistry ()
Gets the list of registered codecs.
void LockRegistry ()
Locks the codecs' registry.
void Register (std::shared_ptr< Codec > codec)
Registers a new audio codec.
void UnlockRegistry ()
Unlocks the codecs' registry.
void Unregister (std::shared_ptr< const Codec > codec)
Unregisters a audio codec.

Protected Attributes

Type Name
AmString m_name
The name of this codec.

Public Functions Documentation

CanHandleFile

Checks whether this codec can handle the file at the given path.

virtual bool Amplitude::Codec::CanHandleFile (
    std::shared_ptr< File > file
) const = 0

Parameters:

  • file The file to check.

Returns:

true if the codec can handle the file, false otherwise.

Codec

Create a new codec instance.

explicit Amplitude::Codec::Codec (
    AmString name
) 

Parameters:

  • name The codec name. Recommended names are "FILE_EXTENSION", e.g., "WAV" or "OGG".
CreateDecoder

Creates a new instance of the decoder associated with this codec.

virtual std::shared_ptr< Decoder > Amplitude::Codec::CreateDecoder () = 0

Returns:

A Decoder instance.

CreateEncoder

Creates a new instance of the encoder associated with this codec.

virtual std::shared_ptr< Encoder > Amplitude::Codec::CreateEncoder () = 0

Returns:

An Encoder instance.

GetName

Gets the name of this codec.

const AmString & Amplitude::Codec::GetName () const

Returns:

The name of this codec.

~Codec

Default destructor.

virtual Amplitude::Codec::~Codec () 

Public Static Functions Documentation

Find

Look up a codec by name.

static std::shared_ptr< Codec > Amplitude::Codec::Find (
    const AmString & name
) 

Parameters:

  • name The name of the codec to find.

Returns:

The codec with the given name, or nullptr if not found.

FindForFile

Finds the codec which can handle the given file.

static std::shared_ptr< Codec > Amplitude::Codec::FindForFile (
    std::shared_ptr< File > file
) 

Parameters:

  • file The file to find the codec for.

Returns:

The codec which can handle the given file, or nullptr if not found.

GetRegistry

Gets the list of registered codecs.

static const std::map< AmString, std::shared_ptr< Codec > > & Amplitude::Codec::GetRegistry () 

Returns:

The registry of codecs.

LockRegistry

Locks the codecs' registry.

static void Amplitude::Codec::LockRegistry () 

Warning:

This function is mainly used for internal purposes. It's called before the Engine initialization, to discard the registration of new codecs after the engine is fully loaded.

Register

Registers a new audio codec.

static void Amplitude::Codec::Register (
    std::shared_ptr< Codec > codec
) 

Note:

This method does nothing if the registry is locked.

Parameters:

  • codec The audio codec to add in the registry.

See also: LockRegistry, UnlockRegistry

UnlockRegistry

Unlocks the codecs' registry.

static void Amplitude::Codec::UnlockRegistry () 

Warning:

This function is mainly used for internal purposes. It's called after the Engine deinitialization, to allow the registration of new codecs after the engine is fully unloaded.

Unregister

Unregisters a audio codec.

static void Amplitude::Codec::Unregister (
    std::shared_ptr< const Codec > codec
) 

Note:

This method does nothing if the registry is locked.

Parameters:

  • codec The audio codec to remove from the registry.

See also: LockRegistry, UnlockRegistry

Protected Attributes Documentation

m_name

The name of this codec.

AmString SparkyStudios::Audio::Amplitude::Codec::m_name;

The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/Core/Codec.h