mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
Assorted sound fixes (#2049)
fixes https://github.com/open-goal/jak-project/issues/2046
This commit is contained in:
parent
7a62e9cf4f
commit
2bf663dccf
|
@ -20,19 +20,13 @@ void blocksound_handler::init() {
|
|||
// return;
|
||||
// }
|
||||
|
||||
int idx = 0;
|
||||
for (auto& g : m_sfx.grains) {
|
||||
// lg::info("grain {}: {}", idx, g->inspect());
|
||||
idx++;
|
||||
}
|
||||
|
||||
while (m_countdown <= 0 && !m_done) {
|
||||
do_grain();
|
||||
}
|
||||
}
|
||||
|
||||
bool blocksound_handler::tick() {
|
||||
m_voices.remove_if([](std::weak_ptr<vag_voice>& p) { return p.expired(); });
|
||||
m_voices.remove_if([](std::weak_ptr<blocksound_voice>& p) { return p.expired(); });
|
||||
|
||||
for (auto& lfo : m_lfo) {
|
||||
lfo.tick();
|
||||
|
@ -145,8 +139,7 @@ void blocksound_handler::set_vol_pan(s32 vol, s32 pan) {
|
|||
continue;
|
||||
}
|
||||
|
||||
auto volume =
|
||||
m_vm.make_volume(127, 0, m_cur_volume, m_cur_pan, voice->tone.Vol, voice->tone.Pan);
|
||||
auto volume = m_vm.make_volume(127, 0, m_cur_volume, m_cur_pan, voice->g_vol, voice->g_pan);
|
||||
auto left = m_vm.adjust_vol_to_group(volume.left, m_sfx.d.VolGroup);
|
||||
auto right = m_vm.adjust_vol_to_group(volume.right, m_sfx.d.VolGroup);
|
||||
|
||||
|
@ -174,13 +167,17 @@ void blocksound_handler::update_pitch() {
|
|||
}
|
||||
|
||||
void blocksound_handler::set_pmod(s32 mod) {
|
||||
// TODO update children
|
||||
for (auto& c : m_children) {
|
||||
c->set_pmod(mod);
|
||||
}
|
||||
m_app_pm = mod;
|
||||
update_pitch();
|
||||
}
|
||||
|
||||
void blocksound_handler::set_pbend(s32 bend) {
|
||||
// TODO update children
|
||||
for (auto& c : m_children) {
|
||||
c->set_pbend(bend);
|
||||
}
|
||||
m_app_pb = bend;
|
||||
update_pitch();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,13 @@ namespace snd {
|
|||
|
||||
extern std::array<s8, 32> g_block_reg;
|
||||
|
||||
class blocksound_voice : public vag_voice {
|
||||
public:
|
||||
blocksound_voice(Tone& t) : vag_voice(t) {}
|
||||
s32 g_vol;
|
||||
s32 g_pan;
|
||||
};
|
||||
|
||||
class blocksound_handler : public sound_handler {
|
||||
public:
|
||||
blocksound_handler(SoundBank& bank,
|
||||
|
@ -106,7 +113,7 @@ class blocksound_handler : public sound_handler {
|
|||
void set_vol_pan(s32 vol, s32 pan) override;
|
||||
void set_pmod(s32 mod) override;
|
||||
void set_register(u8 reg, u8 value) override { m_registers.at(reg) = value; };
|
||||
void set_pbend(s32 bend); // TODO override;
|
||||
void set_pbend(s32 bend) override;
|
||||
|
||||
void init();
|
||||
|
||||
|
@ -126,13 +133,10 @@ class blocksound_handler : public sound_handler {
|
|||
SFX2& m_sfx;
|
||||
voice_manager& m_vm;
|
||||
|
||||
std::list<std::weak_ptr<vag_voice>> m_voices;
|
||||
std::list<std::weak_ptr<blocksound_voice>> m_voices;
|
||||
|
||||
std::list<std::unique_ptr<sound_handler>> m_children;
|
||||
|
||||
s32 m_current_pb{0};
|
||||
s32 m_current_pm{0};
|
||||
|
||||
s32 m_orig_volume{0};
|
||||
s32 m_orig_pan{0};
|
||||
s32 m_cur_volume{0};
|
||||
|
|
|
@ -47,7 +47,9 @@ SFXBlock2::SFXBlock2(locator& loc, u32 id, BankTag* tag)
|
|||
strncpy(buf, (char*)name->Name, 16);
|
||||
|
||||
std::string str(buf);
|
||||
m_names[str] = name->Index;
|
||||
if (m_names.find(str) == m_names.end()) {
|
||||
m_names[str] = name->Index;
|
||||
}
|
||||
m_sounds.at(name->Index).name = str;
|
||||
|
||||
name++;
|
||||
|
|
|
@ -28,9 +28,10 @@ s32 SFXGrain_Tone::execute(blocksound_handler& handler) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto voice = std::make_shared<vag_voice>(m_tone);
|
||||
auto voice = std::make_shared<blocksound_voice>(m_tone);
|
||||
|
||||
s32 vol = m_tone.Vol;
|
||||
|
||||
if (vol < 0) {
|
||||
if (vol >= -4) {
|
||||
vol = handler.m_registers.at(-vol - 1);
|
||||
|
@ -61,7 +62,11 @@ s32 SFXGrain_Tone::execute(blocksound_handler& handler) {
|
|||
|
||||
voice->start_note = handler.m_note;
|
||||
voice->start_fine = handler.m_fine;
|
||||
voice->current_pb = handler.m_cur_pb;
|
||||
voice->current_pm = handler.m_cur_pm;
|
||||
voice->group = handler.m_group;
|
||||
voice->g_vol = vol;
|
||||
voice->g_pan = pan;
|
||||
|
||||
voice->basevol =
|
||||
handler.m_vm.make_volume(127, 0, handler.m_cur_volume, handler.m_cur_pan, vol, pan);
|
||||
|
|
|
@ -22,6 +22,7 @@ class sound_handler {
|
|||
virtual void stop() = 0;
|
||||
virtual void set_vol_pan(s32 vol, s32 pan) = 0;
|
||||
virtual void set_pmod(s32 mod) = 0;
|
||||
virtual void set_pbend(s32 mod){};
|
||||
virtual void set_register(u8 /*reg*/, u8 /*value*/) {}
|
||||
};
|
||||
} // namespace snd
|
||||
|
|
Loading…
Reference in a new issue