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.
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
#include "musicbank.h"
|
|
|
|
#include "ame_handler.h"
|
|
#include "midi_handler.h"
|
|
|
|
#include "../common/synth.h"
|
|
|
|
namespace snd {
|
|
|
|
MusicBank::MusicBank(locator& loc, u32 id, BankTag* tag)
|
|
: SoundBank(id, BankType::Music), m_locator(loc) {
|
|
auto data = (SoundBankData*)tag;
|
|
|
|
auto sound = (MIDISound*)((uintptr_t)data + data->FirstSound);
|
|
for (int i = 0; i < data->NumSounds; i++) {
|
|
m_sounds.emplace_back(sound[i]);
|
|
}
|
|
|
|
auto progdata = (ProgData*)((uintptr_t)data + data->FirstProg);
|
|
for (int i = 0; i < data->NumProgs; i++) {
|
|
Prog prog;
|
|
prog.d = progdata[i];
|
|
m_programs.emplace_back(std::move(prog));
|
|
}
|
|
|
|
for (auto& prog : m_programs) {
|
|
auto tonedata = (Tone*)((uintptr_t)data + prog.d.FirstTone);
|
|
for (int i = 0; i < prog.d.NumTones; i++) {
|
|
prog.tones.emplace_back(tonedata[i]);
|
|
}
|
|
}
|
|
|
|
bank_name = data->BankID;
|
|
}
|
|
|
|
std::unique_ptr<sound_handler> MusicBank::make_handler(voice_manager& vm,
|
|
u32 sound_id,
|
|
s32 vol,
|
|
s32 pan,
|
|
s32 pm,
|
|
s32 pb) {
|
|
auto& sound = m_sounds[sound_id];
|
|
std::unique_ptr<sound_handler> handler;
|
|
|
|
if (sound.Type == 4) { // midi
|
|
auto midi = static_cast<MIDIBlockHeader*>(m_locator.get_midi(sound.MIDIID));
|
|
handler = std::make_unique<midi_handler>(midi, vm, sound, vol, pan, m_locator, *this);
|
|
} else if (sound.Type == 5) { // ame
|
|
auto midi = static_cast<MultiMIDIBlockHeader*>(m_locator.get_midi(sound.MIDIID));
|
|
handler = std::make_unique<ame_handler>(midi, vm, sound, vol, pan, m_locator, *this);
|
|
} else {
|
|
// error
|
|
}
|
|
|
|
return handler;
|
|
}
|
|
|
|
std::unique_ptr<sound_handler> MusicBank::make_handler(voice_manager& vm,
|
|
u32 sound_id,
|
|
s32 vol,
|
|
s32 pan,
|
|
SndPlayParams& params) {
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace snd
|