ScummVM
Kyra::Sound Class Referenceabstract

Analog audio output device API for Kyrandia games. More...

#include <sound.h>

Inheritance diagram for Kyra::Sound:
Collaboration diagram for Kyra::Sound:

Classes

struct  SoundChannel
 
struct  SpeechCodecs
 

Public Types

enum  kType {
  kAdLib, kMidiMT32, kMidiGM, kTowns,
  kPC98, kPCSpkr, kAmiga
}
 

Public Member Functions

 Sound (KyraEngine_v1 *vm, Audio::Mixer *mixer)
 
virtual ~Sound ()
 
virtual kType getMusicType () const =0
 
virtual kType getSfxType () const
 
virtual bool init ()=0
 Initializes the output device. More...
 
virtual void process ()
 Updates the device, this is needed for some devices. More...
 
virtual void updateVolumeSettings ()
 Updates internal volume settings according to ConfigManager. More...
 
virtual void initAudioResourceInfo (int set, void *info)=0
 Assigns static resource data with information on how to load audio resources to. More...
 
virtual void selectAudioResourceSet (int set)=0
 Select audio resource set. More...
 
virtual bool hasSoundFile (uint file) const =0
 Checks if a given sound file is present. More...
 
virtual void loadSoundFile (uint file)=0
 Load a specifc sound file for use of playing music and sound effects. More...
 
virtual void loadSoundFile (Common::String file)=0
 Load a sound file for playing music (and sometimes sound effects) from. More...
 
virtual void unloadSoundFile (Common::String file)
 Unload a specifc sound file that has been loaded before. More...
 
virtual void loadSfxFile (Common::String file)
 Load a sound file for playing sound effects from. More...
 
virtual void playTrack (uint8 track)=0
 Plays the specified track. More...
 
virtual void haltTrack ()=0
 Stop playback of the current track. More...
 
virtual void playSoundEffect (uint8 track, uint8 volume=0xFF)=0
 Plays the specified sound effect. More...
 
virtual void stopAllSoundEffects ()
 Stop playback of all sfx tracks. More...
 
virtual bool isPlaying () const
 Checks if the sound driver plays any sound. More...
 
virtual void beginFadeOut ()=0
 Starts fading out the volume. More...
 
virtual void beginFadeOut (int)
 
virtual void pause (bool paused)
 Stops all audio playback when paused. More...
 
void enableMusic (int enable)
 
int musicEnabled () const
 
void enableSFX (bool enable)
 
bool sfxEnabled () const
 
bool isVoicePresent (const char *file) const
 Checks whether a voice file with the given name is present. More...
 
virtual int32 voicePlay (const char *file, Audio::SoundHandle *handle=0, uint8 volume=255, uint8 priority=255, bool isSfx=false)
 Plays the specified voice file. More...
 
Audio::SeekableAudioStreamgetVoiceStream (const char *file) const
 
bool playVoiceStream (Audio::AudioStream *stream, Audio::SoundHandle *handle=0, uint8 volume=255, uint8 priority=255, bool isSfx=false)
 
bool voiceIsPlaying (const Audio::SoundHandle *handle=0) const
 Checks if a voice is being played. More...
 
bool allVoiceChannelsPlaying () const
 Checks if all voice handles are used. More...
 
uint32 voicePlayedTime (const Audio::SoundHandle &handle) const
 Checks how long a voice has been playing. More...
 
void voiceStop (const Audio::SoundHandle *handle=0)
 Stops playback of the current voice. More...
 
virtual int checkTrigger ()
 Receive notifications from a song at certain points. More...
 
virtual void resetTrigger ()
 Reset sound trigger. More...
 

Protected Types

enum  { kNumChannelHandles = 4 }
 

Protected Attributes

SoundChannel _soundChannels [kNumChannelHandles]
 
int _musicEnabled
 
bool _sfxEnabled
 
KyraEngine_v1_vm
 
Audio::Mixer_mixer
 

Static Private Attributes

static const SpeechCodecs _supportedCodecs []
 

Detailed Description

Analog audio output device API for Kyrandia games.

It contains functionality to play music tracks, sound effects and voices.

Definition at line 92 of file sound.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
kNumChannelHandles 

Definition at line 292 of file sound.h.

◆ kType

Enumerator
kAdLib 
kMidiMT32 
kMidiGM 
kTowns 
kPC98 
kPCSpkr 
kAmiga 

Definition at line 97 of file sound.h.

Constructor & Destructor Documentation

◆ Sound()

Kyra::Sound::Sound ( KyraEngine_v1 vm,
Audio::Mixer mixer 
)

Definition at line 38 of file sound.cpp.

◆ ~Sound()

Kyra::Sound::~Sound ( )
virtual

Definition at line 43 of file sound.cpp.

Member Function Documentation

◆ allVoiceChannelsPlaying()

bool Kyra::Sound::allVoiceChannelsPlaying ( ) const

Checks if all voice handles are used.

Returns
false when a handle is free, else true

Definition at line 158 of file sound.cpp.

◆ beginFadeOut() [1/2]

virtual void Kyra::Sound::beginFadeOut ( )
pure virtual

Starts fading out the volume.

This keeps fading out the output until it is silenced, but does not change the volume set by setVolume! It will automatically reset the volume when playing a new track or sound effect.

Implemented in Kyra::SoundAmiga_EoB, Kyra::SoundTowns_Darkmoon, Kyra::MixedSoundDriver, Kyra::SoundAmiga_LoK, Kyra::SoundTownsPC98_v2, Kyra::SoundPC98_LoK, Kyra::SoundTowns_LoK, Kyra::SoundMidiPC, and Kyra::SoundAdLibPC.

◆ beginFadeOut() [2/2]

virtual void Kyra::Sound::beginFadeOut ( int  )
inlinevirtual

Reimplemented in Kyra::SoundAmiga_EoB.

Definition at line 215 of file sound.h.

◆ checkTrigger()

virtual int Kyra::Sound::checkTrigger ( )
inlinevirtual

Receive notifications from a song at certain points.

Reimplemented in Kyra::SoundAmiga_EoB, Kyra::SoundTowns_Darkmoon, and Kyra::SoundAdLibPC.

Definition at line 285 of file sound.h.

◆ enableMusic()

void Kyra::Sound::enableMusic ( int  enable)
inline

Definition at line 222 of file sound.h.

◆ enableSFX()

void Kyra::Sound::enableSFX ( bool  enable)
inline

Definition at line 224 of file sound.h.

◆ getMusicType()

◆ getSfxType()

Sound::kType Kyra::Sound::getSfxType ( ) const
virtual

Reimplemented in Kyra::MixedSoundDriver.

Definition at line 46 of file sound.cpp.

◆ getVoiceStream()

Audio::SeekableAudioStream * Kyra::Sound::getVoiceStream ( const char *  file) const

Definition at line 80 of file sound.cpp.

◆ haltTrack()

◆ hasSoundFile()

virtual bool Kyra::Sound::hasSoundFile ( uint  file) const
pure virtual

Checks if a given sound file is present.

Parameters
tracktrack number
Returns
true if available, false otherwise

Implemented in Kyra::SoundAmiga_EoB, Kyra::SoundTowns_Darkmoon, Kyra::MixedSoundDriver, Kyra::SoundAmiga_LoK, Kyra::SoundTownsPC98_v2, Kyra::SoundPC98_LoK, Kyra::SoundTowns_LoK, Kyra::SoundMidiPC, and Kyra::SoundAdLibPC.

◆ init()

virtual bool Kyra::Sound::init ( )
pure virtual

◆ initAudioResourceInfo()

virtual void Kyra::Sound::initAudioResourceInfo ( int  set,
void info 
)
pure virtual

Assigns static resource data with information on how to load audio resources to.

Parameters
setvalue defined in AudioResourceSet enum info various types of resource info data (file list, file name pattern, struct, etc. - depending on the inheriting driver type)

Implemented in Kyra::SoundAmiga_EoB, Kyra::SoundTowns_Darkmoon, Kyra::MixedSoundDriver, Kyra::SoundAmiga_LoK, Kyra::SoundTownsPC98_v2, Kyra::SoundPC98_LoK, Kyra::SoundTowns_LoK, Kyra::SoundMidiPC, and Kyra::SoundAdLibPC.

◆ isPlaying()

bool Kyra::Sound::isPlaying ( ) const
virtual

Checks if the sound driver plays any sound.

Returns
true if playing, false otherwise

Reimplemented in Kyra::SoundTowns_Darkmoon, Kyra::MixedSoundDriver, Kyra::SoundMidiPC, and Kyra::SoundAdLibPC.

Definition at line 50 of file sound.cpp.

◆ isVoicePresent()

bool Kyra::Sound::isVoicePresent ( const char *  file) const

Checks whether a voice file with the given name is present.

Parameters
filefile name
Returns
true if available, false otherwise

Definition at line 54 of file sound.cpp.

◆ loadSfxFile()

virtual void Kyra::Sound::loadSfxFile ( Common::String  file)
inlinevirtual

Load a sound file for playing sound effects from.

Reimplemented in Kyra::MixedSoundDriver, and Kyra::SoundMidiPC.

Definition at line 172 of file sound.h.

◆ loadSoundFile() [1/2]

virtual void Kyra::Sound::loadSoundFile ( uint  file)
pure virtual

◆ loadSoundFile() [2/2]

virtual void Kyra::Sound::loadSoundFile ( Common::String  file)
pure virtual

◆ musicEnabled()

int Kyra::Sound::musicEnabled ( ) const
inline

Definition at line 223 of file sound.h.

◆ pause()

virtual void Kyra::Sound::pause ( bool  paused)
inlinevirtual

Stops all audio playback when paused.

Continues after end of pause.

Reimplemented in Kyra::MixedSoundDriver, and Kyra::SoundMidiPC.

Definition at line 220 of file sound.h.

◆ playSoundEffect()

virtual void Kyra::Sound::playSoundEffect ( uint8  track,
uint8  volume = 0xFF 
)
pure virtual

◆ playTrack()

virtual void Kyra::Sound::playTrack ( uint8  track)
pure virtual

◆ playVoiceStream()

bool Kyra::Sound::playVoiceStream ( Audio::AudioStream stream,
Audio::SoundHandle handle = 0,
uint8  volume = 255,
uint8  priority = 255,
bool  isSfx = false 
)

Definition at line 104 of file sound.cpp.

◆ process()

virtual void Kyra::Sound::process ( )
inlinevirtual

Updates the device, this is needed for some devices.

Reimplemented in Kyra::MixedSoundDriver, Kyra::SoundTownsPC98_v2, Kyra::SoundTowns_LoK, and Kyra::SoundAdLibPC.

Definition at line 120 of file sound.h.

◆ resetTrigger()

virtual void Kyra::Sound::resetTrigger ( )
inlinevirtual

Reset sound trigger.

Reimplemented in Kyra::SoundTowns_Darkmoon, and Kyra::SoundAdLibPC.

Definition at line 290 of file sound.h.

◆ selectAudioResourceSet()

virtual void Kyra::Sound::selectAudioResourceSet ( int  set)
pure virtual

◆ sfxEnabled()

bool Kyra::Sound::sfxEnabled ( ) const
inline

Definition at line 225 of file sound.h.

◆ stopAllSoundEffects()

virtual void Kyra::Sound::stopAllSoundEffects ( )
inlinevirtual

Stop playback of all sfx tracks.

Reimplemented in Kyra::SoundTowns_Darkmoon, Kyra::MixedSoundDriver, Kyra::SoundTowns_LoK, and Kyra::SoundMidiPC.

Definition at line 196 of file sound.h.

◆ unloadSoundFile()

virtual void Kyra::Sound::unloadSoundFile ( Common::String  file)
inlinevirtual

Unload a specifc sound file that has been loaded before.

Reimplemented in Kyra::SoundAmiga_EoB.

Definition at line 166 of file sound.h.

◆ updateVolumeSettings()

virtual void Kyra::Sound::updateVolumeSettings ( )
inlinevirtual

Updates internal volume settings according to ConfigManager.

Reimplemented in Kyra::SoundAmiga_EoB, Kyra::SoundTowns_Darkmoon, Kyra::MixedSoundDriver, Kyra::SoundTownsPC98_v2, Kyra::SoundPC98_LoK, Kyra::SoundTowns_LoK, Kyra::SoundMidiPC, and Kyra::SoundAdLibPC.

Definition at line 125 of file sound.h.

◆ voiceIsPlaying()

bool Kyra::Sound::voiceIsPlaying ( const Audio::SoundHandle handle = 0) const

Checks if a voice is being played.

Returns
true when playing, else false

Definition at line 145 of file sound.cpp.

◆ voicePlay()

int32 Kyra::Sound::voicePlay ( const char *  file,
Audio::SoundHandle handle = 0,
uint8  volume = 255,
uint8  priority = 255,
bool  isSfx = false 
)
virtual

Plays the specified voice file.

Also before starting to play the specified voice file, it stops the current voice.

Parameters
filefile to be played
volumevolume of the voice file
isSfxmarks file as sfx instead of voice
handlestore a copy of the sound handle
Returns
playtime of the voice file (-1 marks unknown playtime)

Reimplemented in Kyra::SoundAmiga_LoK, Kyra::SoundTownsPC98_v2, and Kyra::SoundPC98_LoK.

Definition at line 68 of file sound.cpp.

◆ voicePlayedTime()

uint32 Kyra::Sound::voicePlayedTime ( const Audio::SoundHandle handle) const
inline

Checks how long a voice has been playing.

Returns
time in milliseconds

Definition at line 273 of file sound.h.

◆ voiceStop()

void Kyra::Sound::voiceStop ( const Audio::SoundHandle handle = 0)

Stops playback of the current voice.

Definition at line 134 of file sound.cpp.

Member Data Documentation

◆ _mixer

Audio::Mixer* Kyra::Sound::_mixer
protected

Definition at line 308 of file sound.h.

◆ _musicEnabled

int Kyra::Sound::_musicEnabled
protected

Definition at line 304 of file sound.h.

◆ _sfxEnabled

bool Kyra::Sound::_sfxEnabled
protected

Definition at line 305 of file sound.h.

◆ _soundChannels

SoundChannel Kyra::Sound::_soundChannels[kNumChannelHandles]
protected

Definition at line 302 of file sound.h.

◆ _supportedCodecs

const Sound::SpeechCodecs Kyra::Sound::_supportedCodecs
staticprivate
Initial value:
= {
{ ".VOC", makeVOCStream },
{ "", makeVOCStream },
{ ".VO3", Audio::makeMP3Stream },
{ ".MP3", Audio::makeMP3Stream },
{ ".VOF", Audio::makeFLACStream },
{ ".FLA", Audio::makeFLACStream },
{ 0, 0 }
}

Definition at line 318 of file sound.h.

◆ _vm

KyraEngine_v1* Kyra::Sound::_vm
protected

Definition at line 307 of file sound.h.


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