Skip to content

Commit

Permalink
Added S_StartSoundAt
Browse files Browse the repository at this point in the history
Allows for positional sounds that aren't attached to any Actor.
  • Loading branch information
Boondorl committed Jan 17, 2025
1 parent f5bf1d0 commit a5537d5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/sound/s_doomsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void S_InitData()

void S_SoundPitch(int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, float pitch, float startTime)
{
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, channel, flags, sound_id, volume, attenuation, 0, pitch);
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, channel, flags, sound_id, volume, attenuation, nullptr, pitch, startTime);
}

void S_Sound(int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation)
Expand Down Expand Up @@ -414,6 +414,29 @@ DEFINE_ACTION_FUNCTION(DObject, S_StartSound)
return 0;
}

static void S_StartSoundAt(double x, double y, double z, int sound_id, int channel, int flags, double volume, double attenuation, double pitch, double startTime)
{
FVector3 pos = { (float)x, (float)z, (float)y };
soundEngine->StartSound(SOURCE_Unattached, nullptr, &pos, channel, EChanFlags::FromInt(flags), FSoundID::fromInt(sound_id), (float)volume, (float)attenuation, nullptr, (float)pitch, (float)startTime);
}

DEFINE_ACTION_FUNCTION_NATIVE(DObject, S_StartSoundAt, S_StartSoundAt)
{
PARAM_PROLOGUE;
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(z);
PARAM_INT(id);
PARAM_INT(channel);
PARAM_INT(flags);
PARAM_FLOAT(volume);
PARAM_FLOAT(attn);
PARAM_FLOAT(pitch);
PARAM_FLOAT(startTime);
S_StartSoundAt(x, y, z, id, channel, flags, volume, attn, pitch, startTime);
return 0;
}


//==========================================================================
//
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/doombase.zs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ extend class Object
}
deprecated("4.3", "Use S_StartSound() instead") native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0);
native static void S_StartSound (Sound sound_id, int channel, int flags = 0, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0);
native static void S_StartSoundAt(Vector3 pos, Sound sound_id, int channel, int flags = 0, double volume = 1, double attenuation = ATTN_NORM, double pitch = 0.0, double startTime = 0.0);
native static void S_PauseSound (bool notmusic, bool notsfx);
native static void S_ResumeSound (bool notsfx);
native static bool S_ChangeMusic(String music_name, int order = 0, bool looping = true, bool force = false);
Expand Down

0 comments on commit a5537d5

Please sign in to comment.