Skip to content

Resampler

class Resampler

Base class to manage resamplers.

A resampler is used to change the sample rate of an audio buffer. The Resampler class implements factory methods to create instances of ResamplerInstance objects, which are where the the resampling is done.

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

Variables

Name Description
m_name The name of this resampler.

Functions

Name Description
Resampler Create a new Resampler instance.
Resampler Default Resampler constructor.
~Resampler Default destructor.
CreateInstance Creates a new instance of the resampler.
DestroyInstance Destroys an instance of the resampler.
GetName Gets the name of this resampler.
Register Registers a new resampler.
Unregister Unregisters a resampler.
Construct Creates a new instance of the the resampler with the given name and returns its pointer.
Destruct Destroys the given resampler instance.
LockRegistry Locks the resamplers registry.
UnlockRegistry Unlocks the resamplers registry.

Variable Details

m_name

AmString m_name

The name of this resampler.

Function Details

Construct

static ResamplerInstance* Construct(const AmString& name)

Creates a new instance of the the resampler with the given name and returns its pointer.

Note

The returned pointer should be deleted using Destruct().

Parameter name
The name of the resampler.
Return
The resampler with the given name, or nullptr if none.

CreateInstance

* CreateInstance()

Creates a new instance of the resampler.

Return
A new instance of the resampler.

DestroyInstance

virtual void DestroyInstance(ResamplerInstance* instance) = 0

Destroys an instance of the resampler.

Warning

The instance should have been created with CreateInstance() before being destroyed with this method.

Parameter instance
The resampler instance to be destroyed.

Destruct

static void Destruct(const AmString& name, ResamplerInstance* instance)

Destroys the given resampler instance.

Parameter name
The name of the resampler.
Parameter instance
The resampler instance to destroy.

GetName

[[nodiscard]] const AmString& GetName() const

Gets the name of this resampler.

Return
The name of this resampler.

LockRegistry

static void LockRegistry()

Locks the resamplers registry.

Warning

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

Register

static void Register(Resampler* resampler)

Registers a new resampler.

Parameter resampler
The resampler to add in the registry.

Resampler

explicit Resampler(AmString name)

Create a new Resampler instance.

Parameter name
The resampler name. eg. "MiniAudioLinear".

Resampler()

Default Resampler constructor.

This will not automatically register the resampler. It's meant for internal resamplers only.

UnlockRegistry

static void UnlockRegistry()

Unlocks the resamplers registry.

Warning

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

Unregister

static void Unregister(const Resampler* resampler)

Unregisters a resampler.

Parameter resampler
The resampler to remove from the registry.

~Resampler

virtual ~Resampler()

Default destructor.