Files
jak-project/game/sound/989snd/sound_handler.h
T
water111 c08118509b [jak3] Add BRANCH grain, make handler IDs unique (#3950)
Two changes that fix some Jak 3 audio bugs.

In some areas, sound effects would seem to cut off randomly. This was
caused by the sound code reusing IDs, but overlord didn't realize. It
would try to kill a sound effect by ID that had already died, and the ID
was reassigned to a new sound. To fix this, I made the handle IDs always
increment. I also tested starting the ID at large numbers and confirmed
that worked.

I also added support for the BRANCH grain. This makes the
`wastelander-shot` and possibly other sound effects work. It doesn't
support all the features, but this is probably enough.

Fun fact: the wastelander shot is supposed to have 7 variations, but you
always get the same one because they set the sound mask wrong.

I added a line you can uncomment if you want to experience the other 6
variations.

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
2025-06-07 22:34:03 -04:00

42 lines
1.1 KiB
C++

// Copyright: 2021 - 2024, Ziemas
// SPDX-License-Identifier: ISC
#pragma once
#include <map>
#include <memory>
#include "common/common_types.h"
namespace snd {
static constexpr int PAN_RESET = -1;
static constexpr int PAN_DONT_CHANGE = -2;
static constexpr int VOLUME_DONT_CHANGE = 0x7fffffff;
class SoundBank;
class SoundHandler {
public:
virtual ~SoundHandler() = default;
virtual bool Tick() = 0;
virtual SoundBank& Bank() = 0;
virtual void Pause() = 0;
virtual void Unpause() = 0;
virtual u8 Group() = 0;
virtual void Stop() = 0;
virtual void SetVolPan(s32 vol, s32 pan) = 0;
virtual void SetPMod(s32 mod) = 0;
virtual void SetPBend(s32 /*mod*/){};
virtual void SetRegister(u8 /*reg*/, u8 /*value*/) {}
virtual u32 SoundID() const { return -1; }
// Check if this handler violates an instance limit. If so, return pointer to the sound that
// should be removed.
virtual SoundHandler* CheckInstanceLimit(
const std::map<u32, std::unique_ptr<SoundHandler>>& handlers,
s32 vol,
bool parent) {
return nullptr;
}
};
} // namespace snd