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  ResampleType { RESAMPLE_HQ, RESAMPLE_LQ, RESAMPLE_BLIP }
 
- Public Types inherited from openmsx::SoundDevice
using VolumeType = FixedPoint< MSXMixer::AMP_BITS >
 

Public Member Functions

bool generateInput (int *buffer, unsigned num)
 Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sample. More...
 
- Public Member Functions inherited from openmsx::SoundDevice
const std::string & getName () const
 Get the unique name that identifies this sound device. More...
 
const std::string & getDescription () const
 Gets a description of this sound device, to be presented to the user. More...
 
bool isStereo () const
 Is this a stereo device? This is set in the constructor and cannot be changed anymore. More...
 
std::pair< VolumeType, VolumeTypegetAmplificationFactor () const
 Gets this device its 'amplification factor'. More...
 
void setSoftwareVolume (VolumeType volume, EmuTime::param time)
 Change the 'software volume' of this sound device. More...
 
void setSoftwareVolume (VolumeType left, VolumeType right, EmuTime::param time)
 
void recordChannel (unsigned channel, const Filename &filename)
 
void muteChannel (unsigned channel, bool muted)
 

Protected Member Functions

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

Additional Inherited Members

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

Detailed Description

Definition at line 15 of file ResampledSoundDevice.hh.

Member Enumeration Documentation

◆ ResampleType

Enumerator
RESAMPLE_HQ 
RESAMPLE_LQ 
RESAMPLE_BLIP 

Definition at line 18 of file ResampledSoundDevice.hh.

Constructor & Destructor Documentation

◆ ResampledSoundDevice()

openmsx::ResampledSoundDevice::ResampledSoundDevice ( MSXMotherBoard motherBoard,
string_view  name,
string_view  description,
unsigned  channels,
bool  stereo = false 
)
protected

Definition at line 16 of file ResampledSoundDevice.cc.

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

◆ ~ResampledSoundDevice()

openmsx::ResampledSoundDevice::~ResampledSoundDevice ( )
protected

Definition at line 26 of file ResampledSoundDevice.cc.

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

Member Function Documentation

◆ createResampler()

void openmsx::ResampledSoundDevice::createResampler ( )
protected

◆ generateInput()

bool openmsx::ResampledSoundDevice::generateInput ( int *  buffer,
unsigned  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 43 of file ResampledSoundDevice.cc.

References openmsx::SoundDevice::mixChannels().

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

◆ setOutputRate()

void openmsx::ResampledSoundDevice::setOutputRate ( unsigned  sampleRate)
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 32 of file ResampledSoundDevice.cc.

References createResampler().

◆ update()

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

Implements openmsx::Observer< Setting >.

Definition at line 49 of file ResampledSoundDevice.cc.

References createResampler().

Referenced by openmsx::AY8910::writeRegister().

◆ updateBuffer()

bool openmsx::ResampledSoundDevice::updateBuffer ( unsigned  length,
int *  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 ints, 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 37 of file ResampledSoundDevice.cc.


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