openMSX
|
#include <CassettePlayer.hh>
Public Types | |
enum class | State { PLAY , RECORD , STOP } |
Public Types inherited from openmsx::ResampledSoundDevice | |
enum class | ResampleType { HQ , BLIP } |
Public Member Functions | |
CassettePlayer (const HardwareConfig &hwConf) | |
~CassettePlayer () override | |
void | setMotor (bool status, EmuTime::param time) override |
Sets the cassette motor relay false = off true = on. | |
int16_t | readSample (EmuTime::param time) override |
Read wave data from cassette device. | |
void | setSignal (bool output, EmuTime::param time) override |
Sets the cassette output signal false = low true = high. | |
std::string_view | getName () const override |
Name used to identify this pluggable. | |
std::string_view | getDescription () const override |
Description for this pluggable. | |
void | plugHelper (Connector &connector, EmuTime::param time) override |
void | unplugHelper (EmuTime::param time) override |
void | generateChannels (std::span< float * > buffers, unsigned num) override |
Abstract method to generate the actual sound data. | |
float | getAmplificationFactorImpl () const override |
Get amplification/attenuation factor for this device. | |
void | getMediaInfo (TclObject &result) override |
This method gets called when information is required on the media inserted in the media slot of the provider. | |
template<typename Archive > | |
void | serialize (Archive &ar, unsigned version) |
const Filename & | getImageName () const |
State | getState () const |
bool | isMotorControlEnabled () const |
double | getTapePos (EmuTime::param time) |
Returns the position of the tape, in seconds from the beginning of the tape. | |
double | getTapeLength (EmuTime::param time) |
Returns the length of the tape in seconds. | |
Public Member Functions inherited from openmsx::CassetteDevice | |
std::string_view | getClass () const final |
A pluggable belongs to a certain class. | |
Public Member Functions inherited from openmsx::Pluggable | |
virtual | ~Pluggable ()=default |
void | plug (Connector &connector, EmuTime::param time) |
This method is called when this pluggable is inserted in a connector. | |
void | unplug (EmuTime::param time) |
This method is called when this pluggable is removed from a connector. | |
Connector * | getConnector () const |
Get the connector this Pluggable is plugged into. | |
bool | isPluggedIn () const |
Returns true if this pluggable is currently plugged into a connector. | |
Public Member Functions inherited from openmsx::ResampledSoundDevice | |
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. | |
DynamicClock & | getEmuClock () |
Public Member Functions inherited from openmsx::SoundDevice | |
SoundDevice (const SoundDevice &)=delete | |
SoundDevice (SoundDevice &&)=delete | |
SoundDevice & | operator= (const SoundDevice &)=delete |
SoundDevice & | operator= (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 |
Public Member Functions inherited from openmsx::MediaInfoProvider | |
MediaInfoProvider (const MediaInfoProvider &)=delete | |
MediaInfoProvider (MediaInfoProvider &&)=delete | |
MediaInfoProvider & | operator= (const MediaInfoProvider &)=delete |
MediaInfoProvider & | operator= (MediaInfoProvider &&)=delete |
Static Public Attributes | |
static constexpr std::string_view | TAPE_RECORDING_DIR = "taperecordings" |
static constexpr std::string_view | TAPE_RECORDING_EXTENSION = ".wav" |
Static Public Attributes inherited from openmsx::SoundDevice | |
static constexpr unsigned | MAX_CHANNELS = 24 |
Friends | |
class | CassettePlayerCommand |
Additional Inherited Members | |
Protected Member Functions inherited from openmsx::Pluggable | |
Pluggable () | |
void | setConnector (Connector *conn) |
Protected Member Functions inherited from openmsx::ResampledSoundDevice | |
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 () | |
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 |
bool | mixChannels (float *dataOut, size_t samples) |
Calls generateChannels() and combines the output to a single channel. | |
const DynamicClock & | getHostSampleClock () 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 | |
Observer & | operator= (const Observer &)=delete |
Observer & | operator= (Observer &&)=delete |
virtual void | subjectDeleted (const Setting &) |
Protected Member Functions inherited from openmsx::MediaInfoProvider | |
MediaInfoProvider ()=default | |
~MediaInfoProvider ()=default | |
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. | |
Definition at line 26 of file CassettePlayer.hh.
|
strong |
Enumerator | |
---|---|
PLAY | |
RECORD | |
STOP |
Definition at line 58 of file CassettePlayer.hh.
|
explicit |
Definition at line 74 of file CassettePlayer.cc.
References openmsx::MSXMotherBoard::getMSXCliComm(), openmsx::XMLDocument::getStaticDocument(), openmsx::CliComm::HARDWARE, openmsx::MSXMotherBoard::registerMediaInfo(), openmsx::SoundDevice::registerSound(), openmsx::XMLElement::setFirstChild(), and openmsx::MSXCliComm::update().
|
override |
|
overridevirtual |
Abstract method to generate the actual sound data.
buffers | An array of pointer to buffers. Each buffer must be big enough to hold 'num' samples. |
num | The number of samples. |
This method should fill each buffer with sound data that corresponds to one channel of the sound device. The same channel should each time be written to the same buffer (needed for record).
If a certain channel is muted it is allowed to set the buffer pointer to nullptr. This has exactly the same effect as filling the buffer completely with zeros, but it can be more efficient.
Implements openmsx::SoundDevice.
Definition at line 594 of file CassettePlayer.cc.
References getState(), and PLAY.
|
overridevirtual |
Get amplification/attenuation factor for this device.
Normally the outputBuffer() method should scale the output to the range [-1.0..+1.0]. But sometimes it's more convenient to generate another output range. In later stages the output is anyway still multiplied by some factor. This method tells which factor should be used to scale the output to the correct range. The default implementation returns '1.0 / 32768.0'.
Reimplemented from openmsx::SoundDevice.
Definition at line 607 of file CassettePlayer.cc.
|
overridevirtual |
Description for this pluggable.
Implements openmsx::Pluggable.
Definition at line 576 of file CassettePlayer.cc.
|
inline |
Definition at line 61 of file CassettePlayer.hh.
Referenced by openmsx::CassettePlayerCommand::execute(), getMediaInfo(), serialize(), and unplugHelper().
|
overridevirtual |
This method gets called when information is required on the media inserted in the media slot of the provider.
The provider must attach the info as a dictionary to the given TclObject.
Implements openmsx::MediaInfoProvider.
Definition at line 115 of file CassettePlayer.cc.
References openmsx::TclObject::addDictKeyValues(), getImageName(), getTapeLength(), and getTapePos().
|
overridevirtual |
Name used to identify this pluggable.
Reimplemented from openmsx::Pluggable.
Definition at line 571 of file CassettePlayer.cc.
|
inline |
Definition at line 62 of file CassettePlayer.hh.
Referenced by openmsx::CassettePlayerCommand::execute(), generateChannels(), getTapeLength(), getTapePos(), and readSample().
double openmsx::CassettePlayer::getTapeLength | ( | EmuTime::param | time | ) |
Returns the length of the tape in seconds.
When no tape is inserted, this returns 0. While recording this returns the current position (so while recording, tape length grows continuously).
Definition at line 243 of file CassettePlayer.cc.
References getState(), getTapePos(), and RECORD.
Referenced by openmsx::CassettePlayerCommand::execute(), and getMediaInfo().
double openmsx::CassettePlayer::getTapePos | ( | EmuTime::param | time | ) |
Returns the position of the tape, in seconds from the beginning of the tape.
Definition at line 223 of file CassettePlayer.cc.
References getState(), and RECORD.
Referenced by openmsx::CassettePlayerCommand::execute(), getMediaInfo(), and getTapeLength().
|
inline |
Definition at line 63 of file CassettePlayer.hh.
|
overridevirtual |
Implements openmsx::Pluggable.
Definition at line 581 of file CassettePlayer.cc.
|
overridevirtual |
Read wave data from cassette device.
Implements openmsx::CassetteDevice.
Definition at line 461 of file CassettePlayer.cc.
References getState(), and PLAY.
void openmsx::CassettePlayer::serialize | ( | Archive & | ar, |
unsigned | version | ||
) |
Definition at line 647 of file CassettePlayer.cc.
References openmsx::Sha1Sum::empty(), openmsx::FileOperations::exists(), openmsx::FilePool::getFile(), openmsx::Reactor::getFilePool(), getImageName(), openmsx::MSXMotherBoard::getMSXCliComm(), openmsx::MSXMotherBoard::getReactor(), openmsx::Filename::getResolved(), PLAY, openmsx::CliComm::printWarning(), RECORD, openmsx::Filename::setResolved(), STOP, openmsx::TAPE, openmsx::Sha1Sum::toString(), and openmsx::Filename::updateAfterLoadState().
|
overridevirtual |
Sets the cassette motor relay false = off true = on.
Implements openmsx::CassetteDevice.
Definition at line 443 of file CassettePlayer.cc.
|
overridevirtual |
Sets the cassette output signal false = low true = high.
Implements openmsx::CassetteDevice.
Definition at line 473 of file CassettePlayer.cc.
|
overridevirtual |
Implements openmsx::Pluggable.
Definition at line 587 of file CassettePlayer.cc.
References getImageName(), and STOP.
|
friend |
Definition at line 75 of file CassettePlayer.hh.
|
staticconstexpr |
Definition at line 30 of file CassettePlayer.hh.
Referenced by openmsx::CassettePlayerCommand::execute().
|
staticconstexpr |
Definition at line 31 of file CassettePlayer.hh.
Referenced by openmsx::CassettePlayerCommand::execute().