Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Core/GameEngine/Include/Common/GameAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ enum
local player affiliation, etc. (The entire list of checks is contained in shouldPlayLocally()).

In addition, the world and unit audio are never allowed to exceed their footprint, as specified
in the audio settings INI file. In order to accomodate this, the audio uses an audio cache. The
in the audio settings INI file. In order to accommodate this, the audio uses an audio cache. The
audio cache will attempt to load a sample, assuming there is enough room. If there is not enough
room, then it goes through and finds any samples that are lower priority, and kills them until
enough room is present for the sample. If it cannot free enough room, nothing happens to the
Expand Down Expand Up @@ -190,7 +190,7 @@ class AudioManager : public SubsystemInterface
virtual void closeDevice( void ) = 0;
virtual void *getDevice( void ) = 0;

// Debice Dependent notification functions
// Device Dependent notification functions
virtual void notifyOfAudioCompletion( UnsignedInt audioCompleted, UnsignedInt flags ) = 0;

// Device Dependent enumerate providers functions. It is okay for there to be only 1 provider (Miles provides a maximum of 64.
Expand Down
24 changes: 10 additions & 14 deletions Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,14 +724,13 @@ void AudioEventRTS::setVolume( Real vol )
//-------------------------------------------------------------------------------------------------
const Coord3D *AudioEventRTS::getCurrentPosition( void )
{
if (m_ownerType == OT_Positional)
switch (m_ownerType)
{
case OT_Positional:
return &m_positionOfAudio;
}
else if (m_ownerType == OT_Object)
{
Object *obj = TheGameLogic->findObjectByID(m_objectID);
if (obj)

case OT_Object:
if (Object *obj = TheGameLogic->findObjectByID(m_objectID))
{
m_positionOfAudio.set( obj->getPosition() );
}
Expand All @@ -740,11 +739,9 @@ const Coord3D *AudioEventRTS::getCurrentPosition( void )
m_ownerType = OT_Dead;
}
return &m_positionOfAudio;
}
else if (m_ownerType == OT_Drawable)
{
Drawable *draw = TheGameClient->findDrawableByID(m_drawableID);
if( draw )

case OT_Drawable:
if (Drawable *draw = TheGameClient->findDrawableByID(m_drawableID))
{
m_positionOfAudio.set( draw->getPosition() );
}
Expand All @@ -753,9 +750,8 @@ const Coord3D *AudioEventRTS::getCurrentPosition( void )
m_ownerType = OT_Dead;
}
return &m_positionOfAudio;
}
else if( m_ownerType == OT_Dead )
{

case OT_Dead:
return &m_positionOfAudio;
}

Expand Down
18 changes: 10 additions & 8 deletions Core/GameEngine/Source/Common/Audio/GameAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,12 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
}
}

switch (eventToAdd->getAudioEventInfo()->m_soundType)
const AudioType soundType = eventToAdd->getAudioEventInfo()->m_soundType;

// Check if audio type is on
// TheSuperHackers @info Zero audio volume is not a fail condition, because music, speech and sounds
// still need to be in flight in case the user raises the volume on runtime after the audio was already triggered.
switch (soundType)
{
case AT_Music:
if (!isOn(AudioAffect_Music))
Expand All @@ -430,16 +435,14 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
return AHSV_NoSound;
break;
case AT_Streaming:
// if we're currently playing uninterruptable speech, then disallow the addition of this sample
if (getDisallowSpeech())
return AHSV_NoSound;
if (!isOn(AudioAffect_Speech))
return AHSV_NoSound;
break;
}

// if we're currently playing uninterruptable speech, then disallow the addition of this sample
if (getDisallowSpeech() && eventToAdd->getAudioEventInfo()->m_soundType == AT_Streaming) {
return AHSV_NoSound;
}

if (!eventToAdd->getUninterruptable()) {
if (!shouldPlayLocally(eventToAdd)) {
return AHSV_NotForLocal;
Expand Down Expand Up @@ -469,8 +472,7 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
return AHSV_Muted;
}

AudioType type = eventToAdd->getAudioEventInfo()->m_soundType;
if (type == AT_Music)
if (soundType == AT_Music)
{
m_music->addAudioEvent(audioEvent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2677,25 +2677,29 @@ Bool MilesAudioManager::isOnScreen( const Coord3D *pos ) const
//-------------------------------------------------------------------------------------------------
Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const
{
Real volume = 1.0f;
volume *= (event->getVolume() * event->getVolumeShift());
if (event->getAudioEventInfo()->m_soundType == AT_Music)
Real volume = event->getVolume() * event->getVolumeShift();

switch (event->getAudioEventInfo()->m_soundType)
{
case AT_Music:
{
volume *= m_musicVolume;
break;
}
else if (event->getAudioEventInfo()->m_soundType == AT_Streaming)
case AT_Streaming:
{
volume *= m_speechVolume;
break;
}
else
case AT_SoundEffect:
{
if (event->isPositionalAudio())
{
volume *= m_sound3DVolume;
Coord3D distance = m_listenerPosition;
const Coord3D *pos = event->getCurrentPosition();
if (pos)
{
Coord3D distance = m_listenerPosition;
distance.sub(pos);
Real objMinDistance;
Real objMaxDistance;
Expand Down Expand Up @@ -2730,6 +2734,8 @@ Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const
{
volume *= m_soundVolume;
}
break;
}
}

return volume;
Expand Down
Loading