OpenTTD Source 20260815-master-gdf55704e7d
SoundResampler_Soxr Class Reference

Soxr SoundResampler implementation. More...

Inheritance diagram for SoundResampler_Soxr:
SoundResampler PriorityBaseProvider< SoundResampler > BaseProvider< SoundResampler >

Public Member Functions

 SoundResampler_Soxr ()
 Create this SoundResample_Soxr instance.
bool Resample (SoundEntry &sound, uint32_t play_rate) const override
 Resample a loaded sound.
Public Member Functions inherited from SoundResampler
 SoundResampler (std::string_view name, std::string_view description, int priority)
 Create the provider.
virtual ~SoundResampler ()
 Unregister this sound resampler.
Public Member Functions inherited from PriorityBaseProvider< SoundResampler >
constexpr PriorityBaseProvider (std::string_view name, std::string_view description, int priority)
 Create the provider.
int GetPriority () const
 Get the priority of this provider.
Public Member Functions inherited from BaseProvider< SoundResampler >
constexpr BaseProvider (std::string_view name, std::string_view description)
 Create the provider.
virtual ~BaseProvider ()=default
 Ensure the destructor of the sub classes are called as well.
std::string_view GetName () const
 Get the name of this provider.
std::string_view GetDescription () const
 Get a description of this provider.

Static Public Member Functions

static void ConvertInt8toInt16 (std::span< const std::byte > in, std::span< std::byte > out)
 Convert samples from 8 bits to 16 bits.

Private Attributes

const soxr_io_spec_t io = soxr_io_spec(SOXR_INT16_I, SOXR_INT16_I)
 Input/output settings.
const soxr_quality_spec_t quality = soxr_quality_spec(SOXR_VHQ, 0)
 Quality settings.
const soxr_runtime_spec_t runtime = soxr_runtime_spec(1)
 Runtime settings.

Static Private Attributes

static SoundResampler_Soxr instance {}
 Instance of this SoundResampler.

Additional Inherited Members

Protected Attributes inherited from PriorityBaseProvider< SoundResampler >
const int priority
 The priority of this provider.
Protected Attributes inherited from BaseProvider< SoundResampler >
const std::string_view name
 The name of the provider.
const std::string_view description
 A description of the provider.

Detailed Description

Soxr SoundResampler implementation.

Definition at line 21 of file soundresampler_soxr.cpp.

Constructor & Destructor Documentation

◆ SoundResampler_Soxr()

SoundResampler_Soxr::SoundResampler_Soxr ( )
inline

Create this SoundResample_Soxr instance.

Definition at line 24 of file soundresampler_soxr.cpp.

References SoundResampler::SoundResampler().

Member Function Documentation

◆ ConvertInt8toInt16()

void SoundResampler_Soxr::ConvertInt8toInt16 ( std::span< const std::byte > in,
std::span< std::byte > out )
inlinestatic

Convert samples from 8 bits to 16 bits.

Parameters
inSpan of samples to convert.
outSpan to place converted samples.
Precondition
out must be exactly twice the size of in.

Definition at line 32 of file soundresampler_soxr.cpp.

Referenced by Resample().

◆ Resample()

bool SoundResampler_Soxr::Resample ( SoundEntry & sound,
uint32_t play_rate ) const
inlineoverridevirtual

Resample a loaded sound.

Parameters
soundThe sound to resample.
play_rateThe new sample rate.
Returns
true iff the sound was resampled.

Implements SoundResampler.

Definition at line 48 of file soundresampler_soxr.cpp.

References Align(), ConvertInt8toInt16(), and Debug.

Field Documentation

◆ instance

SoundResampler_Soxr SoundResampler_Soxr::instance {}
staticprivate

Instance of this SoundResampler.

Definition at line 92 of file soundresampler_soxr.cpp.

◆ io

const soxr_io_spec_t SoundResampler_Soxr::io = soxr_io_spec(SOXR_INT16_I, SOXR_INT16_I)
private

Input/output settings.

Definition at line 87 of file soundresampler_soxr.cpp.

◆ quality

const soxr_quality_spec_t SoundResampler_Soxr::quality = soxr_quality_spec(SOXR_VHQ, 0)
private

Quality settings.

Definition at line 88 of file soundresampler_soxr.cpp.

◆ runtime

const soxr_runtime_spec_t SoundResampler_Soxr::runtime = soxr_runtime_spec(1)
private

Runtime settings.

Definition at line 89 of file soundresampler_soxr.cpp.


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