ScummVM API documentation
Scumm::Player_V2 Class Reference

#include <player_v2.h>

Inheritance diagram for Scumm::Player_V2:
Audio::AudioStream Scumm::Player_V2Base Scumm::MusicEngine Common::Serializable Scumm::Player_V1

Public Member Functions

 Player_V2 (ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr)
 
void setMusicVolume (int vol) override
 
void startSound (int sound) override
 
void stopSound (int sound) override
 
void stopAllSounds () override
 
int getSoundStatus (int sound) const override
 
int readBuffer (int16 *buffer, const int numSamples) override
 
bool isStereo () const override
 
bool endOfData () const override
 
int getRate () const override
 
- Public Member Functions inherited from Audio::AudioStream
virtual bool endOfStream () const
 
- Public Member Functions inherited from Scumm::Player_V2Base
 Player_V2Base (ScummEngine *scumm, bool pcjr)
 
int getMusicTimer () override
 
- Public Member Functions inherited from Scumm::MusicEngine
virtual void setSfxVolume (int vol)
 
virtual void startSoundWithTrackID (int sound, int track)
 
virtual void setQuality (int qual)
 
virtual void toggleMusic (bool enable)
 
virtual void toggleSoundEffects (bool enable)
 
void saveLoadWithSerializer (Common::Serializer &ser) override
 
virtual void restoreAfterLoad ()
 

Protected Types

enum  { FIXP_SHIFT = 16 }
 

Protected Member Functions

virtual void generateSpkSamples (int16 *data, uint len)
 
virtual void generatePCjrSamples (int16 *data, uint len)
 
void lowPassFilter (int16 *data, uint len)
 
void squareGenerator (int channel, int freq, int vol, int noiseFeedback, int16 *sample, uint len)
 
- Protected Member Functions inherited from Scumm::Player_V2Base
virtual void nextTick ()
 
virtual void clear_channel (int i)
 
virtual void chainSound (int nr, byte *data)
 
virtual void chainNextSound ()
 
void execute_cmd (ChannelInfo *channel)
 
void next_freqs (ChannelInfo *channel)
 

Protected Attributes

unsigned int _update_step
 
unsigned int _decay
 
int _level
 
unsigned int _RNG
 
unsigned int _volumetable [16]
 
int _timer_count [4]
 
int _timer_output
 
Audio::Mixer_mixer
 
Audio::SoundHandle _soundHandle
 
const uint32 _sampleRate
 
Common::Mutex _mutex
 
uint32 _next_tick
 
uint32 _tick_len
 
- Protected Attributes inherited from Scumm::Player_V2Base
bool _isV3Game
 
ScummEngine_vm
 
bool _pcjr
 
int _header_len
 
int _current_nr
 
byte * _current_data
 
int _next_nr
 
byte * _next_data
 
byte * _retaddr
 
ChannelInfo _channels [5]
 

Detailed Description

Scumm V2 PC-Speaker MIDI driver. This simulates the pc speaker sound, which is driven by the 8253 (square wave generator) and a low-band filter.

Member Function Documentation

◆ setMusicVolume()

void Scumm::Player_V2::setMusicVolume ( int  vol)
overridevirtual

Set the output volume for music. Also used, if the inheriting class doesn't distinguish between music and sfx.

Parameters
volthe new output volume

Implements Scumm::MusicEngine.

◆ startSound()

void Scumm::Player_V2::startSound ( int  sound)
overridevirtual

Start playing the sound with the given id.

Parameters
soundthe sound to start

Implements Scumm::MusicEngine.

◆ stopSound()

void Scumm::Player_V2::stopSound ( int  sound)
overridevirtual

Stop playing the sound with the given id.

Parameters
soundthe sound to stop

Implements Scumm::MusicEngine.

◆ stopAllSounds()

void Scumm::Player_V2::stopAllSounds ( )
overridevirtual

Start playing all currently playing sounds.

Implements Scumm::MusicEngine.

◆ getSoundStatus()

int Scumm::Player_V2::getSoundStatus ( int  sound) const
overridevirtual

Query the status of the sound with the given id. Usually this is just a boolean telling us whether the sound is playing or not.

Parameters
soundthe sound to for which we want the status
Returns
the status of the specified sound

Implements Scumm::MusicEngine.

◆ readBuffer()

int Scumm::Player_V2::readBuffer ( int16 *  buffer,
const int  numSamples 
)
overridevirtual

Fill the given buffer with up to numSamples samples.

Data must be in native endianness, 16 bits per sample, signed. For stereo stream, the buffer will be filled with interleaved left and right channel samples, starting with the left sample. Furthermore, the samples in the left and right are summed up. So if you request 4 samples from a stereo stream, you will get a total of two left channel and two right channel samples.

Returns
The actual number of samples read, or -1 if a critical error occurred.
Note
You must check whether the returned value is less than what you requested. This indicates that the stream is fully used up.

Implements Audio::AudioStream.

◆ isStereo()

bool Scumm::Player_V2::isStereo ( ) const
inlineoverridevirtual

Check whether this is a stereo stream.

Implements Audio::AudioStream.

◆ endOfData()

bool Scumm::Player_V2::endOfData ( ) const
inlineoverridevirtual

Check whether end of data has been reached.

If this returns true, it indicates that at this time there is no data available in the stream. However, there might be more data in the future.

This is used by e.g. a rate converter to decide whether to keep on converting data or to stop.

Implements Audio::AudioStream.

◆ getRate()

int Scumm::Player_V2::getRate ( ) const
inlineoverridevirtual

Sample rate of the stream.

Implements Audio::AudioStream.


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