Skip to content

Commit

Permalink
989snd: Rename BlockSoundHandler members
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziemas committed Nov 25, 2023
1 parent de2bb78 commit 14e414c
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 112 deletions.
32 changes: 16 additions & 16 deletions game/sound/989snd/blocksound_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace snd {
std::array<s8, 32> g_block_reg{};

blocksound_handler::blocksound_handler(SoundBank& bank,
BlockSoundHandler::BlockSoundHandler(SoundBank& bank,
SFXBlock::SFX& sfx,
VoiceManager& vm,
s32 sfx_vol,
Expand Down Expand Up @@ -93,11 +93,11 @@ blocksound_handler::blocksound_handler(SoundBank& bank,
m_next_grain = 0;
m_countdown = m_sfx.Grains[0].Delay;
while (m_countdown <= 0 && !m_done) {
do_grain();
DoGrain();
}
}

blocksound_handler::~blocksound_handler() {
BlockSoundHandler::~BlockSoundHandler() {
for (auto& p : m_voices) {
auto v = p.lock();
if (v != nullptr) {
Expand All @@ -106,8 +106,8 @@ blocksound_handler::~blocksound_handler() {
}
}

bool blocksound_handler::Tick() {
m_voices.remove_if([](std::weak_ptr<blocksound_voice>& p) { return p.expired(); });
bool BlockSoundHandler::Tick() {
m_voices.remove_if([](std::weak_ptr<BlockSoundVoice>& p) { return p.expired(); });

for (auto& lfo : m_lfo) {
lfo.Tick();
Expand Down Expand Up @@ -135,13 +135,13 @@ bool blocksound_handler::Tick() {

m_countdown--;
while (m_countdown <= 0 && !m_done) {
do_grain();
DoGrain();
}

return false;
};

void blocksound_handler::Pause() {
void BlockSoundHandler::Pause() {
m_paused = true;

for (auto& c : m_children) {
Expand All @@ -158,7 +158,7 @@ void blocksound_handler::Pause() {
}
}

void blocksound_handler::Unpause() {
void BlockSoundHandler::Unpause() {
m_paused = false;

for (auto& c : m_children) {
Expand All @@ -175,7 +175,7 @@ void blocksound_handler::Unpause() {
}
}

void blocksound_handler::Stop() {
void BlockSoundHandler::Stop() {
m_done = true;

for (auto& c : m_children) {
Expand All @@ -192,7 +192,7 @@ void blocksound_handler::Stop() {
}
}

void blocksound_handler::SetVolPan(s32 vol, s32 pan) {
void BlockSoundHandler::SetVolPan(s32 vol, s32 pan) {
if (vol >= 0) {
if (vol != VOLUME_DONT_CHANGE) {
m_app_volume = vol;
Expand Down Expand Up @@ -241,7 +241,7 @@ void blocksound_handler::SetVolPan(s32 vol, s32 pan) {
}
}

void blocksound_handler::update_pitch() {
void BlockSoundHandler::UpdatePitch() {
m_cur_pm = m_app_pm + m_lfo_pm;
m_cur_pb = std::clamp<s32>(m_app_pb + m_lfo_pb, INT16_MIN, INT16_MAX);

Expand All @@ -259,23 +259,23 @@ void blocksound_handler::update_pitch() {
}
}

void blocksound_handler::SetPMod(s32 mod) {
void BlockSoundHandler::SetPMod(s32 mod) {
for (auto& c : m_children) {
c->SetPMod(mod);
}
m_app_pm = mod;
update_pitch();
UpdatePitch();
}

void blocksound_handler::SetPBend(s32 bend) {
void BlockSoundHandler::SetPBend(s32 bend) {
for (auto& c : m_children) {
c->SetPBend(bend);
}
m_app_pb = bend;
update_pitch();
UpdatePitch();
}

void blocksound_handler::do_grain() {
void BlockSoundHandler::DoGrain() {
auto& grain = m_sfx.Grains[m_next_grain];

s32 ret = grain(*this);
Expand Down
28 changes: 14 additions & 14 deletions game/sound/989snd/blocksound_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ namespace snd {

extern std::array<s8, 32> g_block_reg;

class blocksound_voice : public VagVoice {
class BlockSoundVoice : public VagVoice {
public:
blocksound_voice(Tone& t) : VagVoice(t) {}
BlockSoundVoice(Tone& t) : VagVoice(t) {}
s32 g_vol;
s32 g_pan;
};

class blocksound_handler : public SoundHandler {
class BlockSoundHandler : public SoundHandler {
public:
blocksound_handler(SoundBank& bank,
SFXBlock::SFX& sfx,
VoiceManager& vm,
s32 sfx_vol,
s32 sfx_pan,
SndPlayParams& params);

~blocksound_handler() override;
BlockSoundHandler(SoundBank& bank,
SFXBlock::SFX& sfx,
VoiceManager& vm,
s32 sfx_vol,
s32 sfx_pan,
SndPlayParams& params);

~BlockSoundHandler() override;
bool Tick() override;
SoundBank& Bank() override { return m_bank; };

Expand All @@ -40,9 +40,9 @@ class blocksound_handler : public SoundHandler {
void SetRegister(u8 reg, u8 value) override { m_registers.at(reg) = value; };
void SetPBend(s32 bend) override;

void do_grain();
void DoGrain();

void update_pitch();
void UpdatePitch();

bool m_paused{false};

Expand All @@ -56,7 +56,7 @@ class blocksound_handler : public SoundHandler {
SFXBlock::SFX& m_sfx;
VoiceManager& m_vm;

std::list<std::weak_ptr<blocksound_voice>> m_voices;
std::list<std::weak_ptr<BlockSoundVoice>> m_voices;

std::list<std::unique_ptr<SoundHandler>> m_children;

Expand Down
4 changes: 2 additions & 2 deletions game/sound/989snd/lfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ void LFOTracker::Tick() {
s32 pm = (GetLFO(2) * m_range) >> 15;
if (m_handler.m_lfo_pm != pm) {
m_handler.m_lfo_pm = pm;
m_handler.update_pitch();
m_handler.UpdatePitch();
}
} break;
case LFOTarget::PBEND: {
s32 pb = (GetLFO(2) * m_range) >> 15;
if (m_handler.m_lfo_pb != pb) {
m_handler.m_lfo_pb = pb;
m_handler.update_pitch();
m_handler.UpdatePitch();
}
} break;
case LFOTarget::UNK1: {
Expand Down
6 changes: 3 additions & 3 deletions game/sound/989snd/lfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ namespace snd {
enum class LFOType { OFF, SINE, SQUARE, TRIANGLE, SAW, RAND };
enum class LFOTarget { NONE, VOLUME, PAN, PMOD, PBEND, UNK1, UNK2 };

class blocksound_handler;
class BlockSoundHandler;

class LFOTracker {
public:
LFOTracker(blocksound_handler& handler) : m_handler(handler) {}
LFOTracker(BlockSoundHandler& handler) : m_handler(handler) {}
LFOType m_type{LFOType::OFF};
LFOTarget m_target{0};
u8 m_target_extra{0};
Expand All @@ -35,7 +35,7 @@ class LFOTracker {
void Tick();
s32 GetLFO(s32 step_mult);

blocksound_handler& m_handler;
BlockSoundHandler& m_handler;
};

} // namespace snd
Expand Down
2 changes: 1 addition & 1 deletion game/sound/989snd/sfxblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ std::optional<std::unique_ptr<SoundHandler>> SFXBlock::MakeHandler(VoiceManager&
return std::nullopt;
}

auto handler = std::make_unique<blocksound_handler>(*this, SFX, vm, vol, pan, params);
auto handler = std::make_unique<BlockSoundHandler>(*this, SFX, vm, vol, pan, params);
return handler;
}

Expand Down
Loading

0 comments on commit 14e414c

Please sign in to comment.