ScummVM API documentation
Sci::Audio32 Class Reference

#include <audio32.h>

Inheritance diagram for Sci::Audio32:
Audio::AudioStream Common::Serializable

Public Types

enum  { kMaxVolume = 127, kMonitorAudioFlagSci3 = 0x80 }
 

Public Member Functions

 Audio32 (ResourceManager *resMan)
 
void saveLoadWithSerializer (Common::Serializer &s) override
 
int readBuffer (Audio::st_sample_t *buffer, const int numSamples) override
 
bool isStereo () const override
 
int getRate () const override
 
bool endOfData () const override
 
bool endOfStream () const override
 
uint8 getNumActiveChannels () const
 
uint8 getNumUnlockedChannels () const
 
int16 findChannelByArgs (EngineState *s, int argc, const reg_t *argv, const int startIndex, const reg_t soundNode) const
 
int16 findChannelById (const ResourceId resourceId, const reg_t soundNode=NULL_REG) const
 
void lockResource (const ResourceId resourceId, const bool lock)
 
uint16 getSampleRate () const
 
void setSampleRate (uint16 rate)
 
uint8 getBitDepth () const
 
void setBitDepth (uint8 depth)
 
uint8 getNumOutputChannels () const
 
void setNumOutputChannels (int16 numChannels)
 
uint8 getPreload () const
 
void setPreload (uint8 preload)
 
bool playRobotAudio (const RobotAudioStream::RobotAudioPacket &packet)
 
bool queryRobotAudio (RobotAudioStream::StreamState &outStatus) const
 
bool finishRobotAudio ()
 
bool stopRobotAudio ()
 
uint16 play (int16 channelIndex, const ResourceId resourceId, const bool autoPlay, const bool loop, const int16 volume, const reg_t soundNode, const bool monitor)
 
bool resume (const int16 channelIndex)
 
bool resume (const ResourceId resourceId, const reg_t soundNode=NULL_REG)
 
bool pause (const int16 channelIndex)
 
bool pause (const ResourceId resourceId, const reg_t soundNode=NULL_REG)
 
int16 stop (const int16 channelIndex)
 
int16 stop (const ResourceId resourceId, const reg_t soundNode=NULL_REG)
 
uint16 restart (const ResourceId resourceId, const bool autoPlay, const bool loop, const int16 volume, const reg_t soundNode, const bool monitor)
 
int16 getPosition (const int16 channelIndex) const
 
int16 getPosition (const ResourceId resourceId, const reg_t soundNode=NULL_REG)
 
void setLoop (const int16 channelIndex, const bool loop)
 
void setLoop (const ResourceId resourceId, const reg_t soundNode, const bool loop)
 
void setPan (const int16 channelIndex, const int16 pan)
 
int16 getVolume (const int16 channelIndex) const
 
int16 getVolume (const ResourceId resourceId, const reg_t soundNode) const
 
void setVolume (const int16 channelIndex, int16 volume)
 
void setVolume (const ResourceId resourceId, const reg_t soundNode, const int16 volume)
 
void setMasterVolume (const int16 volume)
 
bool fadeChannel (const int16 channelIndex, const int16 targetVolume, const int16 speed, const int16 steps, const bool stopAfterFade)
 
bool fadeChannel (const ResourceId resourceId, const reg_t soundNode, const int16 targetVolume, const int16 speed, const int16 steps, const bool stopAfterFade)
 
bool getAttenuatedMixing () const
 
void setAttenuatedMixing (bool attenuated)
 
bool hasSignal () const
 
reg_t kernelPlay (const bool autoPlay, EngineState *s, const int argc, const reg_t *const argv)
 
reg_t kernelStop (EngineState *s, const int argc, const reg_t *const argv)
 
reg_t kernelPause (EngineState *s, const int argc, const reg_t *const argv)
 
reg_t kernelResume (EngineState *s, const int argc, const reg_t *const argv)
 
reg_t kernelPosition (EngineState *s, const int argc, const reg_t *const argv)
 
reg_t kernelVolume (EngineState *s, const int argc, const reg_t *const argv)
 
reg_t kernelMixing (const int argc, const reg_t *const argv)
 
reg_t kernelFade (EngineState *s, const int argc, const reg_t *const argv)
 
void kernelLoop (EngineState *s, const int argc, const reg_t *const argv)
 
void kernelPan (EngineState *s, const int argc, const reg_t *const argv)
 
void kernelPanOff (EngineState *s, const int argc, const reg_t *const argv)
 
void printAudioList (Console *con) const
 

Detailed Description

Audio32 acts as a permanent audio stream into the system mixer and provides digital audio services for the SCI32 engine, since the system mixer does not support all the features of SCI.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kMaxVolume 

The maximum channel volume.

Member Function Documentation

◆ readBuffer()

int Sci::Audio32::readBuffer ( Audio::st_sample_t *  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 Sci::Audio32::isStereo ( ) const
inlineoverridevirtual

Check whether this is a stereo stream.

Implements Audio::AudioStream.

◆ getRate()

int Sci::Audio32::getRate ( ) const
inlineoverridevirtual

Sample rate of the stream.

Implements Audio::AudioStream.

◆ endOfData()

bool Sci::Audio32::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.

◆ endOfStream()

bool Sci::Audio32::endOfStream ( ) const
inlineoverridevirtual

Check whether end of stream has been reached.

If this returns true, it indicates that all data in this stream is used up and no additional data will appear in it in the future.

This is used by the mixer to decide whether a given stream shall be removed from the list of active streams (and thus be destroyed). By default, this maps to endOfData().

Reimplemented from Audio::AudioStream.

◆ getNumActiveChannels()

uint8 Sci::Audio32::getNumActiveChannels ( ) const
inline

Gets the number of currently active channels.

◆ getNumUnlockedChannels()

uint8 Sci::Audio32::getNumUnlockedChannels ( ) const

Gets the number of currently active channels that are playing from unlocked resources.

Note
In SSCI, this function would actually return the number of channels whose audio data were not loaded into memory. In practice, the signal for placing audio data into memory was a call to kLock, so since we do not follow how SSCI works when it comes to resource management, the lock state is used as an (apparently) successful proxy for this information instead.

◆ findChannelByArgs()

int16 Sci::Audio32::findChannelByArgs ( EngineState s,
int  argc,
const reg_t argv,
const int  startIndex,
const reg_t  soundNode 
) const

Finds a channel that is already configured for the given audio sample.

Parameters
startIndexThe location of the audio resource information in the arguments list.

◆ findChannelById()

int16 Sci::Audio32::findChannelById ( const ResourceId  resourceId,
const reg_t  soundNode = NULL_REG 
) const

Finds a channel that is already configured for the given audio sample.

◆ lockResource()

void Sci::Audio32::lockResource ( const ResourceId  resourceId,
const bool  lock 
)

Sets or clears a lock on the given resource ID.

◆ getSampleRate()

uint16 Sci::Audio32::getSampleRate ( ) const
inline

Gets the (fake) sample rate of the hardware DAC. For script compatibility only.

◆ setSampleRate()

void Sci::Audio32::setSampleRate ( uint16  rate)

Sets the (fake) sample rate of the hardware DAC. For script compatibility only.

◆ getBitDepth()

uint8 Sci::Audio32::getBitDepth ( ) const
inline

Gets the (fake) bit depth of the hardware DAC. For script compatibility only.

◆ setBitDepth()

void Sci::Audio32::setBitDepth ( uint8  depth)

Sets the (fake) sample rate of the hardware DAC. For script compatibility only.

◆ getNumOutputChannels()

uint8 Sci::Audio32::getNumOutputChannels ( ) const
inline

Gets the (fake) number of output (speaker) channels of the hardware DAC. For script compatibility only.

◆ setNumOutputChannels()

void Sci::Audio32::setNumOutputChannels ( int16  numChannels)

Sets the (fake) number of output (speaker) channels of the hardware DAC. For script compatibility only.

◆ getPreload()

uint8 Sci::Audio32::getPreload ( ) const
inline

Gets the (fake) number of preloaded channels. For script compatibility only.

◆ setPreload()

void Sci::Audio32::setPreload ( uint8  preload)
inline

Sets the (fake) number of preloaded channels. For script compatibility only.

◆ play()

uint16 Sci::Audio32::play ( int16  channelIndex,
const ResourceId  resourceId,
const bool  autoPlay,
const bool  loop,
const int16  volume,
const reg_t  soundNode,
const bool  monitor 
)

Starts or resumes playback of an audio channel.

◆ resume()

bool Sci::Audio32::resume ( const int16  channelIndex)

Resumes playback of a paused audio channel, or of the entire audio player.

◆ pause()

bool Sci::Audio32::pause ( const int16  channelIndex)

Pauses an audio channel, or the entire audio player.

◆ stop()

int16 Sci::Audio32::stop ( const int16  channelIndex)

Stops and unloads an audio channel, or the entire audio player.

◆ restart()

uint16 Sci::Audio32::restart ( const ResourceId  resourceId,
const bool  autoPlay,
const bool  loop,
const int16  volume,
const reg_t  soundNode,
const bool  monitor 
)

Restarts playback of the given audio resource.

◆ getPosition()

int16 Sci::Audio32::getPosition ( const int16  channelIndex) const

Returns the playback position for the given channel number, in ticks.

◆ setLoop()

void Sci::Audio32::setLoop ( const int16  channelIndex,
const bool  loop 
)

Sets whether or not the given channel should loop.

◆ setPan()

void Sci::Audio32::setPan ( const int16  channelIndex,
const int16  pan 
)
inline

Sets the stereo panning for the given channel.

◆ getVolume()

int16 Sci::Audio32::getVolume ( const int16  channelIndex) const

Gets the volume for a given channel. Passing kAllChannels will get the global volume.

◆ setVolume()

void Sci::Audio32::setVolume ( const int16  channelIndex,
int16  volume 
)

Sets the volume of an audio channel. Passing kAllChannels will set the global volume.

◆ setMasterVolume()

void Sci::Audio32::setMasterVolume ( const int16  volume)
inline

Sets the master volume for digital audio playback.

◆ fadeChannel()

bool Sci::Audio32::fadeChannel ( const int16  channelIndex,
const int16  targetVolume,
const int16  speed,
const int16  steps,
const bool  stopAfterFade 
)

Initiate an immediate fade of the given channel.

◆ getAttenuatedMixing()

bool Sci::Audio32::getAttenuatedMixing ( ) const
inline

Gets whether attenuated mixing mode is active.

◆ setAttenuatedMixing()

void Sci::Audio32::setAttenuatedMixing ( bool  attenuated)
inline

Sets the attenuated mixing mode.

◆ hasSignal()

bool Sci::Audio32::hasSignal ( ) const

Returns whether the currently monitored audio channel contains any signal within the next audio frame.


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