Skip to content

Commit

Permalink
989snd: fixes & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziemas committed Nov 11, 2023
1 parent b20dcec commit b855490
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 42 deletions.
2 changes: 1 addition & 1 deletion game/sound/989snd/midi_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void midi_handler::note_on() {
voice->current_pb = m_cur_pm;

voice->group = m_sound.VolGroup;
m_vm.start_tone(voice, m_bank.bank_id);
m_vm.start_tone(voice);
m_voices.emplace_front(voice);
}
}
Expand Down
37 changes: 0 additions & 37 deletions game/sound/989snd/sfxblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,6 @@

namespace snd {

struct SFXBlockData : BankTag {
/* 10 */ s8 BlockNum;
/* 11 */ s8 pad1;
/* 12 */ s16 pad2;
/* 14 */ s16 pad3;
/* 16 */ s16 NumSounds;
/* 18 */ s16 NumGrains;
/* 1a */ s16 NumVAGs;
/* 1c */ u32 FirstSound;
/* 20 */ u32 FirstGrain;
/* 24 */ u32 VagsInSR;
/* 28 */ u32 VagDataSize;
/* 2c */ u32 SRAMAllocSize;
/* 30 */ u32 NextBlock;

/* these last ones are probably not in jak1? */
/* 34 */ u32 BlockNames;
/* 38 */ u32 SFXUD;
};

static_assert(sizeof(SFXBlockData) == 0x38 + 4);

struct SFXData {
/* 0 */ s8 Vol;
/* 1 */ s8 VolGroup;
/* 2 */ s16 Pan;
/* 4 */ s8 NumGrains;
/* 5 */ s8 InstanceLimit;
/* 6 */ u16 Flags;
/* 8 */ u32 FirstGrain;
};

enum SFXFlags {
Looper = 1,
SoloSound = 2, // Stop previous instances
};

struct SFXUserData { // 0x10
/* 0x0 */ u32 data[4];
};
Expand Down
5 changes: 3 additions & 2 deletions game/sound/989snd/sfxgrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ s32 Grain::snd_SFX_GRAIN_TYPE_NULL(blocksound_handler& handler) {
}

s32 Grain::snd_SFX_GRAIN_TYPE_TONE(blocksound_handler& handler) {
auto tone = std::get<Tone>(data);
auto &tone = std::get<Tone>(data);

handler.m_cur_volume =
((handler.m_app_volume * handler.m_orig_volume) >> 10) + handler.m_lfo_volume;
handler.m_cur_volume = std::clamp<s32>(handler.m_cur_volume, 0, 127);
Expand Down Expand Up @@ -71,7 +72,7 @@ s32 Grain::snd_SFX_GRAIN_TYPE_TONE(blocksound_handler& handler) {
voice->basevol =
handler.m_vm.make_volume(127, 0, handler.m_cur_volume, handler.m_cur_pan, vol, pan);

handler.m_vm.start_tone(voice, handler.m_bank.bank_id);
handler.m_vm.start_tone(voice);
handler.m_voices.emplace_front(voice);

return 0;
Expand Down
2 changes: 2 additions & 0 deletions game/sound/989snd/soundbank.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class SoundBank {
bool has_userdata() { return flags & BLOCK_HAS_USERDATA; }
};

virtual ~SoundBank() = default;

u32 DataID;
u32 Version;
BlockFlags Flags;
Expand Down
2 changes: 1 addition & 1 deletion game/sound/989snd/vagvoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ voice_manager::voice_manager(synth& synth) : m_synth(synth) {
m_group_duck.fill(0x10000);
}

void voice_manager::start_tone(std::shared_ptr<vag_voice> voice, u32 bank) {
void voice_manager::start_tone(std::shared_ptr<vag_voice> voice) {
s16 left = adjust_vol_to_group(voice->basevol.left, voice->group);
s16 right = adjust_vol_to_group(voice->basevol.right, voice->group);

Expand Down
2 changes: 1 addition & 1 deletion game/sound/989snd/vagvoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class vag_voice : public voice {
class voice_manager {
public:
voice_manager(synth& synth);
void start_tone(std::shared_ptr<vag_voice> voice, u32 bank);
void start_tone(std::shared_ptr<vag_voice> voice);
void pause(std::shared_ptr<vag_voice> voice);
void unpause(std::shared_ptr<vag_voice> voice);
void set_pan_table(vol_pair* table) { m_pan_table = table; };
Expand Down

0 comments on commit b855490

Please sign in to comment.