- Added S_ChangeSoundVolume() to change the volume of an already playing sound, accessible

through the new ACS function SoundVolume.

SVN r4318 (trunk)
This commit is contained in:
Randy Heit 2013-06-01 17:46:50 +00:00
parent 19eb09f9f7
commit 1b9c71b252
7 changed files with 73 additions and 1 deletions

View file

@ -4134,6 +4134,7 @@ enum EACSFunctions
ACSF_StrMid,
ACSF_GetActorClass,
ACSF_GetWeapon,
ACSF_SoundVolume,
// ZDaemon
ACSF_GetTeamScore = 19620, // (int team)
@ -4964,6 +4965,29 @@ doplaysound: if (!looping)
}
break;
case ACSF_SoundVolume:
// SoundVolume(int tid, int channel, fixed volume)
{
int chan = args[1];
float volume = FIXED2FLOAT(args[2]);
if (args[0] == 0)
{
S_ChangeSoundVolume(activator, chan, volume);
}
else
{
FActorIterator it(args[0]);
AActor *spot;
while ((spot = it.Next()) != NULL)
{
S_ChangeSoundVolume(spot, chan, volume);
}
}
}
break;
case ACSF_strcmp:
case ACSF_stricmp:
if (argCount >= 2)

View file

@ -1592,6 +1592,29 @@ void S_RelinkSound (AActor *from, AActor *to)
}
}
//==========================================================================
//
// S_ChangeSoundVolume
//
//==========================================================================
bool S_ChangeSoundVolume(AActor *actor, int channel, float volume)
{
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
{
if (chan->SourceType == SOURCE_Actor &&
chan->Actor == actor &&
(chan->EntChannel == channel || (i_compatflags & COMPATF_MAGICSILENCE)))
{
GSnd->ChannelVolume(chan, volume);
chan->Volume = volume;
return true;
}
}
return false;
}
//==========================================================================
//
// S_GetSoundPlayingInfo
@ -2136,7 +2159,6 @@ void S_StopChannel(FSoundChan *chan)
}
}
//==========================================================================
//
// (FArchive &) << (FSoundID &)

View file

@ -303,6 +303,9 @@ bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id);
bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id);
// Change a playing sound's volume
bool S_ChangeSoundVolume(AActor *actor, int channel, float volume);
// Moves all sounds from one mobj to another
void S_RelinkSound (AActor *from, AActor *to);

View file

@ -2053,6 +2053,20 @@ void FMODSoundRenderer::StopChannel(FISoundChannel *chan)
}
}
//==========================================================================
//
// FMODSoundRenderer :: ChannelVolume
//
//==========================================================================
void FMODSoundRenderer::ChannelVolume(FISoundChannel *chan, float volume)
{
if (chan != NULL && chan->SysChannel != NULL)
{
((FMOD::Channel *)chan->SysChannel)->setVolume(volume);
}
}
//==========================================================================
//
// FMODSoundRenderer :: GetPosition

View file

@ -33,6 +33,9 @@ public:
// Stops a sound channel.
void StopChannel (FISoundChannel *chan);
// Changes a channel's volume.
void ChannelVolume (FISoundChannel *chan, float volume);
// Marks a channel's start time without actually playing it.
void MarkStartTime (FISoundChannel *chan);

View file

@ -150,6 +150,9 @@ public:
void StopChannel(FISoundChannel *chan)
{
}
void ChannelVolume(FISoundChannel *, float)
{
}
// Streaming sounds.
SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata)

View file

@ -110,6 +110,9 @@ public:
// Stops a sound channel.
virtual void StopChannel (FISoundChannel *chan) = 0;
// Changes a channel's volume.
virtual void ChannelVolume (FISoundChannel *chan, float volume) = 0;
// Marks a channel's start time without actually playing it.
virtual void MarkStartTime (FISoundChannel *chan) = 0;