openMSX
Public Types | Public Member Functions | Protected Member Functions | List of all members
openmsx::ResampledSoundDevice Class Reference

#include <ResampledSoundDevice.hh>

Inheritance diagram for openmsx::ResampledSoundDevice:
Inheritance graph
[legend]
Collaboration diagram for openmsx::ResampledSoundDevice:
Collaboration graph
[legend]

Public Types

enum class  ResampleType { HQ , LQ , BLIP }
 

Public Member Functions

bool generateInput (float *buffer, size_t num)
 Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sample.
 
DynamicClockgetEmuClock ()
 
- Public Member Functions inherited from openmsx::SoundDevice
 SoundDevice (const SoundDevice &)=delete
 
 SoundDevice (SoundDevice &&)=delete
 
SoundDeviceoperator= (const SoundDevice &)=delete
 
SoundDeviceoperator= (SoundDevice &&)=delete
 
const std::string & getName () const
 Get the unique name that identifies this sound device.
 
std::string_view getDescription () const
 Gets a description of this sound device, to be presented to the user.
 
unsigned getNumChannels () const
 How many channels does this device have?
 
bool hasStereoChannels () const
 Are the individual channels of this device stereo?
 
bool isStereo () const
 Is the full output of this device stereo?
 
AmplificationFactors getAmplificationFactor () const
 
void setSoftwareVolume (float volume, EmuTime::param time)
 Change the 'software volume' of this sound device.
 
void setSoftwareVolume (float left, float right, EmuTime::param time)
 
void recordChannel (unsigned channel, const Filename &filename)
 
void muteChannel (unsigned channel, bool muted)
 
std::span< const float > getLastBuffer (unsigned channel)
 Query the last generated audio signal for a specific channel.
 
float getNativeSampleRate () const
 The samples returned by 'getLastBuffer()' have this sample rate.
 
unsigned getLastMonoBufferSize () const
 getLastBuffer() with return buffers containing this many samples.
 
unsigned getLastBufferSize () const
 

Protected Member Functions

 ResampledSoundDevice (MSXMotherBoard &motherBoard, std::string_view name, static_string_view description, unsigned channels, unsigned inputSampleRate, bool stereo)
 
 ~ResampledSoundDevice ()
 
void setOutputRate (unsigned hostSampleRate, double speed) override
 When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through this method.
 
bool updateBuffer (size_t length, float *buffer, EmuTime::param time) override
 Generate sample data.
 
void update (const Setting &setting) noexcept override
 
void createResampler ()
 
- Protected Member Functions inherited from openmsx::SoundDevice
 SoundDevice (MSXMixer &mixer, std::string_view name, static_string_view description, unsigned numChannels, unsigned inputRate, bool stereo)
 Constructor.
 
 ~SoundDevice ()
 
virtual float getAmplificationFactorImpl () const
 Get amplification/attenuation factor for this device.
 
void registerSound (const DeviceConfig &config)
 Registers this sound device with the Mixer.
 
void unregisterSound ()
 Unregisters this sound device with the Mixer.
 
void updateStream (EmuTime::param time)
 
void setInputRate (unsigned sampleRate)
 
unsigned getInputRate () const
 
virtual void generateChannels (std::span< float * > buffers, unsigned num)=0
 Abstract method to generate the actual sound data.
 
bool mixChannels (float *dataOut, size_t samples)
 Calls generateChannels() and combines the output to a single channel.
 
const DynamicClockgetHostSampleClock () const
 See MSXMixer::getHostSampleClock().
 
double getEffectiveSpeed () const
 
- Protected Member Functions inherited from openmsx::Observer< Setting >
 Observer ()=default
 
 ~Observer ()=default
 
 Observer (const Observer &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (const Observer &)=delete
 
Observeroperator= (Observer &&)=delete
 
virtual void subjectDeleted (const Setting &)
 

Additional Inherited Members

- Static Public Attributes inherited from openmsx::SoundDevice
static constexpr unsigned MAX_CHANNELS = 24
 
- Static Protected Member Functions inherited from openmsx::SoundDevice
static void addFill (float *&buffer, float value, unsigned num)
 Adds a number of samples that all have the same value.
 

Detailed Description

Definition at line 19 of file ResampledSoundDevice.hh.

Member Enumeration Documentation

◆ ResampleType

Enumerator
HQ 
LQ 
BLIP 

Definition at line 22 of file ResampledSoundDevice.hh.

Constructor & Destructor Documentation

◆ ResampledSoundDevice()

openmsx::ResampledSoundDevice::ResampledSoundDevice ( MSXMotherBoard motherBoard,
std::string_view  name,
static_string_view  description,
unsigned  channels,
unsigned  inputSampleRate,
bool  stereo 
)
protected

Definition at line 20 of file ResampledSoundDevice.cc.

References openmsx::Subject< T >::attach().

◆ ~ResampledSoundDevice()

openmsx::ResampledSoundDevice::~ResampledSoundDevice ( )
protected

Definition at line 31 of file ResampledSoundDevice.cc.

References openmsx::Subject< T >::detach().

Member Function Documentation

◆ createResampler()

void openmsx::ResampledSoundDevice::createResampler ( )
protected

◆ generateInput()

bool openmsx::ResampledSoundDevice::generateInput ( float *  buffer,
size_t  num 
)

Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sample.

See also
SoundDevice::updateBuffer()

Definition at line 47 of file ResampledSoundDevice.cc.

References openmsx::SoundDevice::mixChannels().

Referenced by openmsx::ResampleTrivial::generateOutputImpl().

◆ getEmuClock()

DynamicClock & openmsx::ResampledSoundDevice::getEmuClock ( )
inline

◆ setOutputRate()

void openmsx::ResampledSoundDevice::setOutputRate ( unsigned  hostSampleRate,
double  speed 
)
overrideprotectedvirtual

When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through this method.

All sound devices share a common sampleRate.

Implements openmsx::SoundDevice.

Definition at line 36 of file ResampledSoundDevice.cc.

References createResampler().

◆ update()

void openmsx::ResampledSoundDevice::update ( const Setting setting)
overrideprotectedvirtualnoexcept

Implements openmsx::Observer< Setting >.

Definition at line 52 of file ResampledSoundDevice.cc.

References setting.

◆ updateBuffer()

bool openmsx::ResampledSoundDevice::updateBuffer ( size_t  length,
float *  buffer,
EmuTime::param  time 
)
overrideprotectedvirtual

Generate sample data.

Parameters
lengthThe number of required samples
bufferThis buffer should be filled
timecurrent time
Returns
false iff the output is empty. IOW filling the buffer with zeros or returning false has the same effect, but the latter can be more efficient

This method is regularly called from the Mixer, it should return a pointer to a buffer filled with the required number of samples. Samples are always floats, later they are converted to the systems native format (e.g. 16-bit signed).

Note: To enable various optimizations (like SSE), this method can fill the output buffer with up to 3 extra samples. Those extra samples should be ignored, though the caller must make sure the buffer has enough space to hold them.

Implements openmsx::SoundDevice.

Definition at line 41 of file ResampledSoundDevice.cc.


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