mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 22:22:21 -04:00
Ame fixes (#2087)
This commit is contained in:
@@ -58,9 +58,17 @@ bool ame_handler::tick() {
|
||||
};
|
||||
|
||||
void ame_handler::start_segment(u32 id) {
|
||||
auto midiblock = (MIDIBlockHeader*)(m_header->BlockPtr[id] + (uintptr_t)m_header);
|
||||
m_midis.emplace(id, std::make_unique<midi_handler>(midiblock, m_vm, m_sound, m_vol, m_pan,
|
||||
m_locator, m_bank, this));
|
||||
if (m_midis.find(id) == m_midis.end()) {
|
||||
auto midiblock = (MIDIBlockHeader*)(m_header->BlockPtr[id] + (uintptr_t)m_header);
|
||||
auto sound_handler = (MIDISoundHandler*)((uintptr_t)midiblock + sizeof(MIDIBlockHeader));
|
||||
|
||||
// Skip adding if not midi type
|
||||
u32 type = (sound_handler->OwnerID >> 24) & 0xf;
|
||||
if (type == 1 || type == 3) {
|
||||
m_midis.emplace(id, std::make_unique<midi_handler>(midiblock, m_vm, m_sound, m_vol, m_pan,
|
||||
m_locator, m_bank, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ame_handler::stop() {
|
||||
|
||||
@@ -325,6 +325,14 @@ void midi_handler::meta_event() {
|
||||
m_seq_ptr += len + 2;
|
||||
}
|
||||
|
||||
static s16 midiTo360Pan(u8 pan) {
|
||||
if (pan >= 64) {
|
||||
return (s16)(90 * (pan - 64) / 63);
|
||||
} else {
|
||||
return (s16)(90 * pan / 64 + 270);
|
||||
}
|
||||
}
|
||||
|
||||
void midi_handler::controller_change() {
|
||||
u8 channel = m_status & 0xf;
|
||||
u8 controller = m_seq_ptr[0];
|
||||
@@ -336,7 +344,7 @@ void midi_handler::controller_change() {
|
||||
m_chanvol[channel] = static_cast<s8>(value);
|
||||
} break;
|
||||
case 0xa: {
|
||||
m_chanpan[channel] = static_cast<s8>(value);
|
||||
m_chanpan[channel] = midiTo360Pan(static_cast<s8>(value));
|
||||
} break;
|
||||
// case 0x40: {} break; // TODO damper
|
||||
default:
|
||||
|
||||
@@ -108,7 +108,7 @@ class midi_handler : public sound_handler {
|
||||
|
||||
std::array<bool, 16> m_mute_state{};
|
||||
std::array<s8, 16> m_chanvol{};
|
||||
std::array<s8, 16> m_chanpan{};
|
||||
std::array<s16, 16> m_chanpan{};
|
||||
std::array<s16, 16> m_pitch_bend{};
|
||||
u8* m_sample_data{nullptr};
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ struct MIDISound {
|
||||
/* 18 */ /*void**/ u32 MIDIBlock;
|
||||
};
|
||||
|
||||
// Annoyingly enough we need some data out of this struct
|
||||
struct MIDISoundHandler {
|
||||
u32 OwnerID;
|
||||
};
|
||||
|
||||
struct Prog;
|
||||
class MusicBank : public SoundBank {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user