openMSX
Classes | Public Member Functions | Static Public Attributes | List of all members
openmsx::MSXMixer Class Referencefinal

#include <MSXMixer.hh>

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

Public Member Functions

 MSXMixer (const MSXMixer &)=delete
 
MSXMixeroperator= (const MSXMixer &)=delete
 
 MSXMixer (Mixer &mixer, MSXMotherBoard &motherBoard, GlobalSettings &globalSettings)
 
 ~MSXMixer ()
 
void registerSound (SoundDevice &device, float volume, int balance, unsigned numChannels)
 Use this method to register a given sounddevice. More...
 
void unregisterSound (SoundDevice &device)
 Every sounddevice must unregister before it is destructed. More...
 
void updateStream (EmuTime::param time)
 Use this method to force an 'early' call to all updateBuffer() methods. More...
 
void updateSoftwareVolume (SoundDevice &device)
 Used by SoundDevice::setSoftwareVolume() More...
 
double getEffectiveSpeed () const
 Returns the ratio of emutime-speed per realtime-speed. More...
 
void setSynchronousMode (bool synchronous)
 If we're recording, we want to emulate sound at 100% emutime speed. More...
 
bool isSynchronousMode () const
 
void mute ()
 TODO This methods (un)mute the sound. More...
 
void unmute ()
 
void setMixerParams (unsigned fragmentSize, unsigned sampleRate)
 Set new fragment size and sample frequency. More...
 
const DynamicClockgetHostSampleClock () const
 Clock that ticks at the exact moment(s) in time that a host sample should be generated. More...
 
bool needStereoRecording () const
 
void setRecorder (AviRecorder *recorder)
 
unsigned getSampleRate () const
 
SoundDevicefindDevice (std::string_view name) const
 
void reInit ()
 

Static Public Attributes

static constexpr int AMP_BITS = 9
 

Detailed Description

Definition at line 28 of file MSXMixer.hh.

Constructor & Destructor Documentation

◆ MSXMixer() [1/2]

openmsx::MSXMixer::MSXMixer ( const MSXMixer )
delete

◆ MSXMixer() [2/2]

openmsx::MSXMixer::MSXMixer ( Mixer mixer,
MSXMotherBoard motherBoard,
GlobalSettings globalSettings 
)

Definition at line 39 of file MSXMixer.cc.

References openmsx::Subject< T >::attach(), and unmute().

◆ ~MSXMixer()

openmsx::MSXMixer::~MSXMixer ( )

Definition at line 66 of file MSXMixer.cc.

References openmsx::Subject< T >::detach(), mute(), and openmsx::AviRecorder::stop().

Member Function Documentation

◆ findDevice()

SoundDevice * openmsx::MSXMixer::findDevice ( std::string_view  name) const

Definition at line 748 of file MSXMixer.cc.

References end(), and ranges::find().

◆ getEffectiveSpeed()

double openmsx::MSXMixer::getEffectiveSpeed ( ) const

Returns the ratio of emutime-speed per realtime-speed.

In other words how many times faster emutime goes compared to realtime. This depends on the 'speed' setting but also on whether we're recording or not (in case of recording we want to generate sound as if realtime and emutime go at the same speed.

Definition at line 156 of file MSXMixer.cc.

References openmsx::SpeedManager::getSpeed().

Referenced by reInit().

◆ getHostSampleClock()

const DynamicClock& openmsx::MSXMixer::getHostSampleClock ( ) const
inline

Clock that ticks at the exact moment(s) in time that a host sample should be generated.

The current time of this clock is the time of the last generated sample. The rate of this clock is the same as the host sample rate. Note that this rate is not the same as the frequency set with the 'frequency' setting. Either because the sound driver can't handle the requested speed or because the 'speed' setting is different from 100.

Definition at line 110 of file MSXMixer.hh.

◆ getSampleRate()

unsigned openmsx::MSXMixer::getSampleRate ( ) const
inline

Definition at line 117 of file MSXMixer.hh.

Referenced by openmsx::AviRecorder::addWave(), and registerSound().

◆ isSynchronousMode()

bool openmsx::MSXMixer::isSynchronousMode ( ) const
inline

Definition at line 84 of file MSXMixer.hh.

◆ mute()

void openmsx::MSXMixer::mute ( )

TODO This methods (un)mute the sound.

These methods may be called multiple times, as long as you never call unmute() more than mute()

Definition at line 548 of file MSXMixer.cc.

References openmsx::Mixer::unregisterMixer().

Referenced by ~MSXMixer().

◆ needStereoRecording()

bool openmsx::MSXMixer::needStereoRecording ( ) const

Definition at line 540 of file MSXMixer.cc.

References ranges::any_of().

◆ operator=()

MSXMixer& openmsx::MSXMixer::operator= ( const MSXMixer )
delete

◆ registerSound()

void openmsx::MSXMixer::registerSound ( SoundDevice device,
float  volume,
int  balance,
unsigned  numChannels 
)

Use this method to register a given sounddevice.

While registering, the device its setSampleRate() method is called (see SoundDevice for more info). After registration the device its updateBuffer() method is 'regularly' called (see SoundDevice for more info).

Definition at line 85 of file MSXMixer.cc.

References openmsx::Setting::DONT_SAVE, enumerate(), openmsx::MSXCommandController::getCliComm(), openmsx::SoundDevice::getName(), getSampleRate(), openmsx::SoundDevice::setOutputRate(), openmsx::CliComm::SOUNDDEVICE, tmpStrCat(), and openmsx::CliComm::update().

◆ reInit()

void openmsx::MSXMixer::reInit ( )

◆ setMixerParams()

void openmsx::MSXMixer::setMixerParams ( unsigned  fragmentSize,
unsigned  sampleRate 
)

Set new fragment size and sample frequency.

A fragment size of zero means the Mixer is muted.

Definition at line 582 of file MSXMixer.cc.

References reInit().

Referenced by setSynchronousMode().

◆ setRecorder()

void openmsx::MSXMixer::setRecorder ( AviRecorder recorder)

Definition at line 596 of file MSXMixer.cc.

References setSynchronousMode().

Referenced by openmsx::AviRecorder::stop().

◆ setSynchronousMode()

void openmsx::MSXMixer::setSynchronousMode ( bool  synchronous)

If we're recording, we want to emulate sound at 100% emutime speed.

See also getEffectiveSpeed().

Definition at line 139 of file MSXMixer.cc.

References setMixerParams().

Referenced by setRecorder().

◆ unmute()

void openmsx::MSXMixer::unmute ( )

Definition at line 556 of file MSXMixer.cc.

References openmsx::Mixer::registerMixer().

Referenced by MSXMixer().

◆ unregisterSound()

void openmsx::MSXMixer::unregisterSound ( SoundDevice device)

Every sounddevice must unregister before it is destructed.

Definition at line 126 of file MSXMixer.cc.

References openmsx::MSXCommandController::getCliComm(), openmsx::SoundDevice::getName(), move_pop_back(), rfind_unguarded(), openmsx::CliComm::SOUNDDEVICE, and openmsx::CliComm::update().

◆ updateSoftwareVolume()

void openmsx::MSXMixer::updateSoftwareVolume ( SoundDevice device)

Used by SoundDevice::setSoftwareVolume()

Definition at line 724 of file MSXMixer.cc.

References find_unguarded().

◆ updateStream()

void openmsx::MSXMixer::updateStream ( EmuTime::param  time)

Use this method to force an 'early' call to all updateBuffer() methods.

Definition at line 161 of file MSXMixer.cc.

References openmsx::AviRecorder::addWave(), LZ4::count(), openmsx::DynamicClock::getTicksTill(), and openmsx::Mixer::uploadBuffer().

Referenced by openmsx::AviRecorder::addImage().

Member Data Documentation

◆ AMP_BITS

constexpr int openmsx::MSXMixer::AMP_BITS = 9
staticconstexpr

Definition at line 35 of file MSXMixer.hh.


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