From 0e64a38812b863965a6a2c899c0beab41c805a88 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 May 2023 18:56:42 +0200 Subject: [PATCH] - ported a few SNDINFO options from GZDoom. --- source/core/music/s_advsound.cpp | 77 ++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/source/core/music/s_advsound.cpp b/source/core/music/s_advsound.cpp index 260bc94e8..27f0752dc 100644 --- a/source/core/music/s_advsound.cpp +++ b/source/core/music/s_advsound.cpp @@ -65,6 +65,9 @@ enum SICommands SI_DukeFlags, SI_Loop, SI_BloodRelVol, + SI_Volume, + SI_Attenuation, + SI_Rolloff, }; @@ -101,6 +104,9 @@ static const char *SICommandStrings[] = "$dukeflags", "$loop", "$bloodrelvol", + "$volume", + "$attenuation", + "$rolloff", NULL }; @@ -335,6 +341,77 @@ static void S_AddSNDINFO (int lump) } break; + case SI_Volume: { + // $volume + FSoundID sfx; + + sc.MustGetString(); + sfx = soundEngine->FindSoundTentative(sc.String); + sc.MustGetFloat(); + auto sfxp = soundEngine->GetWritableSfx(sfx); + sfxp->Volume = (float)sc.Float; + } + break; + + case SI_Attenuation: { + // $attenuation + FSoundID sfx; + + sc.MustGetString(); + sfx = soundEngine->FindSoundTentative(sc.String); + sc.MustGetFloat(); + auto sfxp = soundEngine->GetWritableSfx(sfx); + sfxp->Attenuation = (float)sc.Float; + } + break; + + case SI_Rolloff: { + // $rolloff *| [linear|log|custom] + // Using * for the name makes it the default for sounds that don't specify otherwise. + FRolloffInfo* rolloff; + int type; + FSoundID sfx; + + sc.MustGetString(); + if (sc.Compare("*")) + { + sfx = INVALID_SOUND; + rolloff = &soundEngine->GlobalRolloff(); + } + else + { + sfx = soundEngine->FindSoundTentative(sc.String); + auto sfxp = soundEngine->GetWritableSfx(sfx); + rolloff = &sfxp->Rolloff; + } + type = ROLLOFF_Doom; + if (!sc.CheckFloat()) + { + sc.MustGetString(); + if (sc.Compare("linear")) + { + rolloff->RolloffType = ROLLOFF_Linear; + } + else if (sc.Compare("log")) + { + rolloff->RolloffType = ROLLOFF_Log; + } + else if (sc.Compare("custom")) + { + rolloff->RolloffType = ROLLOFF_Custom; + } + else + { + sc.ScriptError("Unknown rolloff type '%s'", sc.String); + } + sc.MustGetFloat(); + } + rolloff->MinDistance = (float)sc.Float; + sc.MustGetFloat(); + rolloff->MaxDistance = (float)sc.Float; + break; + } + case SI_PitchSet: { // $pitchset [range maximum] FSoundID sfx;