mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- removed the old sound system header from Duke and RR frontends and fixed every report this produced:
* reverb/echo is not yet implemented, so there's two stub functions for now. * RTS needs to be done differently, because the sound engine cannot play raw buffers without any control data.
This commit is contained in:
parent
fbfb1972b8
commit
fa7638c446
17 changed files with 68 additions and 36 deletions
|
@ -621,6 +621,8 @@ file( GLOB HEADER_FILES
|
|||
common/console/*.h
|
||||
common/filesystem/*.h
|
||||
common/music/*.h
|
||||
common/sound/*.h
|
||||
common/sound/backend/*.h
|
||||
common/menu/*.h
|
||||
common/input/*.h
|
||||
|
||||
|
@ -902,6 +904,7 @@ include_directories(
|
|||
common/filesystem
|
||||
common/music
|
||||
common/sound
|
||||
common/sound/backend
|
||||
common/dobject
|
||||
common/menu
|
||||
common/input
|
||||
|
|
|
@ -91,7 +91,7 @@ static FORCE_INLINE void FX_SetVolume(int volume) { MV_SetVolume(volume); }
|
|||
static FORCE_INLINE int FX_GetVolume(void) { return MV_GetVolume(); }
|
||||
static FORCE_INLINE void FX_SetReverseStereo(int setting) { MV_SetReverseStereo(setting); }
|
||||
static FORCE_INLINE int FX_GetReverseStereo(void) { return MV_GetReverseStereo(); }
|
||||
static FORCE_INLINE void FX_SetReverb(int reverb) { MV_SetReverb(reverb); }
|
||||
static FORCE_INLINE void FX_SetReverb_(int reverb) { MV_SetReverb(reverb); }
|
||||
static FORCE_INLINE int FX_GetMaxReverbDelay(void) { return MV_GetMaxReverbDelay(); }
|
||||
static FORCE_INLINE int FX_GetReverbDelay(void) { return MV_GetReverbDelay(); }
|
||||
static FORCE_INLINE void FX_SetReverbDelay(int delay) { MV_SetReverbDelay(delay); }
|
||||
|
|
|
@ -488,22 +488,22 @@ void sfxSetReverb(bool toggle)
|
|||
{
|
||||
if (toggle)
|
||||
{
|
||||
FX_SetReverb(128);
|
||||
FX_SetReverb_(128);
|
||||
FX_SetReverbDelay(10);
|
||||
}
|
||||
else
|
||||
FX_SetReverb(0);
|
||||
FX_SetReverb_(0);
|
||||
}
|
||||
|
||||
void sfxSetReverb2(bool toggle)
|
||||
{
|
||||
if (toggle)
|
||||
{
|
||||
FX_SetReverb(128);
|
||||
FX_SetReverb_(128);
|
||||
FX_SetReverbDelay(20);
|
||||
}
|
||||
else
|
||||
FX_SetReverb(0);
|
||||
FX_SetReverb_(0);
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -893,13 +893,14 @@ const char *FileSystem::GetResourceFileFullName (int rfnum) const noexcept
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FileSystem::AddFromBuffer(const char* name, const char* type, char* data, int size, int id, int flags)
|
||||
int FileSystem::AddFromBuffer(const char* name, const char* type, char* data, int size, int id, int flags)
|
||||
{
|
||||
FStringf fullname("%s.%s", name, type);
|
||||
auto newlump = new FMemoryLump(data, size);
|
||||
newlump->LumpNameSetup(fullname);
|
||||
newlump->ResourceId = id;
|
||||
AddLump(newlump);
|
||||
return Files.Size()-1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
int FindResource (int resid, const char *type, int filenum = -1) const noexcept;
|
||||
int GetResource (int resid, const char *type, int filenum = -1) const; // Like FindFile, but throws an exception when it cannot find what it looks for.
|
||||
|
||||
void AddFromBuffer(const char* name, const char* type, char* data, int size, int id, int flags);
|
||||
int AddFromBuffer(const char* name, const char* type, char* data, int size, int id, int flags);
|
||||
|
||||
|
||||
TArray<FString> GetAllFilesOfType(FName type, bool withsubdirs = false);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "filesystem/filesystem.h"
|
||||
#include "rts.h"
|
||||
#include "m_swap.h"
|
||||
#include "s_soundinternal.h"
|
||||
|
||||
|
||||
struct WadInfo
|
||||
|
@ -56,7 +57,7 @@ struct FileLump
|
|||
|
||||
struct LumpInfoInternal
|
||||
{
|
||||
int32_t position, size;
|
||||
int32_t position, size, sid;
|
||||
};
|
||||
|
||||
//=============
|
||||
|
@ -96,7 +97,7 @@ bool RTS_IsInitialized()
|
|||
LumpInfo.Resize(numlumps);
|
||||
for(unsigned i = 0; i < numlumps; i++, li++)
|
||||
{
|
||||
LumpInfo[i] = { LittleLong(li->position), LittleLong(li->size) };
|
||||
LumpInfo[i] = { LittleLong(li->position), LittleLong(li->size), -1 };
|
||||
if (unsigned(LumpInfo[i].position + LumpInfo[i].size) >= RTSFile.Size())
|
||||
{
|
||||
LumpInfo[i].size = 0; // points to invalid data
|
||||
|
@ -108,6 +109,19 @@ bool RTS_IsInitialized()
|
|||
}
|
||||
RTSFile.Reset();
|
||||
LumpInfo.Reset();
|
||||
|
||||
// For the benefit of the sound system we have to link the RTS content into the file system.
|
||||
// Unfortunately the file cannot be added directly because the internal names are meaningless.
|
||||
int i = 0;
|
||||
for (auto& li : LumpInfo)
|
||||
{
|
||||
if (li.size > 0)
|
||||
{
|
||||
FStringf rts("rts%02d", i);
|
||||
int lump = fileSystem.AddFromBuffer(rts, "rts", (char*)RTSFile.Data() + li.position, li.size, -1, 0);
|
||||
li.sid = soundEngine->AddSoundLump(rts, lump, 0, -1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -127,3 +141,12 @@ void *RTS_GetSound(int lump)
|
|||
if(LumpInfo[lump].size <= 0) return nullptr;
|
||||
return RTSFile.Data() + LumpInfo[lump].position;
|
||||
}
|
||||
|
||||
int RTS_GetSoundID(int lump)
|
||||
{
|
||||
if (!RTS_IsInitialized()) return -1;
|
||||
lump++;
|
||||
if ((unsigned)lump >= LumpInfo.Size()) return -1;
|
||||
if (LumpInfo[lump].size <= 0) return -1;
|
||||
return LumpInfo[lump].sid;
|
||||
}
|
||||
|
|
|
@ -4,3 +4,4 @@ void RTS_Init(const char *filename);
|
|||
bool RTS_IsInitialized();
|
||||
int RTS_SoundLength(int lump);
|
||||
void *RTS_GetSound(int lump);
|
||||
int RTS_GetSoundID(int lump);
|
||||
|
|
|
@ -453,3 +453,7 @@ inline void FX_StopAllSounds(void)
|
|||
soundEngine->StopAllChannels();
|
||||
}
|
||||
|
||||
inline void FX_SetReverb(int strength)
|
||||
{
|
||||
// todo: investigate how this works and set a proper environment.
|
||||
}
|
|
@ -1486,7 +1486,6 @@ ACTOR_STATIC void G_MoveFX(void)
|
|||
else if (playerDist >= spriteHitag && T1(spriteNum) == 1)
|
||||
{
|
||||
FX_SetReverb(0);
|
||||
FX_SetReverbDelay(0);
|
||||
T1(spriteNum) = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
#include "compat.h"
|
||||
#include "fx_man.h"
|
||||
#include "pragmas.h"
|
||||
#include "polymost.h"
|
||||
#include "gamecvars.h"
|
||||
|
|
|
@ -4392,16 +4392,15 @@ void G_InitTimer(int32_t ticspersec)
|
|||
static int32_t g_RTSPlaying;
|
||||
|
||||
// Returns: started playing?
|
||||
extern int G_StartRTS(int lumpNum, int localPlayer)
|
||||
int G_StartRTS(int lumpNum, int localPlayer)
|
||||
{
|
||||
if (!adult_lockout && SoundEnabled() &&
|
||||
RTS_IsInitialized() && g_RTSPlaying == 0 && (snd_speech & (localPlayer ? 1 : 4)))
|
||||
{
|
||||
char *const pData = (char *)RTS_GetSound(lumpNum - 1);
|
||||
|
||||
if (pData != NULL)
|
||||
auto sid = RTS_GetSoundID(lumpNum - 1);
|
||||
if (sid != -1)
|
||||
{
|
||||
FX_Play3D(pData, RTS_SoundLength(lumpNum - 1), FX_ONESHOT, 0, 0, 1, 255, 1.f, -lumpNum);
|
||||
S_PlaySound(sid, CHAN_UI);
|
||||
g_RTSPlaying = 7;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ void cacheAllSounds(void)
|
|||
|
||||
static inline int S_GetPitch(int num)
|
||||
{
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(num+1);
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1);
|
||||
if (!snd) return 0;
|
||||
int const range = abs(snd->pitchEnd - snd->pitchStart);
|
||||
|
||||
return (range == 0) ? snd->pitchStart : min(snd->pitchStart, snd->pitchEnd) + rand() % range;
|
||||
|
@ -115,9 +116,11 @@ float S_ConvertPitch(int lpitch)
|
|||
return pow(2, lpitch / 1200.); // I hope I got this right that ASS uses a linear scale where 1200 is a full octave.
|
||||
}
|
||||
|
||||
int S_GetUserFlags(int sndnum)
|
||||
int S_GetUserFlags(int num)
|
||||
{
|
||||
return ((sound_t*)soundEngine->GetUserData(sndnum + 1))->flags;
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1);
|
||||
if (!snd) return 0;
|
||||
return snd->flags;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -177,8 +180,8 @@ static int S_CalcDistAndAng(int spriteNum, int soundNum, int sectNum,
|
|||
|
||||
int orgsndist = 0, sndang = 0, sndist = 0, explosion = 0;
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(soundNum+1);
|
||||
int userflags = snd->flags;
|
||||
int dist_adjust = snd->volAdjust;
|
||||
int userflags = snd? snd->flags : 0;
|
||||
int dist_adjust = snd? snd->volAdjust : 0;
|
||||
|
||||
if (PN(spriteNum) != APLAYER || P_Get(spriteNum) != screenpeek)
|
||||
{
|
||||
|
@ -378,7 +381,7 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, int flags)
|
|||
bool foundone = soundEngine->EnumerateChannels([&](FSoundChan* chan)
|
||||
{
|
||||
auto sid = chan->OrgID;
|
||||
auto flags = ((sound_t*)soundEngine->GetUserData(sid))->flags;
|
||||
auto flags = S_GetUserFlags(sid - 1);
|
||||
return !!(flags & SF_TALK);
|
||||
});
|
||||
// don't play if any Duke talk sounds are already playing
|
||||
|
|
|
@ -1352,7 +1352,6 @@ ACTOR_STATIC void G_MoveFX(void)
|
|||
else if (playerDist >= spriteHitag && T1(spriteNum) == 1)
|
||||
{
|
||||
FX_SetReverb(0);
|
||||
FX_SetReverbDelay(0);
|
||||
T1(spriteNum) = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "cache1d.h"
|
||||
#include "compat.h"
|
||||
|
||||
#include "fx_man.h"
|
||||
#include "pragmas.h"
|
||||
|
||||
#include "polymost.h"
|
||||
|
|
|
@ -5946,16 +5946,15 @@ void G_InitTimer(int32_t ticspersec)
|
|||
static int32_t g_RTSPlaying;
|
||||
|
||||
// Returns: started playing?
|
||||
extern int G_StartRTS(int lumpNum, int localPlayer)
|
||||
int G_StartRTS(int lumpNum, int localPlayer)
|
||||
{
|
||||
if (!adult_lockout && SoundEnabled() &&
|
||||
RTS_IsInitialized() && g_RTSPlaying == 0 && (snd_speech & (localPlayer ? 1 : 4)))
|
||||
{
|
||||
char *const pData = (char *)RTS_GetSound(lumpNum - 1);
|
||||
|
||||
if (pData != NULL)
|
||||
auto sid = RTS_GetSoundID(lumpNum - 1);
|
||||
if (sid != -1)
|
||||
{
|
||||
FX_Play3D(pData, RTS_SoundLength(lumpNum - 1), FX_ONESHOT, 0, 0, 1, 255, 1.f, -lumpNum);
|
||||
S_PlaySound(sid, CHAN_UI);
|
||||
g_RTSPlaying = 7;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ void cacheAllSounds(void)
|
|||
static inline int S_GetPitch(int num)
|
||||
{
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(num+1);
|
||||
if (!snd) return 0;
|
||||
int const range = abs(snd->pitchEnd - snd->pitchStart);
|
||||
|
||||
return (range == 0) ? snd->pitchStart : min(snd->pitchStart, snd->pitchEnd) + rand() % range;
|
||||
|
@ -115,9 +116,11 @@ float S_ConvertPitch(int lpitch)
|
|||
return pow(2, lpitch / 1200.); // I hope I got this right that ASS uses a linear scale where 1200 is a full octave.
|
||||
}
|
||||
|
||||
int S_GetUserFlags(int sndnum)
|
||||
int S_GetUserFlags(int num)
|
||||
{
|
||||
return ((sound_t*)soundEngine->GetUserData(sndnum + 1))->flags;
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1);
|
||||
if (!snd) return 0;
|
||||
return snd->flags;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -176,9 +179,9 @@ static int S_CalcDistAndAng(int spriteNum, int soundNum, int sectNum,
|
|||
// However, ultimately rolloff would also just reposition the sound source so this can remain as it is.
|
||||
|
||||
int orgsndist = 0, sndang = 0, sndist = 0, explosion = 0;
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(soundNum+1);
|
||||
int userflags = snd->flags;
|
||||
int dist_adjust = snd->volAdjust;
|
||||
auto const* snd = (sound_t*)soundEngine->GetUserData(soundNum + 1);
|
||||
int userflags = snd ? snd->flags : 0;
|
||||
int dist_adjust = snd ? snd->volAdjust : 0;
|
||||
|
||||
if (PN(spriteNum) != APLAYER || P_Get(spriteNum) != screenpeek)
|
||||
{
|
||||
|
@ -381,7 +384,7 @@ int S_PlaySound3D(int sndnum, int spriteNum, const vec3_t* pos, int flags)
|
|||
bool foundone = soundEngine->EnumerateChannels([&](FSoundChan* chan)
|
||||
{
|
||||
auto sid = chan->OrgID;
|
||||
auto flags = ((sound_t*)soundEngine->GetUserData(sid))->flags;
|
||||
auto flags = S_GetUserFlags(sid - 1);
|
||||
return !!(flags & SF_TALK);
|
||||
});
|
||||
// don't play if any Duke talk sounds are already playing
|
||||
|
|
|
@ -894,7 +894,7 @@ SoundShutdown(void)
|
|||
|
||||
void COVER_SetReverb(int amt)
|
||||
{
|
||||
FX_SetReverb(amt);
|
||||
FX_SetReverb_(amt);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue