From aef34f9aa5916064ae9b5d74409854019af17318 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 25 Mar 2008 04:42:26 +0000 Subject: [PATCH] - Removed xlat_parser.h from the repository. Lemon was always being run on xlat_parser.y because both files had the same time stamp after an update, and Lemon only rewrites the header file if it's changed. - Added $volume SNDINFO command. This is multiplied with the volume the sound is played at to arrive at the final volume (before distance attenuation). - Added the CHAN_AREA flag to disable 3D panning within the min distance of a sound. Sector sound sequences (except doors) use this flag. - Added the CHAN_LOOP flag to replace the S_Looped* sound functions. - Restored the sound limiting. SVN r849 (trunk) --- docs/rh-log.txt | 13 +- src/g_heretic/a_hereticweaps.cpp | 4 +- src/g_hexen/a_serpent.cpp | 2 +- src/g_strife/a_inquisitor.cpp | 4 +- src/g_strife/a_strifestuff.cpp | 2 +- src/p_acs.cpp | 2 +- src/p_ceiling.cpp | 8 +- src/p_doors.cpp | 8 +- src/p_floor.cpp | 4 +- src/p_pillar.cpp | 4 +- src/p_plats.cpp | 8 +- src/s_advsound.cpp | 27 +- src/s_sndseq.cpp | 52 ++-- src/s_sndseq.h | 8 +- src/s_sound.cpp | 188 ++++++------- src/s_sound.h | 16 +- src/sound/fmodsound.cpp | 180 +++++++------ src/sound/fmodsound.h | 7 +- src/sound/i_sound.h | 4 +- src/thingdef/thingdef_codeptr.cpp | 2 +- src/xlat/xlat_parser.h | 37 --- wadsrc/sndinfo.txt | 92 +++++++ wadsrc/wadsrc.vcproj | 6 +- zdoom.vcproj | 428 +++++++++++++++--------------- 24 files changed, 593 insertions(+), 513 deletions(-) delete mode 100644 src/xlat/xlat_parser.h diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 1bacdaf48..0168dfd82 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,14 @@ +March 24, 2008 +- Removed xlat_parser.h from the repository. Lemon was always being run on + xlat_parser.y because both files had the same time stamp after an update, + and Lemon only rewrites the header file if it's changed. +- Added $volume SNDINFO command. This is multiplied with the volume the sound + is played at to arrive at the final volume (before distance attenuation). +- Added the CHAN_AREA flag to disable 3D panning within the min distance of a + sound. Sector sound sequences (except doors) use this flag. +- Added the CHAN_LOOP flag to replace the S_Looped* sound functions. +- Restored the sound limiting. + March 24, 2008 (Changes by Graf Zahl) - Added Thomas's submissions for decal assignment to puffs and NOINFIGHTING flag. - Reverted changes of r715 in v_collection.cpp because they broke loading @@ -469,7 +480,7 @@ February 26, 2008 - More write barriers and pointer declarations. Here are rules I've come up with so far for when write barriers can be ommitted: * Initializing pointers for a newly created object: A new object can never - black, so none of its pointers that get set by the constructor (or code + be black, so none of its pointers that get set by the constructor (or code just following its creation) need to be behind write barriers. * Creating a new thinker and storing it in a pointer: The thinker constructor already puts it behind a write barrier when it links it into diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 8874729b2..0acff0794 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -2538,7 +2538,7 @@ void A_SkullRodStorm (AActor *actor) P_CheckMissileSpawn (mo); if (actor->special1 != -1 && !S_IsActorPlayingSomething (actor, CHAN_BODY, -1)) { - S_LoopedSoundID (actor, CHAN_BODY, actor->special1, 1, ATTN_NORM); + S_SoundID (actor, CHAN_BODY|CHAN_LOOP, actor->special1, 1, ATTN_NORM); } } @@ -2912,7 +2912,7 @@ void A_FirePhoenixPL2 (AActor *actor) mo->momz = FixedMul (mo->Speed, slope); if (!player->refire || !S_IsActorPlayingSomething (pmo, CHAN_WEAPON, -1)) { - S_LoopedSoundID (pmo, CHAN_WEAPON, soundid, 1, ATTN_NORM); + S_SoundID (pmo, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM); } P_CheckMissileSpawn (mo); } diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index 8973eb7e3..1b1064111 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -708,7 +708,7 @@ void A_SerpentFXSound (AActor *actor) { if (!S_IsActorPlayingSomething (actor, CHAN_BODY, -1)) { - S_LoopedSound (actor, CHAN_BODY, "SerpentFXContinuous", 1, ATTN_NORM); + S_Sound (actor, CHAN_BODY|CHAN_LOOP, "SerpentFXContinuous", 1, ATTN_NORM); } } diff --git a/src/g_strife/a_inquisitor.cpp b/src/g_strife/a_inquisitor.cpp index a96b0166e..41219f744 100644 --- a/src/g_strife/a_inquisitor.cpp +++ b/src/g_strife/a_inquisitor.cpp @@ -246,7 +246,7 @@ void A_InquisitorJump (AActor *self) if (self->target == NULL) return; - S_LoopedSound (self, CHAN_ITEM, "inquisitor/jump", 1, ATTN_NORM); + S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); self->z += 64*FRACUNIT; A_FaceTarget (self); an = self->angle >> ANGLETOFINESHIFT; @@ -280,7 +280,7 @@ void A_InquisitorCheckLand (AActor *self) } if (!S_IsActorPlayingSomething (self, CHAN_ITEM, -1)) { - S_LoopedSound (self, CHAN_ITEM, "inquisitor/jump", 1, ATTN_NORM); + S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); } } diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index cf396d9c2..b57e54795 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -809,7 +809,7 @@ void A_LoopActiveSound (AActor *self) { if (self->ActiveSound != 0 && !S_IsActorPlayingSomething (self, CHAN_VOICE, -1)) { - S_LoopedSoundID (self, CHAN_VOICE, self->ActiveSound, 1, ATTN_NORM); + S_SoundID (self, CHAN_VOICE|CHAN_LOOP, self->ActiveSound, 1, ATTN_NORM); } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 29fa191ba..c7f99b136 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4182,7 +4182,7 @@ int DLevelScript::RunScript () { if (activationline) { - SN_StartSequence (activationline->frontsector, lookup, 0); + SN_StartSequence (activationline->frontsector, lookup, 0, true); } } sp--; diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index b6cfe14e1..ac51d6bf5 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -64,16 +64,16 @@ void DCeiling::PlayCeilingSound () { if (m_Sector->seqType >= 0) { - SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_PLATFORM, 0); + SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_PLATFORM, 0, false); } else { if (m_Silent == 2) - SN_StartSequence (m_Sector, "Silence", 0); + SN_StartSequence (m_Sector, "Silence", 0, false); else if (m_Silent == 1) - SN_StartSequence (m_Sector, "CeilingSemiSilent", 0); + SN_StartSequence (m_Sector, "CeilingSemiSilent", 0, false); else - SN_StartSequence (m_Sector, "CeilingNormal", 0); + SN_StartSequence (m_Sector, "CeilingNormal", 0, false); } } diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 1d92ed3da..a2edd2a5a 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -236,7 +236,7 @@ void DDoor::DoorSound (bool raise) const if (m_Sector->seqType >= 0) { - SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_DOOR, choice); + SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_DOOR, choice, true); } else { @@ -297,7 +297,7 @@ void DDoor::DoorSound (bool raise) const } break; } - SN_StartSequence (m_Sector, snd, choice); + SN_StartSequence (m_Sector, snd, choice, true); } } @@ -564,7 +564,7 @@ bool DAnimatedDoor::StartClosing () m_Line2->flags |= ML_BLOCKING; if (ani.CloseSound != NULL) { - SN_StartSequence (m_Sector, ani.CloseSound, 1); + SN_StartSequence (m_Sector, ani.CloseSound, 1, true); } m_Status = Closing; @@ -742,7 +742,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay) MoveCeiling (2048*FRACUNIT, topdist, 1); if (DoorAnimations[m_WhichDoorIndex].OpenSound != NULL) { - SN_StartSequence (m_Sector, DoorAnimations[m_WhichDoorIndex].OpenSound, 1); + SN_StartSequence (m_Sector, DoorAnimations[m_WhichDoorIndex].OpenSound, 1, true); } } diff --git a/src/p_floor.cpp b/src/p_floor.cpp index cf1fdfb68..72a9c790b 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -298,11 +298,11 @@ static void StartFloorSound (sector_t *sec) { if (sec->seqType >= 0) { - SN_StartSequence (sec, sec->seqType, SEQ_PLATFORM, 0); + SN_StartSequence (sec, sec->seqType, SEQ_PLATFORM, 0, false); } else { - SN_StartSequence (sec, "Floor", 0); + SN_StartSequence (sec, "Floor", 0, false); } } diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index 96bf37534..a0934cecc 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -169,9 +169,9 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, } if (sector->seqType >= 0) - SN_StartSequence (sector, sector->seqType, SEQ_PLATFORM, 0); + SN_StartSequence (sector, sector->seqType, SEQ_PLATFORM, 0, false); else - SN_StartSequence (sector, "Floor", 0); + SN_StartSequence (sector, "Floor", 0, false); } bool EV_DoPillar (DPillar::EPillar type, int tag, fixed_t speed, fixed_t height, diff --git a/src/p_plats.cpp b/src/p_plats.cpp index c5858278d..1eebc9195 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -58,9 +58,9 @@ void DPlat::Serialize (FArchive &arc) void DPlat::PlayPlatSound (const char *sound) { if (m_Sector->seqType >= 0) - SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_PLATFORM, 0); + SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_PLATFORM, 0, false); else - SN_StartSequence (m_Sector, sound, 0); + SN_StartSequence (m_Sector, sound, 0, false); } // @@ -174,7 +174,7 @@ void DPlat::Tick () m_Status = down; if (m_Type == platToggle) - SN_StartSequence (m_Sector, "Silence", 0); + SN_StartSequence (m_Sector, "Silence", 0, false); else PlayPlatSound ("Platform"); } @@ -352,7 +352,7 @@ manual_plat: plat->m_Low = sec->floorplane.PointToDist (spot, newheight); plat->m_High = sec->floorplane.d; plat->m_Status = DPlat::down; - SN_StartSequence (sec, "Silence", 0); + SN_StartSequence (sec, "Silence", 0, false); break; case DPlat::platDownToNearestFloor: diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index eeac85610..64647ca14 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -147,6 +147,7 @@ enum SICommands SI_IfHexen, SI_IfStrife, SI_Rolloff, + SI_Volume, }; // Blood was a cool game. If Monolith ever releases the source for it, @@ -186,7 +187,7 @@ MidiDeviceMap MidiDevices; // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel, - const char *name, float volume, float attenuation, bool looping); + const char *name, float volume, float attenuation); extern bool IsFloat (const char *str); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -242,6 +243,7 @@ static const char *SICommandStrings[] = "$ifhexen", "$ifstrife", "$rolloff", + "$volume", NULL }; @@ -440,8 +442,9 @@ int S_AddSoundLump (const char *logicalname, int lump) newsfx.lumpnum = lump; newsfx.next = 0; newsfx.index = 0; - newsfx.frequency = 0; + newsfx.Volume = 1; newsfx.PitchMask = CurrentPitchMask; + newsfx.NearLimit = 2; newsfx.bRandomHeader = false; newsfx.bPlayerReserve = false; newsfx.bForce11025 = false; @@ -1105,12 +1108,13 @@ static void S_AddSNDINFO (int lump) break; case SI_Limit: { - // $limit -- deprecated and ignored + // $limit int sfx; sc.MustGetString (); sfx = S_FindSoundTentative (sc.String); sc.MustGetNumber (); + S_sfx[sfx].NearLimit = MIN(MAX(sc.Number, 0), 255); } break; @@ -1141,6 +1145,17 @@ static void S_AddSNDINFO (int lump) CurrentPitchMask = (1 << clamp (sc.Number, 0, 7)) - 1; break; + case SI_Volume: { + // $volume + int sfx; + + sc.MustGetString(); + sfx = S_FindSoundTentative(sc.String); + sc.MustGetFloat(); + S_sfx[sfx].Volume = 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. @@ -1867,8 +1882,8 @@ void AAmbientSound::Tick () if (ambient->sound[0]) { - S_StartNamedSound (this, NULL, CHAN_BODY, ambient->sound, - ambient->volume, ambient->attenuation, true); + S_StartNamedSound (this, NULL, CHAN_BODY|CHAN_LOOP, ambient->sound, + ambient->volume, ambient->attenuation); SetTicker (ambient); } else @@ -1881,7 +1896,7 @@ void AAmbientSound::Tick () if (ambient->sound[0]) { S_StartNamedSound (this, NULL, CHAN_BODY, ambient->sound, - ambient->volume, ambient->attenuation, false); + ambient->volume, ambient->attenuation); SetTicker (ambient); } else diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index 412abba62..72f29b90f 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -102,8 +102,7 @@ public: DSeqActorNode (AActor *actor, int sequence, int modenum); void Destroy (); void Serialize (FArchive &arc); - void MakeSound () { S_SoundID (m_Actor, CHAN_BODY, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); } - void MakeLoopedSound () { S_LoopedSoundID (m_Actor, CHAN_BODY, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); } + void MakeSound (int loop) { S_SoundID (m_Actor, CHAN_BODY|loop, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); } bool IsPlaying () { return S_IsActorPlayingSomething (m_Actor, CHAN_BODY, m_CurrentSoundID); } void *Source () { return m_Actor; } DSeqNode *SpawnChild (int seqnum) { return SN_StartSequence (m_Actor, seqnum, SEQ_NOTRANS, m_ModeNum, true); } @@ -119,8 +118,7 @@ public: DSeqPolyNode (polyobj_t *poly, int sequence, int modenum); void Destroy (); void Serialize (FArchive &arc); - void MakeSound () { S_SoundID (&m_Poly->startSpot[0], CHAN_BODY, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); } - void MakeLoopedSound () { S_LoopedSoundID (&m_Poly->startSpot[0], CHAN_BODY, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); } + void MakeSound (int loop) { S_SoundID (&m_Poly->startSpot[0], CHAN_BODY|loop, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); } bool IsPlaying () { return S_GetSoundPlayingInfo (&m_Poly->startSpot[0], m_CurrentSoundID); } void *Source () { return m_Poly; } DSeqNode *SpawnChild (int seqnum) { return SN_StartSequence (m_Poly, seqnum, SEQ_NOTRANS, m_ModeNum, true); } @@ -133,11 +131,10 @@ class DSeqSectorNode : public DSeqNode { DECLARE_CLASS (DSeqSectorNode, DSeqNode) public: - DSeqSectorNode (sector_t *sec, int sequence, int modenum); + DSeqSectorNode (sector_t *sec, int sequence, int modenum, bool is_door); void Destroy (); void Serialize (FArchive &arc); - void MakeSound () { S_SoundID (&m_Sector->soundorg[0], CHAN_BODY, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); Looping = false; } - void MakeLoopedSound () { S_LoopedSoundID (&m_Sector->soundorg[0], CHAN_BODY, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); Looping = true; } + void MakeSound (int loop) { S_SoundID (&m_Sector->soundorg[0], CHAN_BODY|(m_IsDoor ? 0 : CHAN_AREA)|loop, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); Looping = !!loop; } bool IsPlaying () { return S_GetSoundPlayingInfo (m_Sector->soundorg, m_CurrentSoundID); } void *Source () { return m_Sector; } DSeqNode *SpawnChild (int seqnum) { return SN_StartSequence (m_Sector, seqnum, SEQ_NOTRANS, m_ModeNum, true); } @@ -145,6 +142,7 @@ public: private: DSeqSectorNode() {} sector_t *m_Sector; + bool m_IsDoor; }; // When destroyed, destroy the sound sequences too. @@ -397,7 +395,7 @@ IMPLEMENT_CLASS (DSeqSectorNode) void DSeqSectorNode::Serialize (FArchive &arc) { Super::Serialize (arc); - arc << m_Sector << Looping; + arc << m_Sector << Looping << m_IsDoor; } //========================================================================== @@ -410,15 +408,18 @@ static void AssignTranslations (FScanner &sc, int seq, seqtype_t type) { sc.Crossed = false; - while (sc.GetString () && !sc.Crossed) + while (sc.GetString() && !sc.Crossed) { - if (IsNum (sc.String)) + if (IsNum(sc.String)) { SeqTrans[(atoi(sc.String) & 63) + type * 64] = seq; + if (type == SEQ_DOOR) + { + Sequences[seq]->bDoorSound |= true; + } } } - - sc.UnGet (); + sc.UnGet(); } //========================================================================== @@ -446,11 +447,14 @@ static void AssignHexenTranslations (void) int trans; if (HexenSequences[i].Seqs[j] & 0x40) - trans = 64; + { + trans = 64 * SEQ_DOOR; + Sequences[seq]->bDoorSound |= true; + } else if (HexenSequences[i].Seqs[j] & 0x80) - trans = 64*2; + trans = 64 * SEQ_ENVIRONMENT; else - trans = 0; + trans = 64 * SEQ_PLATFORM; SeqTrans[trans + (HexenSequences[i].Seqs[j] & 0x3f)] = seq; } @@ -690,6 +694,7 @@ static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, c Sequences[curseq]->SeqName = seqname; Sequences[curseq]->Slot = slot; Sequences[curseq]->StopSound = stopsound; + Sequences[curseq]->bDoorSound = false; memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(DWORD)*ScriptTemp.Size()); Sequences[curseq]->Script[ScriptTemp.Size()] = MakeCommand(SS_CMD_END, 0); } @@ -738,11 +743,12 @@ DSeqPolyNode::DSeqPolyNode (polyobj_t *poly, int sequence, int modenum) { } -DSeqSectorNode::DSeqSectorNode (sector_t *sec, int sequence, int modenum) +DSeqSectorNode::DSeqSectorNode (sector_t *sec, int sequence, int modenum, bool is_door) : DSeqNode (sequence, modenum), Looping (false), m_Sector (sec) { + m_IsDoor = is_door; } //========================================================================== @@ -786,7 +792,7 @@ DSeqNode *SN_StartSequence (AActor *actor, int sequence, seqtype_t type, int mod return NULL; } -DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int modenum, bool nostop) +DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int modenum, bool is_door, bool nostop) { if (!nostop) { @@ -794,7 +800,7 @@ DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int } if (TwiddleSeqNum (sequence, type)) { - return new DSeqSectorNode (sector, sequence, modenum); + return new DSeqSectorNode (sector, sequence, modenum, is_door); } return NULL; } @@ -838,12 +844,12 @@ DSeqNode *SN_StartSequence (AActor *actor, FName seqname, int modenum) return NULL; } -DSeqNode *SN_StartSequence (sector_t *sec, const char *seqname, int modenum) +DSeqNode *SN_StartSequence (sector_t *sec, const char *seqname, int modenum, bool is_door) { int seqnum = FindSequence (seqname); if (seqnum >= 0) { - return SN_StartSequence (sec, seqnum, SEQ_NOTRANS, modenum); + return SN_StartSequence (sec, seqnum, SEQ_NOTRANS, modenum, is_door); } return NULL; } @@ -992,7 +998,7 @@ void DSeqNode::Tick () if (!IsPlaying()) { m_CurrentSoundID = GetData(*m_SequencePtr); - MakeSound (); + MakeSound (0); } m_SequencePtr++; break; @@ -1014,7 +1020,7 @@ void DSeqNode::Tick () { // Does not advance sequencePtr, so it will repeat as necessary. m_CurrentSoundID = GetData(*m_SequencePtr); - MakeLoopedSound (); + MakeSound (CHAN_LOOP); } return; @@ -1022,7 +1028,7 @@ void DSeqNode::Tick () // Like SS_CMD_PLAYREPEAT, sequencePtr is not advanced, so this // command will repeat until the sequence is stopped. m_CurrentSoundID = GetData(m_SequencePtr[0]); - MakeSound (); + MakeSound (0); m_DelayUntilTic = TIME_REFERENCE + m_SequencePtr[1]; return; diff --git a/src/s_sndseq.h b/src/s_sndseq.h index 46ca46425..234f70e53 100644 --- a/src/s_sndseq.h +++ b/src/s_sndseq.h @@ -30,8 +30,7 @@ public: void AddChoice (int seqnum, seqtype_t type); FName GetSequenceName() const; - virtual void MakeSound () {} - virtual void MakeLoopedSound () {} + virtual void MakeSound (int loop) {} virtual void *Source () { return NULL; } virtual bool IsPlaying () { return false; } virtual DSeqNode *SpawnChild (int seqnum) { return NULL; } @@ -75,6 +74,7 @@ struct FSoundSequence FName SeqName; FName Slot; int StopSound; + bool bDoorSound; SDWORD Script[1]; // + more until end of sequence script }; @@ -82,8 +82,8 @@ void S_ParseSndSeq (int levellump); DSeqNode *SN_StartSequence (AActor *mobj, int sequence, seqtype_t type, int modenum, bool nostop=false); DSeqNode *SN_StartSequence (AActor *mobj, const char *name, int modenum); DSeqNode *SN_StartSequence (AActor *mobj, FName seqname, int modenum); -DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int modenum, bool nostop=false); -DSeqNode *SN_StartSequence (sector_t *sector, const char *name, int modenum); +DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int modenum, bool full3d, bool nostop=false); +DSeqNode *SN_StartSequence (sector_t *sector, const char *name, int modenum, bool full3d); DSeqNode *SN_StartSequence (polyobj_t *poly, int sequence, seqtype_t type, int modenum, bool nostop=false); DSeqNode *SN_StartSequence (polyobj_t *poly, const char *name, int modenum); void SN_StopSequence (AActor *mobj); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index d06613143..467e51545 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -92,11 +92,12 @@ extern float S_GetMusicVolume (const char *music); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -static fixed_t P_AproxDistance2 (fixed_t *listener, fixed_t x, fixed_t y); -static void S_StartSound (fixed_t *pt, AActor *mover, int channel, - int sound_id, float volume, float attenuation, bool looping); -static void S_ActivatePlayList (bool goBack); -static void CalcPosVel (fixed_t *pt, AActor *mover, int constz, float pos[3], +static fixed_t P_AproxDistance2(fixed_t *listener, fixed_t x, fixed_t y); +static void S_StartSound(fixed_t *pt, AActor *mover, int channel, + int sound_id, float volume, float attenuation); +static bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3]); +static void S_ActivatePlayList(bool goBack); +static void CalcPosVel(fixed_t *pt, AActor *mover, int constz, float pos[3], float vel[3]); // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -192,7 +193,7 @@ void S_NoiseDebug (void) char temp[16]; fixed_t *origin = chan->Pt; - if (!chan->Is3D) + if (!(chan->ChanFlags & CHAN_IS3D)) { ox = players[consoleplayer].camera->x; oy = players[consoleplayer].camera->y; @@ -210,7 +211,7 @@ void S_NoiseDebug (void) oy = chan->Y; oz = chan->Z; } - color = chan->Loop ? CR_BROWN : CR_GREY; + color = (chan->ChanFlags & CHAN_LOOP) ? CR_BROWN : CR_GREY; Wads.GetLumpName (temp, chan->SfxInfo->lumpnum); temp[8] = 0; screen->DrawText (color, 0, y, temp, TAG_DONE); @@ -310,6 +311,7 @@ void S_Shutdown () { GSnd->StopSound(Channels); } + GSnd->UpdateSounds(); } else { @@ -382,11 +384,11 @@ void S_Start () } // Also reload the SNDSEQ if the SNDINFO was replaced! - parse_ss=true; + parse_ss = true; } else if (LastLocalSndSeq.CompareNoCase(LocalSndSeq) != 0) { - parse_ss=true; + parse_ss = true; } if (parse_ss) { @@ -587,7 +589,7 @@ void S_LinkChannel(FSoundChan *chan, FSoundChan **head) void CalcPosVel (fixed_t *pt, AActor *mover, int constz, float pos[3], float vel[3]) { - if (mover != NULL && 0) + if (mover != NULL) { vel[0] = FIXED2FLOAT(mover->momx) * TICRATE; vel[1] = FIXED2FLOAT(mover->momz) * TICRATE; @@ -621,7 +623,7 @@ void CalcPosVel (fixed_t *pt, AActor *mover, int constz, //========================================================================== static void S_StartSound (fixed_t *pt, AActor *mover, int channel, - int sound_id, float volume, float attenuation, bool looping) + int sound_id, float volume, float attenuation) { sfxinfo_t *sfx; int chanflags; @@ -630,28 +632,31 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, int pitch; fixed_t x, y, z; FSoundChan *chan; - - static int sndcount = 0; + float pos[3]; + float vel[3]; if (sound_id <= 0 || volume <= 0 || GSnd == NULL) return; org_id = sound_id; + chanflags = channel & ~7; if (pt == NULL) { attenuation = 0; // Give these variables values, although they don't really matter x = y = z = 0; + fixed_t pt2[3] = { 0, 0, 0 }; + CalcPosVel (pt2, mover, chanflags & CHAN_LISTENERZ, pos, vel); } else { x = pt[0]; y = pt[1]; z = pt[2]; + CalcPosVel (pt, mover, chanflags & CHAN_LISTENERZ, pos, vel); } - chanflags = channel & ~7; if (chanflags & CHAN_IMMOBILE) { pt = NULL; @@ -672,12 +677,11 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, channel &= 7; } - volume = clamp(volume, 0.f, 1.f); - sfx = &S_sfx[sound_id]; - // If this is a singular sound, don't play it if it's already playing. - if (sfx->bSingular && S_CheckSingular(sound_id)) + // Scale volume according to SNDINFO data. + volume = MIN(volume * sfx->Volume, 1.f); + if (volume <= 0) return; // Resolve player sounds, random sounds, and aliases @@ -698,6 +702,15 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, sfx = &S_sfx[sound_id]; } + // If this is a singular sound, don't play it if it's already playing. + if (sfx->bSingular && S_CheckSingular(sound_id)) + return; + + // If this sound doesn't like playing near itself, don't play it if + // that's what would happen. + if (sfx->NearLimit && S_CheckSoundLimit(sfx, pos)) + return; + // Make sure the sound is loaded. if (sfx->data == NULL) { @@ -722,25 +735,6 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, else { basepriority = 0; -#if 0 - switch (channel) - { - case CHAN_WEAPON: - basepriority = 20; - break; - case CHAN_VOICE: - basepriority = 10; - break; - default: - case CHAN_BODY: - basepriority = 0; - break; - case CHAN_ITEM: - basepriority = -10; - break; - } - basepriority = int(basepriority / attenuation); -#endif } if (mover != NULL && channel == CHAN_AUTO) @@ -793,34 +787,13 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, if (attenuation > 0) { - float pos[3]; - float vel[3]; - - if (pt) - { - CalcPosVel (pt, mover, chanflags & CHAN_LISTENERZ, pos, vel); - } - else - { - fixed_t pt2[3]; - pt2[0] = x; - pt2[1] = y; - pt2[2] = z; - CalcPosVel (pt2, mover, chanflags & CHAN_LISTENERZ, pos, vel); - } - chan = GSnd->StartSound3D (sfx, volume, attenuation, pitch, basepriority, looping, pos, vel, !(chanflags & CHAN_NOPAUSE)); - if (chan != NULL) - { - chan->ConstZ = !!(chanflags & CHAN_LISTENERZ); - } + chan = GSnd->StartSound3D (sfx, volume, attenuation, pitch, basepriority, pos, vel, chanflags); + chanflags |= CHAN_IS3D; } else { - chan = GSnd->StartSound (sfx, volume, pitch, looping, !(chanflags & CHAN_NOPAUSE)); - if (chan != NULL) - { - chan->ConstZ = true; - } + chan = GSnd->StartSound (sfx, volume, pitch, chanflags); + chanflags |= CHAN_LISTENERZ; } if (chan != NULL) { @@ -834,7 +807,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, chan->X = x; chan->Y = y; chan->Z = z; - chan->Loop = looping; + chan->ChanFlags = chanflags; if (mover != NULL) { mover->SoundChans |= 1 << channel; @@ -850,19 +823,19 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel, void S_SoundID (int channel, int sound_id, float volume, int attenuation) { - S_StartSound ((fixed_t *)NULL, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation), false); + S_StartSound ((fixed_t *)NULL, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation)); } void S_SoundID (AActor *ent, int channel, int sound_id, float volume, int attenuation) { if (ent->Sector->MoreFlags & SECF_SILENT) return; - S_StartSound (&ent->x, ent, channel, sound_id, volume, SELECT_ATTEN(attenuation), false); + S_StartSound (&ent->x, ent, channel, sound_id, volume, SELECT_ATTEN(attenuation)); } void S_SoundID (fixed_t *pt, int channel, int sound_id, float volume, int attenuation) { - S_StartSound (pt, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation), false); + S_StartSound (pt, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation)); } void S_SoundID (fixed_t x, fixed_t y, fixed_t z, int channel, int sound_id, float volume, int attenuation) @@ -871,25 +844,7 @@ void S_SoundID (fixed_t x, fixed_t y, fixed_t z, int channel, int sound_id, floa pt[0] = x; pt[1] = y; pt[2] = z; - S_StartSound (pt, NULL, channel|CHAN_IMMOBILE, sound_id, volume, SELECT_ATTEN(attenuation), false); -} - -//========================================================================== -// -// S_LoopedSoundID -// -//========================================================================== - -void S_LoopedSoundID (AActor *ent, int channel, int sound_id, float volume, int attenuation) -{ - if (ent->Sector->MoreFlags & SECF_SILENT) - return; - S_StartSound (&ent->x, ent, channel, sound_id, volume, SELECT_ATTEN(attenuation), true); -} - -void S_LoopedSoundID (fixed_t *pt, int channel, int sound_id, float volume, int attenuation) -{ - S_StartSound (pt, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation), true); + S_StartSound (pt, NULL, channel|CHAN_IMMOBILE, sound_id, volume, SELECT_ATTEN(attenuation)); } //========================================================================== @@ -899,7 +854,7 @@ void S_LoopedSoundID (fixed_t *pt, int channel, int sound_id, float volume, int //========================================================================== void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel, - const char *name, float volume, float attenuation, bool looping) + const char *name, float volume, float attenuation) { int sfx_id; @@ -914,9 +869,9 @@ void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel, DPrintf ("Unknown sound %s\n", name); if (ent) - S_StartSound (&ent->x, ent, channel, sfx_id, volume, attenuation, looping); + S_StartSound (&ent->x, ent, channel, sfx_id, volume, attenuation); else - S_StartSound (pt, NULL, channel, sfx_id, volume, attenuation, looping); + S_StartSound (pt, NULL, channel, sfx_id, volume, attenuation); } //========================================================================== @@ -927,17 +882,17 @@ void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel, void S_Sound (int channel, const char *name, float volume, int attenuation) { - S_StartNamedSound ((AActor *)NULL, NULL, channel, name, volume, SELECT_ATTEN(attenuation), false); + S_StartNamedSound ((AActor *)NULL, NULL, channel, name, volume, SELECT_ATTEN(attenuation)); } void S_Sound (AActor *ent, int channel, const char *name, float volume, int attenuation) { - S_StartNamedSound (ent, NULL, channel, name, volume, SELECT_ATTEN(attenuation), false); + S_StartNamedSound (ent, NULL, channel, name, volume, SELECT_ATTEN(attenuation)); } void S_Sound (fixed_t *pt, int channel, const char *name, float volume, int attenuation) { - S_StartNamedSound (NULL, pt, channel, name, volume, SELECT_ATTEN(attenuation), false); + S_StartNamedSound (NULL, pt, channel, name, volume, SELECT_ATTEN(attenuation)); } void S_Sound (fixed_t x, fixed_t y, int channel, const char *name, float volume, int attenuation) @@ -946,18 +901,7 @@ void S_Sound (fixed_t x, fixed_t y, int channel, const char *name, float volume, pt[0] = x; pt[1] = y; S_StartNamedSound (NULL, pt, channel|CHAN_LISTENERZ|CHAN_IMMOBILE, - name, volume, SELECT_ATTEN(attenuation), false); -} - -//========================================================================== -// -// S_LoopedSound -// -//========================================================================== - -void S_LoopedSound (AActor *ent, int channel, const char *name, float volume, int attenuation) -{ - S_StartNamedSound (ent, NULL, channel, name, volume, SELECT_ATTEN(attenuation), true); + name, volume, SELECT_ATTEN(attenuation)); } //========================================================================== @@ -980,6 +924,38 @@ bool S_CheckSingular(int sound_id) return false; } +//========================================================================== +// +// S_CheckSoundLimit +// +// Limits the number of nearby copies of a sound that can play near +// each other. If there are NearLimit instances of this sound already +// playing within 256 units of the new sound, the new sound will not +// start. +// +//========================================================================== + +bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3]) +{ + FSoundChan *chan; + int count; + + for (chan = Channels, count = 0; chan != NULL && count < sfx->NearLimit; chan = chan->NextChan) + { + if (chan->SfxInfo == sfx) + { + double dx = FIXED2FLOAT(chan->Pt[0]) - pos[0]; + double dy = FIXED2FLOAT(chan->Pt[1]) - pos[2]; + double dz = FIXED2FLOAT(chan->Pt[2]) - pos[1]; + if (dx*dx + dy*dy + dz*dz <= 256.0*256.0) + { + count++; + } + } + } + return count >= sfx->NearLimit; +} + //========================================================================== // // S_StopSound @@ -1048,7 +1024,7 @@ void S_RelinkSound (AActor *from, AActor *to) { if (chan->Pt == frompt) { - if (to != NULL || !chan->Loop) + if (to != NULL || !(chan->ChanFlags & CHAN_LOOP)) { chan->Pt = topt ? topt : &chan->X; chan->X = frompt[0]; @@ -1189,9 +1165,9 @@ void S_UpdateSounds (void *listener_p) for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan) { - if (chan->Is3D) + if (chan->ChanFlags & CHAN_IS3D) { - CalcPosVel(chan->Pt, chan->Mover, chan->ConstZ, pos, vel); + CalcPosVel(chan->Pt, chan->Mover, chan->ChanFlags & CHAN_LISTENERZ, pos, vel); GSnd->UpdateSoundParams3D(chan, pos, vel); } } diff --git a/src/s_sound.h b/src/s_sound.h index 9204e9075..f05498eb7 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -40,9 +40,11 @@ struct sfxinfo_t int lumpnum; // lump number of sfx unsigned int next, index; // [RH] For hashing - unsigned int frequency; // [RH] Preferred playback rate +// unsigned int frequency; // [RH] Preferred playback rate + float Volume; BYTE PitchMask; + BYTE NearLimit; // 0 means unlimited WORD bRandomHeader:1; WORD bPlayerReserve:1; @@ -97,9 +99,7 @@ struct FSoundChan float Volume; float DistanceScale; BYTE EntChannel; // Actor's sound channel. - bool Loop; - bool Is3D; - bool ConstZ; + int ChanFlags; }; FSoundChan *S_GetChannel(void *syschan); @@ -132,14 +132,10 @@ void S_Sound (int channel, const char *name, float volume, int attenuation); void S_Sound (AActor *ent, int channel, const char *name, float volume, int attenuation); void S_Sound (fixed_t *pt, int channel, const char *name, float volume, int attenuation); void S_Sound (fixed_t x, fixed_t y, int channel, const char *name, float volume, int attenuation); -void S_LoopedSound (AActor *ent, int channel, const char *name, float volume, int attenuation); -void S_LoopedSound (fixed_t *pt, int channel, const char *name, float volume, int attenuation); void S_SoundID (int channel, int sfxid, float volume, int attenuation); void S_SoundID (AActor *ent, int channel, int sfxid, float volume, int attenuation); void S_SoundID (fixed_t *pt, int channel, int sfxid, float volume, int attenuation); void S_SoundID (fixed_t x, fixed_t y, fixed_t z, int channel, int sfxid, float volume, int attenuation); -void S_LoopedSoundID (AActor *ent, int channel, int sfxid, float volume, int attenuation); -void S_LoopedSoundID (fixed_t *pt, int channel, int sfxid, float volume, int attenuation); // sound channels // channel 0 never willingly overrides @@ -162,6 +158,10 @@ void S_LoopedSoundID (fixed_t *pt, int channel, int sfxid, float volume, int att #define CHAN_IMMOBILE 16 #define CHAN_MAYBE_LOCAL 32 #define CHAN_NOPAUSE 64 // do not pause this sound in menus +#define CHAN_AREA 128 // Sound plays from all around within MinDistance +#define CHAN_LOOP 256 +#define CHAN_IS3D 1 // internal flag + #define CHAN_PICKUP (CHAN_ITEM|CHAN_MAYBE_LOCAL) // sound attenuation values diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 3e117b89b..f6c243f9c 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -919,7 +919,7 @@ SoundStream *FMODSoundRenderer::OpenStream(const char *filename_or_data, int fla // //========================================================================== -FSoundChan *FMODSoundRenderer::StartSound(sfxinfo_t *sfx, float vol, int pitch, bool looping, bool pausable) +FSoundChan *FMODSoundRenderer::StartSound(sfxinfo_t *sfx, float vol, int pitch, int chanflags) { int id = int(sfx - &S_sfx[0]); FMOD_RESULT result; @@ -927,7 +927,14 @@ FSoundChan *FMODSoundRenderer::StartSound(sfxinfo_t *sfx, float vol, int pitch, FMOD::Channel *chan; float freq; - freq = PITCH(sfx->frequency, pitch); + if (FMOD_OK == ((FMOD::Sound *)sfx->data)->getDefaults(&freq, NULL, NULL, NULL)) + { + freq = PITCH(freq, pitch); + } + else + { + freq = 0; + } GSfxInfo = sfx; result = Sys->playSound(FMOD_CHANNEL_FREE, (FMOD::Sound *)sfx->data, true, &chan); @@ -941,17 +948,19 @@ FSoundChan *FMODSoundRenderer::StartSound(sfxinfo_t *sfx, float vol, int pitch, mode = FMOD_SOFTWARE; } mode = (mode & ~FMOD_3D) | FMOD_2D; - if (looping) + if (chanflags & CHAN_LOOP) { mode = (mode & ~FMOD_LOOP_OFF) | FMOD_LOOP_NORMAL; } chan->setMode(mode); - - chan->setChannelGroup((pausable && !SFXPaused) ? PausableSfx : SfxGroup); - chan->setFrequency(freq); + chan->setChannelGroup((!(chanflags & CHAN_NOPAUSE) && !SFXPaused) ? PausableSfx : SfxGroup); + if (freq != 0) + { + chan->setFrequency(freq); + } chan->setVolume(vol); chan->setPaused(false); - return CommonChannelSetup(chan, false); + return CommonChannelSetup(chan); } DPrintf ("Sound %s failed to play: %d\n", sfx->name.GetChars(), result); @@ -965,7 +974,7 @@ FSoundChan *FMODSoundRenderer::StartSound(sfxinfo_t *sfx, float vol, int pitch, //========================================================================== FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float distscale, - int pitch, int priority, bool looping, float pos[3], float vel[3], bool pausable) + int pitch, int priority, float pos[3], float vel[3], int chanflags) { int id = int(sfx - &S_sfx[0]); FMOD_RESULT result; @@ -975,15 +984,15 @@ FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float dis float def_freq, def_vol, def_pan; int def_priority; - freq = PITCH(sfx->frequency, pitch); - - // Change the sound's default priority before playing it. if (FMOD_OK == ((FMOD::Sound *)sfx->data)->getDefaults(&def_freq, &def_vol, &def_pan, &def_priority)) { + freq = PITCH(def_freq, pitch); + // Change the sound's default priority before playing it. ((FMOD::Sound *)sfx->data)->setDefaults(def_freq, def_vol, def_pan, clamp(def_priority - priority, 1, 256)); } else { + freq = 0; def_priority = -1; } @@ -1005,34 +1014,21 @@ FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float dis { mode = FMOD_3D | FMOD_SOFTWARE; } - if (looping) + if (chanflags & CHAN_LOOP) { mode = (mode & ~FMOD_LOOP_OFF) | FMOD_LOOP_NORMAL; } - // If this sound is played at the same coordinates as the listener, - // make it head relative. - if (players[consoleplayer].camera != NULL) - { - float cpos[3]; - - cpos[0] = FIXED2FLOAT(players[consoleplayer].camera->x); - cpos[2] = FIXED2FLOAT(players[consoleplayer].camera->y); - cpos[1] = FIXED2FLOAT(players[consoleplayer].camera->z); - if (cpos[0] == pos[0] && cpos[1] == pos[1] && cpos[2] == pos[2]) - { - mode = (mode & ~FMOD_3D_WORLDRELATIVE) | FMOD_3D_HEADRELATIVE; - pos[0] = 0; - pos[1] = 0; - pos[2] = 0; - } - } + mode = SetChanHeadSettings(chan, sfx, pos, chanflags, mode); chan->setMode(mode); - chan->setChannelGroup((pausable && !SFXPaused) ? PausableSfx : SfxGroup); - chan->setFrequency(freq); + chan->setChannelGroup((!(chanflags & CHAN_NOPAUSE) && !SFXPaused) ? PausableSfx : SfxGroup); + if (freq != 0) + { + chan->setFrequency(freq); + } chan->setVolume(vol); chan->set3DAttributes((FMOD_VECTOR *)pos, (FMOD_VECTOR *)vel); chan->setPaused(false); - FSoundChan *schan = CommonChannelSetup(chan, true); + FSoundChan *schan = CommonChannelSetup(chan); schan->DistanceScale = distscale; return schan; } @@ -1041,6 +1037,60 @@ FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float dis return 0; } +//========================================================================== +// +// FMODSound :: SetChanHeadSettings +// +// If this sound is played at the same coordinates as the listener, make +// it head relative. Also, area sounds should use no 3D panning if close +// enough to the listener. +// +//========================================================================== + +FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t *sfx, float pos[3], int chanflags, FMOD_MODE oldmode) const +{ + if (players[consoleplayer].camera == NULL) + { + return oldmode; + } + double cpos[3]; + cpos[0] = FIXED2FLOAT(players[consoleplayer].camera->x); + cpos[2] = FIXED2FLOAT(players[consoleplayer].camera->y); + cpos[1] = FIXED2FLOAT(players[consoleplayer].camera->z); + if (chanflags & CHAN_AREA) + { + const double interp_range = 512.0; + double dx = cpos[0] - pos[0], dy = cpos[1] - pos[1], dz = cpos[2] - pos[2]; + double min_dist = sfx->MinDistance == 0 ? (S_MinDistance == 0 ? 200 : S_MinDistance) : sfx->MinDistance; + double dist_sqr = dx*dx + dy*dy + dz*dz; + float level, old_level; + + if (dist_sqr <= min_dist*min_dist) + { // Within min distance: No 3D panning. + level = 0; + } + else if (dist_sqr <= (min_dist + interp_range) * (min_dist + interp_range)) + { // Within interp_range units of min distance: Interpolate between none and full 3D panning. + level = float(1 - (min_dist + interp_range - sqrt(dist_sqr)) / interp_range); + } + else + { // Beyond 256 units of min distance: Normal 3D panning. + level = 1; + } + if (chan->get3DPanLevel(&old_level) == FMOD_OK && old_level != level) + { // Only set it if it's different. + chan->set3DPanLevel(level); + } + return oldmode; + } + else if (cpos[0] == pos[0] && cpos[1] == pos[1] && cpos[2] == pos[2]) + { + pos[2] = pos[1] = pos[0] = 0; + return (oldmode & ~FMOD_3D_WORLDRELATIVE) | FMOD_3D_HEADRELATIVE; + } + return (oldmode & ~FMOD_3D_HEADRELATIVE) | FMOD_3D_WORLDRELATIVE; +} + //========================================================================== // // FMODSoundRenderer :: CommonChannelSetup @@ -1050,12 +1100,11 @@ FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float dis // //========================================================================== -FSoundChan *FMODSoundRenderer::CommonChannelSetup(FMOD::Channel *chan, bool is3d) +FSoundChan *FMODSoundRenderer::CommonChannelSetup(FMOD::Channel *chan) const { FSoundChan *schan = S_GetChannel(chan); chan->setUserData(schan); chan->setCallback(FMOD_CHANNEL_CALLBACKTYPE_END, ChannelEndCallback, 0); - schan->Is3D = is3d; GSfxInfo = NULL; return schan; } @@ -1104,39 +1153,17 @@ void FMODSoundRenderer::UpdateSoundParams3D(FSoundChan *chan, float pos[3], floa return; FMOD::Channel *fchan = (FMOD::Channel *)chan->SysChannel; + FMOD_MODE oldmode, mode; - // Sounds at the same location as the listener should be head relative, others - // should be world relative. - if (players[consoleplayer].camera != NULL) + if (fchan->getMode(&oldmode) != FMOD_OK) { - FMOD_MODE oldmode, mode; - float cpos[3]; - - cpos[0] = FIXED2FLOAT(players[consoleplayer].camera->x); - cpos[2] = FIXED2FLOAT(players[consoleplayer].camera->y); - cpos[1] = FIXED2FLOAT(players[consoleplayer].camera->z); - if (FMOD_OK != fchan->getMode(&oldmode)) - { - oldmode = FMOD_3D | FMOD_SOFTWARE; - } - if (cpos[0] == pos[0] && cpos[1] == pos[1] && cpos[2] == pos[2]) - { - mode = (oldmode & ~FMOD_3D_WORLDRELATIVE) | FMOD_3D_HEADRELATIVE; - pos[0] = 0; - pos[1] = 0; - pos[2] = 0; - } - else - { - mode = (oldmode & ~FMOD_3D_HEADRELATIVE) | FMOD_3D_WORLDRELATIVE; - } - // Only set the mode if it changed. - if (((mode ^ oldmode) & (FMOD_3D_WORLDRELATIVE | FMOD_3D_HEADRELATIVE)) == 0) - { - fchan->setMode(mode); - } + oldmode = FMOD_3D | FMOD_SOFTWARE; + } + mode = SetChanHeadSettings(fchan, chan->SfxInfo, pos, chan->ChanFlags, oldmode); + if (mode != oldmode) + { // Only set the mode if it changed. + fchan->setMode(mode); } - fchan->set3DAttributes((FMOD_VECTOR *)pos, (FMOD_VECTOR *)vel); } @@ -1352,24 +1379,26 @@ void FMODSoundRenderer::DoLoad(void **slot, sfxinfo_t *sfx) if (sfx->bLoadRAW || (((BYTE *)sfxdata)[0] == 3 && ((BYTE *)sfxdata)[1] == 0 && len <= size - 8)) { + int frequency; + if (sfx->bLoadRAW) { len = Wads.LumpLength (sfx->lumpnum); - sfx->frequency = (sfx->bForce22050 ? 22050 : 11025); + frequency = (sfx->bForce22050 ? 22050 : 11025); } else { - sfx->frequency = ((WORD *)sfxdata)[1]; - if (sfx->frequency == 0) + frequency = ((WORD *)sfxdata)[1]; + if (frequency == 0) { - sfx->frequency = 11025; + frequency = 11025; } sfxstart = sfxdata + 8; } exinfo.length = len; exinfo.numchannels = 1; - exinfo.defaultfrequency = sfx->frequency; + exinfo.defaultfrequency = frequency; exinfo.format = FMOD_SOUND_FORMAT_PCM8; samplemode |= FMOD_OPENRAW; @@ -1398,19 +1427,6 @@ void FMODSoundRenderer::DoLoad(void **slot, sfxinfo_t *sfx) continue; } *slot = sample; - // Get frequency and length for sounds FMOD handled for us. - if (!(samplemode & FMOD_OPENRAW)) - { - float freq; - - result = sample->getDefaults(&freq, NULL, NULL, NULL); - if (result != FMOD_OK) - { - DPrintf("Failed getting default sound frequency, assuming 11025Hz\n"); - freq = 11025; - } - sfx->frequency = (unsigned int)freq; - } break; } diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index 1a2b5661c..9630cfc95 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -24,8 +24,8 @@ public: void StopStream (SoundStream *stream); // Starts a sound. - FSoundChan *StartSound (sfxinfo_t *sfx, float vol, int pitch, bool looping, bool pauseable); - FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, bool looping, float pos[3], float vel[3], bool pauseable); + FSoundChan *StartSound (sfxinfo_t *sfx, float vol, int pitch, int chanflags); + FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, float pos[3], float vel[3], int chanflags); // Stops a sound channel. void StopSound (FSoundChan *chan); @@ -58,7 +58,8 @@ private: (FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, int cmd, unsigned int data1, unsigned int data2); static float F_CALLBACK RolloffCallback(FMOD_CHANNEL *channel, float distance); - FSoundChan *CommonChannelSetup(FMOD::Channel *chan, bool is3d); + FSoundChan *CommonChannelSetup(FMOD::Channel *chan) const; + FMOD_MODE SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t *sfx, float pos[3], int chanflags, FMOD_MODE oldmode) const; void DoLoad (void **slot, sfxinfo_t *sfx); void getsfx (sfxinfo_t *sfx); diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index b8ead6dbe..35acba411 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -78,8 +78,8 @@ public: virtual SoundStream *OpenStream (const char *filename, int flags, int offset, int length) = 0; // Starts a sound. - virtual FSoundChan *StartSound (sfxinfo_t *sfx, float vol, int pitch, bool looping, bool pauseable) = 0; - virtual FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, bool looping, float pos[3], float vel[3], bool pauseable) = 0; + virtual FSoundChan *StartSound (sfxinfo_t *sfx, float vol, int pitch, int chanflags) = 0; + virtual FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, float pos[3], float vel[3], int chanflags) = 0; // Stops a sound channel. virtual void StopSound (FSoundChan *chan) = 0; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 37e4a9210..bd453d4b2 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -339,7 +339,7 @@ void A_PlaySoundEx (AActor *self) { if (!S_IsActorPlayingSomething (self, channel - NAME_Auto, soundid)) { - S_LoopedSoundID (self, channel - NAME_Auto, soundid, 1, attenuation); + S_SoundID (self, (channel - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation); } } } diff --git a/src/xlat/xlat_parser.h b/src/xlat/xlat_parser.h deleted file mode 100644 index 4a1bb3a40..000000000 --- a/src/xlat/xlat_parser.h +++ /dev/null @@ -1,37 +0,0 @@ -#define NOP 1 -#define OR 2 -#define XOR 3 -#define AND 4 -#define MINUS 5 -#define PLUS 6 -#define MULTIPLY 7 -#define DIVIDE 8 -#define NEG 9 -#define NUM 10 -#define SYMNUM 11 -#define LPAREN 12 -#define RPAREN 13 -#define DEFINE 14 -#define SYM 15 -#define RBRACE 16 -#define ENUM 17 -#define LBRACE 18 -#define COMMA 19 -#define EQUALS 20 -#define TAG 21 -#define LBRACKET 22 -#define RBRACKET 23 -#define FLAGS 24 -#define ARG2 25 -#define ARG3 26 -#define ARG4 27 -#define ARG5 28 -#define OR_EQUAL 29 -#define COLON 30 -#define SECTOR 31 -#define SEMICOLON 32 -#define NOBITMASK 33 -#define BITMASK 34 -#define CLEAR 35 -#define LSHASSIGN 36 -#define RSHASSIGN 37 diff --git a/wadsrc/sndinfo.txt b/wadsrc/sndinfo.txt index d95bc834a..a640f32b6 100644 --- a/wadsrc/sndinfo.txt +++ b/wadsrc/sndinfo.txt @@ -202,6 +202,11 @@ weapons/bfgf dsbfg weapons/bfgx dsrxplod weapons/railgf railgf1 +$limit weapons/plasmaf 0 +$limit weapons/chngun 0 +$limit weapons/rocklf 0 // because normal running is almost as fast as a rocket +$limit weapons/rocklx 0 // and the cyberdemon shoots 3 at once + //=========================================================================== // // MONSTER SOUNDS @@ -284,6 +289,7 @@ chainguy/death1 dspodth1 chainguy/death2 dspodth2 chainguy/death3 dspodth3 chainguy/attack dsshotgn +$limit chainguy/attack 0 // Imp @@ -367,6 +373,8 @@ baby/walk dsbspwlk baby/attack dsplasma baby/shotx dsfirxpl +$limit baby/attack 0 + // Cyber Demon cyber/sight dscybsit @@ -452,6 +460,10 @@ misc/spawn dsitmbk // Item respawn misc/chat dsradio // Doom 2 chat sound misc/chat2 dstink // Chat sound for everything else +$limit misc/i_pkup 1 +$limit misc/k_pkup 1 +$limit misc/w_pkup 1 +$limit misc/p_pkup 1 $pitchshift misc/i_pkup 0 $pitchshift misc/k_pkup 0 $pitchshift misc/chat2 0 @@ -543,6 +555,21 @@ weapons/phoenixshoot phosht weapons/phoenixhit phohit weapons/phoenixpowshoot phopow +$limit weapons/gauntletson 0 +$limit weapons/gauntletshit 0 +$limit weapons/gauntletspowhit 0 +$limit weapons/gauntletsactivate 0 +$limit weapons/gauntletsuse 0 +$limit weapons/maceexplode 0 +$limit weapons/phoenixhit 0 +$limit weapons/phoenixpowshoot 1 + +// [RH] Heretic didn't have these limitless, but they can sound bad if they're not +$limit weapons/bowhit 0 +$limit weapons/hornrodshoot 0 +$limit weapons/hornrodhit 0 +$limit weapons/maceshoot 0 + himp/sight impsit himp/attack impat1 himp/pain imppai @@ -552,11 +579,17 @@ himp/leaderattack impat2 misc/invuse artiuse +$limit misc/invuse 1 + world/podexplode podexp world/podgrow newpod world/wind wind world/waterfall waterfl +$limit world/podexplode 0 +$limit world/podgrow 0 +$limit world/wind 1 + misc/i_pkup itemup misc/k_pkup keyup misc/p_pkup artiup @@ -565,6 +598,8 @@ $alias misc/w_pkup *weaponlaugh misc/rain ramrain misc/spawn respawn +$limit misc/spawn 1 + // // Minotaur sounds // @@ -633,10 +668,24 @@ world/amb10 amb10 world/amb11 amb11 world/amb12 bstsit +$limit world/amb1 1 +$limit world/amb2 1 +$limit world/amb3 1 +$limit world/amb4 1 +$limit world/amb5 1 +$limit world/amb6 1 +$limit world/amb7 1 +$limit world/amb8 1 +$limit world/amb9 1 +$limit world/amb10 1 +$limit world/amb11 0 + misc/chat chat misc/teleport telept misc/ripslop ripslop +$limit misc/chat 1 + world/drip gloop world/watersplash gloop world/lavasizzle burn @@ -841,6 +890,31 @@ $alias minotaur/attack2 MaulatorHamSwing $random BishopActiveSounds { BishopActive BishopSight } $random PigActive { PigActive1 PigActive2 } +$limit PlayerFighterFailedUse 1 +$limit PlayerClericFailedUse 1 +$limit PlayerMageFailedUse 1 +$limit SorcererBallWoosh 4 +$limit SorcererBallBounce 3 +$limit SorcererBallExplode 3 +$limit SorcererBallPop 3 +$limit SorcererBigBallExplode 3 +$limit Ambient1 1 +$limit Ambient2 1 +$limit Ambient3 1 +$limit Ambient4 1 +$limit Ambient5 1 +$limit Ambient6 1 +$limit Ambient7 1 +$limit Ambient8 1 +$limit Ambient9 1 +$limit Ambient10 1 +$limit Ambient11 1 +$limit Ambient12 1 +$limit Ambient13 1 +$limit Ambient14 1 +$limit Ambient15 1 +$limit MysticIncant 4 + $pitchshift PlayerMageNormalDeath 0 $pitchshift PlayerMageCrazyDeath 0 $pitchshift PlayerMageExtreme1Death 0 @@ -869,6 +943,20 @@ $alias menu/clear PlatformStop // Hexen does not have ripslop sound like Heretic misc/ripslop dsempty +$limit DoorCloseLight 4 + +$limit PuppyBeat 0 +$limit CeantaurPain 0 +$limit BishopPain 0 +$limit SerpentPain 0 +$limit DemonPain 0 +$limit WraithPain 0 +$limit MaulatorPain 0 +$limit EttinPain 0 +$limit FireDemonPain 0 +$limit SorcererPain 0 +$limit DragonPain 0 + $endif // ifhexen //=========================================================================== @@ -962,6 +1050,10 @@ world/waterfall dswfall world/waterdrip dswdrip world/watersplash dswsplsh +$limit world/river 1 +$limit world/waterfall 1 +$limit world/waterdrip 1 + world/drip dsempty // These four satisfy the Heretic/Hexen terrain definitions world/sludgegloop dsempty world/lavasizzle dsempty diff --git a/wadsrc/wadsrc.vcproj b/wadsrc/wadsrc.vcproj index ddc698ea2..fc24d78ed 100644 --- a/wadsrc/wadsrc.vcproj +++ b/wadsrc/wadsrc.vcproj @@ -177,15 +177,15 @@ Name="Map Translators" > - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - @@ -940,6 +930,16 @@ Outputs=""src/$(InputName).h"" /> + + + @@ -1530,16 +1530,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -1550,6 +1540,16 @@ Outputs="$(IntDir)/$(InputName).obj" /> + + + @@ -1574,16 +1574,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -1594,6 +1584,16 @@ Outputs="$(IntDir)/$(InputName).obj" /> + + + @@ -1618,16 +1618,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -1638,6 +1628,16 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -1662,16 +1662,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -1682,6 +1672,16 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -1706,16 +1706,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -1726,6 +1716,16 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -1886,6 +1886,14 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -1896,14 +1904,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - + + + @@ -2762,14 +2770,6 @@ AdditionalIncludeDirectories="src\win32;$(NoInherit)" /> - - - @@ -2924,7 +2924,7 @@ />