openMSX
|
#include <MSXMixer.hh>
Classes | |
struct | SoundDeviceInfo |
Public Member Functions | |
MSXMixer (Mixer &mixer, MSXMotherBoard &motherBoard, GlobalSettings &globalSettings) | |
MSXMixer (const MSXMixer &)=delete | |
MSXMixer (MSXMixer &&)=delete | |
MSXMixer & | operator= (const MSXMixer &)=delete |
MSXMixer & | operator= (MSXMixer &&)=delete |
~MSXMixer () | |
void | registerSound (SoundDevice &device, float volume, int balance, unsigned numChannels) |
Use this method to register a given SoundDevice. | |
void | unregisterSound (SoundDevice &device) |
Every SoundDevice must unregister before it is destructed. | |
void | updateStream (EmuTime::param time) |
Use this method to force an 'early' call to all updateBuffer() methods. | |
void | updateSoftwareVolume (SoundDevice &device) |
Used by SoundDevice::setSoftwareVolume() | |
double | getEffectiveSpeed () const |
Returns the ratio of EmuTime-speed per realtime-speed. | |
void | setSynchronousMode (bool synchronous) |
If we're recording, we want to emulate sound at 100% EmuTime speed. | |
bool | isSynchronousMode () const |
void | mute () |
TODO This methods (un)mute the sound. | |
void | unmute () |
void | setMixerParams (unsigned fragmentSize, unsigned sampleRate) |
Set new fragment size and sample frequency. | |
const DynamicClock & | getHostSampleClock () const |
Clock that ticks at the exact moment(s) in time that a host sample should be generated. | |
bool | needStereoRecording () const |
void | setRecorder (AviRecorder *recorder) |
unsigned | getSampleRate () const |
SoundDevice * | findDevice (std::string_view name) const |
const SoundDeviceInfo * | findDeviceInfo (std::string_view name) const |
const auto & | getDeviceInfos () const |
void | reInit () |
Static Public Attributes | |
static constexpr int | AMP_BITS = 9 |
Definition at line 32 of file MSXMixer.hh.
openmsx::MSXMixer::MSXMixer | ( | Mixer & | mixer, |
MSXMotherBoard & | motherBoard, | ||
GlobalSettings & | globalSettings | ||
) |
Definition at line 41 of file MSXMixer.cc.
References openmsx::Subject< T >::attach().
|
delete |
|
delete |
openmsx::MSXMixer::~MSXMixer | ( | ) |
Definition at line 60 of file MSXMixer.cc.
References openmsx::Subject< T >::detach(), mute(), and openmsx::AviRecorder::stop().
SoundDevice * openmsx::MSXMixer::findDevice | ( | std::string_view | name | ) | const |
Definition at line 812 of file MSXMixer.cc.
References findDeviceInfo().
const MSXMixer::SoundDeviceInfo * openmsx::MSXMixer::findDeviceInfo | ( | std::string_view | name | ) | const |
Definition at line 805 of file MSXMixer.cc.
References end(), and ranges::find().
Referenced by findDevice().
|
inline |
Definition at line 141 of file MSXMixer.hh.
Referenced by openmsx::ImGuiSCCViewer::paint(), openmsx::ImGuiSoundChip::paint(), and openmsx::ImGuiWaveViewer::paint().
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 150 of file MSXMixer.cc.
References openmsx::SpeedManager::getSpeed().
Referenced by reInit().
|
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 130 of file MSXMixer.hh.
|
inline |
Definition at line 137 of file MSXMixer.hh.
Referenced by openmsx::AviRecorder::addWave(), and registerSound().
|
inline |
Definition at line 104 of file MSXMixer.hh.
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 605 of file MSXMixer.cc.
References openmsx::Mixer::unregisterMixer().
Referenced by ~MSXMixer().
bool openmsx::MSXMixer::needStereoRecording | ( | ) | const |
Definition at line 597 of file MSXMixer.cc.
References ranges::any_of().
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 79 of file MSXMixer.cc.
References openmsx::MSXMixer::SoundDeviceInfo::balanceSetting, openmsx::MSXMixer::SoundDeviceInfo::channelSettings, openmsx::MSXMixer::SoundDeviceInfo::defaultVolume, openmsx::MSXMixer::SoundDeviceInfo::device, enumerate(), openmsx::MSXCommandController::getCliComm(), openmsx::SoundDevice::getName(), getSampleRate(), openmsx::SpeedManager::getSpeed(), openmsx::Setting::NO, openmsx::SoundDevice::setOutputRate(), openmsx::CliComm::SOUND_DEVICE, tmpStrCat(), openmsx::MSXCliComm::update(), and openmsx::MSXMixer::SoundDeviceInfo::volumeSetting.
void openmsx::MSXMixer::reInit | ( | ) |
Definition at line 622 of file MSXMixer.cc.
References openmsx::Schedulable::getCurrentTime(), getEffectiveSpeed(), openmsx::DynamicClock::reset(), and openmsx::DynamicClock::setFreq().
Referenced by 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 639 of file MSXMixer.cc.
References openmsx::SpeedManager::getSpeed(), and reInit().
Referenced by setSynchronousMode().
void openmsx::MSXMixer::setRecorder | ( | AviRecorder * | recorder | ) |
Definition at line 653 of file MSXMixer.cc.
References setSynchronousMode().
Referenced by openmsx::AviRecorder::stop().
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 133 of file MSXMixer.cc.
References setMixerParams().
Referenced by setRecorder().
void openmsx::MSXMixer::unmute | ( | ) |
Definition at line 613 of file MSXMixer.cc.
References openmsx::Mixer::registerMixer().
void openmsx::MSXMixer::unregisterSound | ( | SoundDevice & | device | ) |
Every SoundDevice must unregister before it is destructed.
Definition at line 120 of file MSXMixer.cc.
References openmsx::MSXMixer::SoundDeviceInfo::device, openmsx::MSXCommandController::getCliComm(), openmsx::SoundDevice::getName(), move_pop_back(), rfind_unguarded(), openmsx::CliComm::SOUND_DEVICE, and openmsx::MSXCliComm::update().
void openmsx::MSXMixer::updateSoftwareVolume | ( | SoundDevice & | device | ) |
Used by SoundDevice::setSoftwareVolume()
Definition at line 781 of file MSXMixer.cc.
References openmsx::MSXMixer::SoundDeviceInfo::device, and find_unguarded().
void openmsx::MSXMixer::updateStream | ( | EmuTime::param | time | ) |
Use this method to force an 'early' call to all updateBuffer() methods.
Definition at line 155 of file MSXMixer.cc.
References openmsx::AviRecorder::addWave(), ALIGNAS_SSE, openmsx::DynamicClock::getTicksTill(), subspan(), and openmsx::Mixer::uploadBuffer().
Referenced by openmsx::AviRecorder::addImage().
|
staticconstexpr |
Definition at line 39 of file MSXMixer.hh.