mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
5b99929394
Supports most of the grain types now while maintaining compatibility with the old stuff (at least the subset of things jak1 uses) Would benefit from some testing in Jak 1 to make sure I didn't break anything. Sorry the git history is a mess, I'll do something about it later.
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "sfxblock.h"
|
|
|
|
#include "blocksound_handler.h"
|
|
#include "sfxgrain.h"
|
|
|
|
#include "common/log/log.h"
|
|
|
|
namespace snd {
|
|
|
|
SFXBlock::SFXBlock(locator& loc, u32 id, BankTag* tag)
|
|
: SoundBank(id, BankType::SFX), m_locator(loc) {
|
|
auto data = (SFXBlockData*)tag;
|
|
|
|
auto sounddata = (SFX2Data*)((uintptr_t)data + data->FirstSound);
|
|
for (int i = 0; i < data->NumSounds; i++) {
|
|
SFX2 sound;
|
|
sound.index = i;
|
|
sound.d = sounddata[i];
|
|
m_sounds.push_back(std::move(sound));
|
|
}
|
|
|
|
for (auto& sound : m_sounds) {
|
|
auto graindata = (SFXGrain*)((uintptr_t)data + data->FirstGrain + sound.d.FirstGrain);
|
|
for (int i = 0; i < sound.d.NumGrains; i++) {
|
|
SFXGrain& grain = graindata[i];
|
|
sound.grains.push_back(new_grain((grain_type)grain.Type, grain));
|
|
}
|
|
}
|
|
}
|
|
|
|
std::unique_ptr<sound_handler> SFXBlock::make_handler(voice_manager& vm,
|
|
u32 sound_id,
|
|
s32 vol,
|
|
s32 pan,
|
|
SndPlayParams& params) {
|
|
auto& SFX = m_sounds[sound_id];
|
|
|
|
if (SFX.grains.empty()) {
|
|
// fmt::print("skipping empty sfx\n");
|
|
return nullptr;
|
|
}
|
|
|
|
auto handler =
|
|
std::make_unique<blocksound_handler>(*this, m_sounds[sound_id], vm, vol, pan, params);
|
|
handler->init();
|
|
return handler;
|
|
}
|
|
} // namespace snd
|