Remove amuse, and compile fixes

This commit is contained in:
Phillip Stephens 2023-10-22 09:21:20 -07:00
parent e9cfa6aff4
commit 137e4c19a3
33 changed files with 632 additions and 650 deletions

4
.gitmodules vendored
View File

@ -2,10 +2,6 @@
path = extern/nod path = extern/nod
url = ../nod.git url = ../nod.git
branch = master branch = master
[submodule "extern/amuse"]
path = extern/amuse
url = ../amuse.git
branch = master
[submodule "extern/kabufuda"] [submodule "extern/kabufuda"]
path = extern/kabufuda path = extern/kabufuda
url = ../kabufuda.git url = ../kabufuda.git

View File

@ -287,8 +287,8 @@ void CNESEmulator::InitializeEmulator() {
// double useFreq = 223740; // double useFreq = 223740;
double useFreq = apuGetFrequency(); double useFreq = apuGetFrequency();
m_booVoice = CAudioSys::GetVoiceEngine()->allocateNewStereoVoice(useFreq, this); //m_booVoice = CAudioSys::GetVoiceEngine()->allocateNewStereoVoice(useFreq, this);
m_booVoice->start(); //m_booVoice->start();
uint32_t apuBufSz = apuGetMaxBufSize(); uint32_t apuBufSz = apuGetMaxBufSize();
m_audioBufBlock.reset(new u8[apuBufSz * NUM_AUDIO_BUFFERS]); m_audioBufBlock.reset(new u8[apuBufSz * NUM_AUDIO_BUFFERS]);
memset(m_audioBufBlock.get(), 0, apuBufSz * NUM_AUDIO_BUFFERS); memset(m_audioBufBlock.get(), 0, apuBufSz * NUM_AUDIO_BUFFERS);
@ -301,8 +301,8 @@ void CNESEmulator::InitializeEmulator() {
void CNESEmulator::DeinitializeEmulator() { void CNESEmulator::DeinitializeEmulator() {
// printf("\n"); // printf("\n");
emuRenderFrame = false; emuRenderFrame = false;
m_booVoice->stop(); //m_booVoice->stop();
m_booVoice.reset(); //m_booVoice.reset();
apuDeinitBufs(); apuDeinitBufs();
if (emuNesROM != NULL) { if (emuNesROM != NULL) {
if (!nesEmuNSFPlayback && (audioExpansion & EXP_FDS)) { if (!nesEmuNSFPlayback && (audioExpansion & EXP_FDS)) {
@ -345,63 +345,63 @@ CNESEmulator::~CNESEmulator() {
} }
int CNESEmulator::audioUpdate() { int CNESEmulator::audioUpdate() {
int origProcBufs = m_procBufs; // int origProcBufs = m_procBufs;
//
uint8_t* data = apuGetBuf(); // uint8_t* data = apuGetBuf();
if (data != NULL && m_procBufs) { // if (data != NULL && m_procBufs) {
uint32_t apuBufSz = apuGetMaxBufSize(); // uint32_t apuBufSz = apuGetMaxBufSize();
uint32_t remBytes = apuGetBufSize(); // uint32_t remBytes = apuGetBufSize();
while (remBytes != 0) { // while (remBytes != 0) {
size_t thisBytes = std::min(remBytes, apuBufSz - m_posInHeadBuf); // size_t thisBytes = std::min(remBytes, apuBufSz - m_posInHeadBuf);
memmove(m_audioBufs[m_headBuf] + m_posInHeadBuf, data, thisBytes); // memmove(m_audioBufs[m_headBuf] + m_posInHeadBuf, data, thisBytes);
data += thisBytes; // data += thisBytes;
m_posInHeadBuf += thisBytes; // m_posInHeadBuf += thisBytes;
if (m_posInHeadBuf == apuBufSz) { // if (m_posInHeadBuf == apuBufSz) {
m_posInHeadBuf = 0; // m_posInHeadBuf = 0;
--m_procBufs; // --m_procBufs;
++m_headBuf; // ++m_headBuf;
if (m_headBuf == NUM_AUDIO_BUFFERS) // if (m_headBuf == NUM_AUDIO_BUFFERS)
m_headBuf = 0; // m_headBuf = 0;
// printf("PUSH\n"); // // printf("PUSH\n");
} // }
remBytes -= thisBytes; // remBytes -= thisBytes;
} // }
} // }
//
// if (!origProcBufs) // // if (!origProcBufs)
// printf("OVERRUN\n"); // // printf("OVERRUN\n");
//
return origProcBufs; // return origProcBufs;
} }
static constexpr uint32_t AudioFrameSz = 2 * sizeof(int16_t); static constexpr uint32_t AudioFrameSz = 2 * sizeof(int16_t);
size_t CNESEmulator::supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) { //size_t CNESEmulator::supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) {
uint32_t remFrames = uint32_t(frames); // uint32_t remFrames = uint32_t(frames);
while (remFrames) { // while (remFrames) {
if (m_posInTailBuf == apuGetMaxBufSize()) { // if (m_posInTailBuf == apuGetMaxBufSize()) {
++m_tailBuf; // ++m_tailBuf;
if (m_tailBuf == NUM_AUDIO_BUFFERS) // if (m_tailBuf == NUM_AUDIO_BUFFERS)
m_tailBuf = 0; // m_tailBuf = 0;
m_posInTailBuf = 0; // m_posInTailBuf = 0;
++m_procBufs; // ++m_procBufs;
// printf("POP\n"); // // printf("POP\n");
} // }
//
if (m_procBufs == NUM_AUDIO_BUFFERS) { // if (m_procBufs == NUM_AUDIO_BUFFERS) {
memset(data, 0, remFrames * AudioFrameSz); // memset(data, 0, remFrames * AudioFrameSz);
// printf("UNDERRUN\n"); // // printf("UNDERRUN\n");
return frames; // return frames;
} // }
//
size_t copySz = std::min(apuGetMaxBufSize() - m_posInTailBuf, remFrames * AudioFrameSz); // size_t copySz = std::min(apuGetMaxBufSize() - m_posInTailBuf, remFrames * AudioFrameSz);
memmove(data, m_audioBufs[m_tailBuf] + m_posInTailBuf, copySz); // memmove(data, m_audioBufs[m_tailBuf] + m_posInTailBuf, copySz);
data += copySz / sizeof(int16_t); // data += copySz / sizeof(int16_t);
m_posInTailBuf += copySz; // m_posInTailBuf += copySz;
remFrames -= copySz / AudioFrameSz; // remFrames -= copySz / AudioFrameSz;
} // }
return frames; // return frames;
} //}
void CNESEmulator::NesEmuMainLoop(bool forceDraw) { void CNESEmulator::NesEmuMainLoop(bool forceDraw) {
// int start = GetTickCount(); // int start = GetTickCount();

View File

@ -3,7 +3,6 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "zeus/CColor.hpp" #include "zeus/CColor.hpp"
//#include "boo/graphicsdev/IGraphicsDataFactory.hpp" //#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
#include "boo/audiodev/IAudioVoice.hpp"
#include "zeus/CMatrix4f.hpp" #include "zeus/CMatrix4f.hpp"
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
@ -15,7 +14,7 @@ namespace MP1 {
#define NUM_AUDIO_BUFFERS 4 #define NUM_AUDIO_BUFFERS 4
class CNESEmulator final : public boo::IAudioVoiceCallback { class CNESEmulator final {
public: public:
enum class EPasswordEntryState { NotPasswordScreen, NotEntered, Entered }; enum class EPasswordEntryState { NotPasswordScreen, NotEntered, Entered };
@ -47,7 +46,7 @@ private:
uint32_t m_procBufs = NUM_AUDIO_BUFFERS; uint32_t m_procBufs = NUM_AUDIO_BUFFERS;
uint32_t m_posInHeadBuf = 0; uint32_t m_posInHeadBuf = 0;
uint32_t m_posInTailBuf = 0; uint32_t m_posInTailBuf = 0;
boo::ObjToken<boo::IAudioVoice> m_booVoice; //boo::ObjToken<boo::IAudioVoice> m_booVoice;
// void* x4_loadBuf; // void* x4_loadBuf;
// void* x8_rom; // void* x8_rom;
@ -82,8 +81,8 @@ public:
EPasswordEntryState GetPasswordEntryState() const { return x34_passwordEntryState; } EPasswordEntryState GetPasswordEntryState() const { return x34_passwordEntryState; }
int audioUpdate(); int audioUpdate();
void preSupplyAudio(boo::IAudioVoice& voice, double dt) {} //void preSupplyAudio(boo::IAudioVoice& voice, double dt) {}
size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data); //size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data);
}; };
} // namespace MP1 } // namespace MP1

View File

@ -3,7 +3,7 @@
#include <cstring> #include <cstring>
namespace metaforce { namespace metaforce {
/*
amuse::AudioGroupData CAudioGroupSet::LoadData() { amuse::AudioGroupData CAudioGroupSet::LoadData() {
const auto readU32 = [](const u8* ptr) { const auto readU32 = [](const u8* ptr) {
uint32_t value; uint32_t value;
@ -30,8 +30,8 @@ amuse::AudioGroupData CAudioGroupSet::LoadData() {
return {proj, projLen, pool, poolLen, sdir, sdirLen, samp, sampLen, amuse::GCNDataTag{}}; return {proj, projLen, pool, poolLen, sdir, sdirLen, samp, sampLen, amuse::GCNDataTag{}};
} }
*/
CAudioGroupSet::CAudioGroupSet(std::unique_ptr<u8[]>&& in) : m_buffer(std::move(in)), m_data(LoadData()) {} CAudioGroupSet::CAudioGroupSet(std::unique_ptr<u8[]>&& in) : m_buffer(std::move(in)) {}
CFactoryFnReturn FAudioGroupSetDataFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len, CFactoryFnReturn FAudioGroupSetDataFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef) { const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef) {

View File

@ -9,7 +9,7 @@
#include "Runtime/IObj.hpp" #include "Runtime/IObj.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include <amuse/AudioGroupData.hpp> //#include <amuse/AudioGroupData.hpp>
namespace metaforce { namespace metaforce {
@ -17,12 +17,12 @@ class CAudioGroupSet {
std::unique_ptr<u8[]> m_buffer; std::unique_ptr<u8[]> m_buffer;
std::string x10_baseName; std::string x10_baseName;
std::string x20_name; std::string x20_name;
amuse::AudioGroupData m_data; // amuse::AudioGroupData m_data;
amuse::AudioGroupData LoadData(); // amuse::AudioGroupData LoadData();
public: public:
explicit CAudioGroupSet(std::unique_ptr<u8[]>&& in); explicit CAudioGroupSet(std::unique_ptr<u8[]>&& in);
const amuse::AudioGroupData& GetAudioGroupData() const { return m_data; } //const amuse::AudioGroupData& GetAudioGroupData() const { return m_data; }
std::string_view GetName() const { return x20_name; } std::string_view GetName() const { return x20_name; }
}; };

View File

@ -69,16 +69,12 @@ void CAudioSys::SysUnloadAudioGroupSet(std::string_view name) {
bool CAudioSys::SysIsGroupSetLoaded(std::string_view name) { return FindGroupSet(name).operator bool(); } bool CAudioSys::SysIsGroupSetLoaded(std::string_view name) { return FindGroupSet(name).operator bool(); }
void CAudioSys::SysAddGroupIntoAmuse(std::string_view name) { void CAudioSys::SysAddGroupIntoAmuse(std::string_view name) {
if (auto set = FindGroupSet(name))
AddAudioGroup(set->GetAudioGroupData());
} }
void CAudioSys::SysRemoveGroupFromAmuse(std::string_view name) { void CAudioSys::SysRemoveGroupFromAmuse(std::string_view name) {
if (auto set = FindGroupSet(name))
RemoveAudioGroup(set->GetAudioGroupData());
} }
void CAudioSys::_UpdateVolume() { GetAmuseEngine().setVolume(s_MasterVol * s_SfxVol); } void CAudioSys::_UpdateVolume() { }
void CAudioSys::SysSetVolume(u8 volume) { void CAudioSys::SysSetVolume(u8 volume) {
s_MasterVol = volume / 127.f; s_MasterVol = volume / 127.f;

View File

@ -4,8 +4,8 @@
#include "Runtime/GCNTypes.hpp" #include "Runtime/GCNTypes.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include <amuse/amuse.hpp> //#include <amuse/amuse.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp> //#include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
namespace metaforce { namespace metaforce {
@ -21,8 +21,6 @@ public:
private: private:
static CAudioSys* g_SharedSys; static CAudioSys* g_SharedSys;
boo::IAudioVoiceEngine* m_voiceEngine;
amuse::Engine m_engine;
static void _UpdateVolume(); static void _UpdateVolume();
public: public:
@ -38,16 +36,11 @@ public:
bool x28_important; // Can't be allocated over, regardless of priority bool x28_important; // Can't be allocated over, regardless of priority
u8 x29_prio; u8 x29_prio;
}; };
CAudioSys(boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend, u8, u8, u8, u8, u32) CAudioSys(u8, u8, u8, u8, u32) {
: m_voiceEngine(voiceEngine), m_engine(backend) {
g_SharedSys = this; g_SharedSys = this;
} }
~CAudioSys() { g_SharedSys = nullptr; } ~CAudioSys() { g_SharedSys = nullptr; }
static void AddAudioGroup(const amuse::AudioGroupData& data) { g_SharedSys->m_engine.addAudioGroup(data); }
static void RemoveAudioGroup(const amuse::AudioGroupData& data) { g_SharedSys->m_engine.removeAudioGroup(data); }
static boo::IAudioVoiceEngine* GetVoiceEngine() { return g_SharedSys->m_voiceEngine; }
static amuse::Engine& GetAmuseEngine() { return g_SharedSys->m_engine; }
static void SetSurroundMode(ESurroundModes mode) {} static void SetSurroundMode(ESurroundModes mode) {}
static TLockedToken<CAudioGroupSet> FindGroupSet(std::string_view name); static TLockedToken<CAudioGroupSet> FindGroupSet(std::string_view name);
static std::string_view SysGetGroupSetName(CAssetId id); static std::string_view SysGetGroupSetName(CAssetId id);

View File

@ -12,14 +12,14 @@ void CMidiManager::StopAll() {
} }
void CMidiManager::Stop(const CMidiHandle& handle, float fadeTime) { void CMidiManager::Stop(const CMidiHandle& handle, float fadeTime) {
handle->GetAudioSysHandle()->stopSong(fadeTime); // handle->GetAudioSysHandle()->stopSong(fadeTime);
m_MidiWrappers.erase(handle); // m_MidiWrappers.erase(handle);
} }
std::unordered_set<CMidiHandle>::iterator CMidiManager::Stop(std::unordered_set<CMidiHandle>::iterator handle, std::unordered_set<CMidiHandle>::iterator CMidiManager::Stop(std::unordered_set<CMidiHandle>::iterator handle,
float fadeTime) { float fadeTime) {
const CMidiHandle& h = *handle; // const CMidiHandle& h = *handle;
h->GetAudioSysHandle()->stopSong(fadeTime); // h->GetAudioSysHandle()->stopSong(fadeTime);
return m_MidiWrappers.erase(handle); return m_MidiWrappers.erase(handle);
} }
@ -29,10 +29,10 @@ CMidiHandle CMidiManager::Play(const CMidiData& data, float fadeTime, bool stopE
it = Stop(it, fadeTime); it = Stop(it, fadeTime);
CMidiHandle handle = *m_MidiWrappers.insert(std::make_shared<CMidiWrapper>()).first; CMidiHandle handle = *m_MidiWrappers.insert(std::make_shared<CMidiWrapper>()).first;
handle->SetAudioSysHandle( // handle->SetAudioSysHandle(
CAudioSys::GetAmuseEngine().seqPlay(data.GetGroupId(), data.GetSetupId(), data.GetArrData())); // CAudioSys::GetAmuseEngine().seqPlay(data.GetGroupId(), data.GetSetupId(), data.GetArrData()));
handle->GetAudioSysHandle()->setVolume(volume, fadeTime); // handle->GetAudioSysHandle()->setVolume(volume, fadeTime);
handle->SetSongId(data.GetSetupId()); // handle->SetSongId(data.GetSetupId());
return handle; return handle;
} }

View File

@ -23,14 +23,14 @@ public:
}; };
class CMidiWrapper { class CMidiWrapper {
amuse::ObjToken<amuse::Sequencer> x0_sequencer; //amuse::ObjToken<amuse::Sequencer> x0_sequencer;
// CSfxHandle x4_handle; // CSfxHandle x4_handle;
u16 x8_songId; u16 x8_songId;
bool xa_available = true; bool xa_available = true;
public: public:
amuse::ObjToken<amuse::Sequencer> GetAudioSysHandle() const { return x0_sequencer; } //amuse::ObjToken<amuse::Sequencer> GetAudioSysHandle() const { return x0_sequencer; }
void SetAudioSysHandle(amuse::ObjToken<amuse::Sequencer> sequencer) { x0_sequencer = std::move(sequencer); } //void SetAudioSysHandle(amuse::ObjToken<amuse::Sequencer> sequencer) { x0_sequencer = std::move(sequencer); }
// const CSfxHandle& GetManagerHandle() const { return x4_handle; } // const CSfxHandle& GetManagerHandle() const { return x4_handle; }
// void SetMidiHandle(const CSfxHandle& handle) { x4_handle = handle; } // void SetMidiHandle(const CSfxHandle& handle) { x4_handle = handle; }
bool IsAvailable() const { return xa_available; } bool IsAvailable() const { return xa_available; }

View File

@ -7,15 +7,15 @@ namespace metaforce {
static TLockedToken<std::vector<u16>> mpSfxTranslationTableTok; static TLockedToken<std::vector<u16>> mpSfxTranslationTableTok;
std::vector<u16>* CSfxManager::mpSfxTranslationTable = nullptr; std::vector<u16>* CSfxManager::mpSfxTranslationTable = nullptr;
static amuse::EffectReverbHiInfo s_ReverbHiQueued; //static amuse::EffectReverbHiInfo s_ReverbHiQueued;
static amuse::EffectChorusInfo s_ChorusQueued; //static amuse::EffectChorusInfo s_ChorusQueued;
static amuse::EffectReverbStdInfo s_ReverbStdQueued; //static amuse::EffectReverbStdInfo s_ReverbStdQueued;
static amuse::EffectDelayInfo s_DelayQueued; //static amuse::EffectDelayInfo s_DelayQueued;
//
static amuse::EffectReverbHi* s_ReverbHiState = nullptr; //static amuse::EffectReverbHi* s_ReverbHiState = nullptr;
static amuse::EffectChorus* s_ChorusState = nullptr; //static amuse::EffectChorus* s_ChorusState = nullptr;
static amuse::EffectReverbStd* s_ReverbStdState = nullptr; //static amuse::EffectReverbStd* s_ReverbStdState = nullptr;
static amuse::EffectDelay* s_DelayState = nullptr; //static amuse::EffectDelay* s_DelayState = nullptr;
CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
CObjectReference* selfRef) { CObjectReference* selfRef) {
@ -36,7 +36,7 @@ bool CSfxManager::m_auxProcessingEnabled = false;
float CSfxManager::m_reverbAmount = 1.f; float CSfxManager::m_reverbAmount = 1.f;
CSfxManager::EAuxEffect CSfxManager::m_activeEffect = CSfxManager::EAuxEffect::None; CSfxManager::EAuxEffect CSfxManager::m_activeEffect = CSfxManager::EAuxEffect::None;
CSfxManager::EAuxEffect CSfxManager::m_nextEffect = CSfxManager::EAuxEffect::None; CSfxManager::EAuxEffect CSfxManager::m_nextEffect = CSfxManager::EAuxEffect::None;
amuse::ObjToken<amuse::Listener> CSfxManager::m_listener; //amuse::ObjToken<amuse::Listener> CSfxManager::m_listener;
u16 CSfxManager::kMaxPriority; u16 CSfxManager::kMaxPriority;
u16 CSfxManager::kMedPriority; u16 CSfxManager::kMedPriority;
@ -54,27 +54,27 @@ bool CSfxManager::LoadTranslationTable(CSimplePool* pool, const SObjectTag* tag)
} }
bool CSfxManager::CSfxWrapper::IsPlaying() const { bool CSfxManager::CSfxWrapper::IsPlaying() const {
if (CBaseSfxWrapper::IsPlaying() && x1c_voiceHandle) // if (CBaseSfxWrapper::IsPlaying() && x1c_voiceHandle)
return x1c_voiceHandle->state() == amuse::VoiceState::Playing; // return x1c_voiceHandle->state() == amuse::VoiceState::Playing;
return false; return false;
} }
void CSfxManager::CSfxWrapper::Play() { void CSfxManager::CSfxWrapper::Play() {
x1c_voiceHandle = CAudioSys::GetAmuseEngine().fxStart(x18_sfxId, x20_vol, x22_pan); // x1c_voiceHandle = CAudioSys::GetAmuseEngine().fxStart(x18_sfxId, x20_vol, x22_pan);
if (x1c_voiceHandle) { // if (x1c_voiceHandle) {
if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics()) // if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics())
x1c_voiceHandle->setReverbVol(m_reverbAmount); // x1c_voiceHandle->setReverbVol(m_reverbAmount);
SetPlaying(true); // SetPlaying(true);
} // }
x24_ready = false; x24_ready = false;
} }
void CSfxManager::CSfxWrapper::Stop() { void CSfxManager::CSfxWrapper::Stop() {
if (x1c_voiceHandle) { // if (x1c_voiceHandle) {
x1c_voiceHandle->keyOff(); // x1c_voiceHandle->keyOff();
SetPlaying(false); // SetPlaying(false);
x1c_voiceHandle.reset(); // x1c_voiceHandle.reset();
} // }
} }
bool CSfxManager::CSfxWrapper::Ready() { bool CSfxManager::CSfxWrapper::Ready() {
@ -86,25 +86,25 @@ bool CSfxManager::CSfxWrapper::Ready() {
u16 CSfxManager::CSfxWrapper::GetSfxId() const { return x18_sfxId; } u16 CSfxManager::CSfxWrapper::GetSfxId() const { return x18_sfxId; }
void CSfxManager::CSfxWrapper::UpdateEmitterSilent() { void CSfxManager::CSfxWrapper::UpdateEmitterSilent() {
if (x1c_voiceHandle) // if (x1c_voiceHandle)
x1c_voiceHandle->setVolume(1.f / 127.f); // x1c_voiceHandle->setVolume(1.f / 127.f);
} }
void CSfxManager::CSfxWrapper::UpdateEmitter() { void CSfxManager::CSfxWrapper::UpdateEmitter() {
if (x1c_voiceHandle) // if (x1c_voiceHandle)
x1c_voiceHandle->setVolume(x20_vol); // x1c_voiceHandle->setVolume(x20_vol);
} }
void CSfxManager::CSfxWrapper::SetReverb(float rev) { void CSfxManager::CSfxWrapper::SetReverb(float rev) {
if (x1c_voiceHandle && IsAuxProcessingEnabled() && UseAcoustics()) // if (x1c_voiceHandle && IsAuxProcessingEnabled() && UseAcoustics())
x1c_voiceHandle->setReverbVol(rev); // x1c_voiceHandle->setReverbVol(rev);
} }
bool CSfxManager::CSfxEmitterWrapper::IsPlaying() const { bool CSfxManager::CSfxEmitterWrapper::IsPlaying() const {
if (IsLooped()) if (IsLooped())
return CBaseSfxWrapper::IsPlaying(); return CBaseSfxWrapper::IsPlaying();
if (CBaseSfxWrapper::IsPlaying() && x50_emitterHandle) // if (CBaseSfxWrapper::IsPlaying() && x50_emitterHandle)
return x50_emitterHandle->getVoice()->state() == amuse::VoiceState::Playing; // return x50_emitterHandle->getVoice()->state() == amuse::VoiceState::Playing;
return false; return false;
} }
@ -114,23 +114,23 @@ void CSfxManager::CSfxEmitterWrapper::Play() {
else else
x1a_reverb = 0.f; x1a_reverb = 0.f;
zeus::simd_floats pos(x24_parmData.x0_pos.mSimd); // zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
zeus::simd_floats dir(x24_parmData.xc_dir.mSimd); // zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
x50_emitterHandle = CAudioSys::GetAmuseEngine().addEmitter( // x50_emitterHandle = CAudioSys::GetAmuseEngine().addEmitter(
pos.data(), dir.data(), x24_parmData.x18_maxDist, x24_parmData.x1c_distComp, x24_parmData.x24_sfxId, // pos.data(), dir.data(), x24_parmData.x18_maxDist, x24_parmData.x1c_distComp, x24_parmData.x24_sfxId,
x24_parmData.x27_minVol, x24_parmData.x26_maxVol, (x24_parmData.x20_flags & 0x8) != 0); // x24_parmData.x27_minVol, x24_parmData.x26_maxVol, (x24_parmData.x20_flags & 0x8) != 0);
//
if (x50_emitterHandle) // if (x50_emitterHandle)
SetPlaying(true); // SetPlaying(true);
x54_ready = false; x54_ready = false;
} }
void CSfxManager::CSfxEmitterWrapper::Stop() { void CSfxManager::CSfxEmitterWrapper::Stop() {
if (x50_emitterHandle) { // if (x50_emitterHandle) {
x50_emitterHandle->getVoice()->keyOff(); // x50_emitterHandle->getVoice()->keyOff();
SetPlaying(false); // SetPlaying(false);
x50_emitterHandle.reset(); // x50_emitterHandle.reset();
} // }
} }
bool CSfxManager::CSfxEmitterWrapper::Ready() { bool CSfxManager::CSfxEmitterWrapper::Ready() {
@ -154,22 +154,22 @@ CSfxManager::ESfxAudibility CSfxManager::CSfxEmitterWrapper::GetAudible(const ze
u16 CSfxManager::CSfxEmitterWrapper::GetSfxId() const { return x24_parmData.x24_sfxId; } u16 CSfxManager::CSfxEmitterWrapper::GetSfxId() const { return x24_parmData.x24_sfxId; }
void CSfxManager::CSfxEmitterWrapper::UpdateEmitterSilent() { void CSfxManager::CSfxEmitterWrapper::UpdateEmitterSilent() {
if (x50_emitterHandle) { // if (x50_emitterHandle) {
zeus::simd_floats pos(x24_parmData.x0_pos.mSimd); // zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
zeus::simd_floats dir(x24_parmData.xc_dir.mSimd); // zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
x50_emitterHandle->setVectors(pos.data(), dir.data()); // x50_emitterHandle->setVectors(pos.data(), dir.data());
x50_emitterHandle->setMaxVol(1.f / 127.f); // x50_emitterHandle->setMaxVol(1.f / 127.f);
} // }
x55_cachedMaxVol = x24_parmData.x26_maxVol; x55_cachedMaxVol = x24_parmData.x26_maxVol;
} }
void CSfxManager::CSfxEmitterWrapper::UpdateEmitter() { void CSfxManager::CSfxEmitterWrapper::UpdateEmitter() {
if (x50_emitterHandle) { // if (x50_emitterHandle) {
zeus::simd_floats pos(x24_parmData.x0_pos.mSimd); // zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
zeus::simd_floats dir(x24_parmData.xc_dir.mSimd); // zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
x50_emitterHandle->setVectors(pos.data(), dir.data()); // x50_emitterHandle->setVectors(pos.data(), dir.data());
x50_emitterHandle->setMaxVol(x55_cachedMaxVol); // x50_emitterHandle->setMaxVol(x55_cachedMaxVol);
} // }
} }
void CSfxManager::CSfxEmitterWrapper::SetReverb(float rev) { void CSfxManager::CSfxEmitterWrapper::SetReverb(float rev) {
@ -238,26 +238,26 @@ void CSfxManager::TurnOffChannel(ESfxChannels chan) {
void CSfxManager::AddListener(ESfxChannels channel, const zeus::CVector3f& pos, const zeus::CVector3f& dir, void CSfxManager::AddListener(ESfxChannels channel, const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& heading, const zeus::CVector3f& up, float frontRadius, const zeus::CVector3f& heading, const zeus::CVector3f& up, float frontRadius,
float surroundRadius, float soundSpeed, u32 flags /* 0x1 for doppler */, float vol) { float surroundRadius, float soundSpeed, u32 flags /* 0x1 for doppler */, float vol) {
if (m_listener) // if (m_listener)
CAudioSys::GetAmuseEngine().removeListener(m_listener.get()); // CAudioSys::GetAmuseEngine().removeListener(m_listener.get());
zeus::simd_floats p(pos.mSimd); // zeus::simd_floats p(pos.mSimd);
zeus::simd_floats d(dir.mSimd); // zeus::simd_floats d(dir.mSimd);
zeus::simd_floats h(heading.mSimd); // zeus::simd_floats h(heading.mSimd);
zeus::simd_floats u(up.mSimd); // zeus::simd_floats u(up.mSimd);
m_listener = CAudioSys::GetAmuseEngine().addListener(p.data(), d.data(), h.data(), u.data(), frontRadius, // m_listener = CAudioSys::GetAmuseEngine().addListener(p.data(), d.data(), h.data(), u.data(), frontRadius,
surroundRadius, soundSpeed, vol); // surroundRadius, soundSpeed, vol);
} }
void CSfxManager::UpdateListener(const zeus::CVector3f& pos, const zeus::CVector3f& dir, const zeus::CVector3f& heading, void CSfxManager::UpdateListener(const zeus::CVector3f& pos, const zeus::CVector3f& dir, const zeus::CVector3f& heading,
const zeus::CVector3f& up, float vol) { const zeus::CVector3f& up, float vol) {
if (m_listener) { // if (m_listener) {
zeus::simd_floats p(pos.mSimd); // zeus::simd_floats p(pos.mSimd);
zeus::simd_floats d(dir.mSimd); // zeus::simd_floats d(dir.mSimd);
zeus::simd_floats h(heading.mSimd); // zeus::simd_floats h(heading.mSimd);
zeus::simd_floats u(up.mSimd); // zeus::simd_floats u(up.mSimd);
m_listener->setVectors(p.data(), d.data(), h.data(), u.data()); // m_listener->setVectors(p.data(), d.data(), h.data(), u.data());
m_listener->setVolume(vol); // m_listener->setVolume(vol);
} // }
} }
s16 CSfxManager::GetRank(CBaseSfxWrapper* sfx) { s16 CSfxManager::GetRank(CBaseSfxWrapper* sfx) {
@ -304,10 +304,10 @@ void CSfxManager::PitchBend(const CSfxHandle& handle, float pitch) {
return; return;
if (!handle->IsPlaying()) if (!handle->IsPlaying())
CSfxManager::Update(0.f); CSfxManager::Update(0.f);
if (handle->IsPlaying()) { // if (handle->IsPlaying()) {
m_doUpdate = true; // m_doUpdate = true;
handle->GetVoice()->setPitchWheel(pitch); // handle->GetVoice()->setPitchWheel(pitch);
} // }
} }
void CSfxManager::SfxVolume(const CSfxHandle& handle, float vol) { void CSfxManager::SfxVolume(const CSfxHandle& handle, float vol) {
@ -317,15 +317,15 @@ void CSfxManager::SfxVolume(const CSfxHandle& handle, float vol) {
CSfxWrapper& wrapper = static_cast<CSfxWrapper&>(*handle); CSfxWrapper& wrapper = static_cast<CSfxWrapper&>(*handle);
wrapper.SetVolume(vol); wrapper.SetVolume(vol);
} }
if (handle->IsPlaying()) // if (handle->IsPlaying())
handle->GetVoice()->setVolume(vol); // handle->GetVoice()->setVolume(vol);
} }
void CSfxManager::SfxSpan(const CSfxHandle& handle, float span) { void CSfxManager::SfxSpan(const CSfxHandle& handle, float span) {
if (!handle) if (!handle)
return; return;
if (handle->IsPlaying()) // if (handle->IsPlaying())
handle->GetVoice()->setSurroundPan(span); // handle->GetVoice()->setSurroundPan(span);
} }
u16 CSfxManager::TranslateSFXID(u16 id) { u16 CSfxManager::TranslateSFXID(u16 id) {
@ -380,16 +380,16 @@ void CSfxManager::UpdateEmitter(const CSfxHandle& handle, const zeus::CVector3f&
float maxVol) { float maxVol) {
if (!handle || !handle->IsEmitter() || !handle->IsPlaying()) if (!handle || !handle->IsEmitter() || !handle->IsPlaying())
return; return;
m_doUpdate = true; // m_doUpdate = true;
CSfxEmitterWrapper& emitter = static_cast<CSfxEmitterWrapper&>(*handle); // CSfxEmitterWrapper& emitter = static_cast<CSfxEmitterWrapper&>(*handle);
emitter.GetEmitterData().x0_pos = pos; // emitter.GetEmitterData().x0_pos = pos;
emitter.GetEmitterData().xc_dir = dir; // emitter.GetEmitterData().xc_dir = dir;
emitter.GetEmitterData().x26_maxVol = maxVol; // emitter.GetEmitterData().x26_maxVol = maxVol;
amuse::Emitter& h = *emitter.GetHandle(); // amuse::Emitter& h = *emitter.GetHandle();
zeus::simd_floats p(pos.mSimd); // zeus::simd_floats p(pos.mSimd);
zeus::simd_floats d(dir.mSimd); // zeus::simd_floats d(dir.mSimd);
h.setVectors(p.data(), d.data()); // h.setVectors(p.data(), d.data());
h.setMaxVol(maxVol); // h.setMaxVol(maxVol);
} }
CSfxHandle CSfxManager::AddEmitter(u16 id, const zeus::CVector3f& pos, const zeus::CVector3f& dir, bool useAcoustics, CSfxHandle CSfxManager::AddEmitter(u16 id, const zeus::CVector3f& pos, const zeus::CVector3f& dir, bool useAcoustics,
@ -459,84 +459,84 @@ void CSfxManager::EnableAuxCallback() {
if (m_activeEffect != EAuxEffect::None) if (m_activeEffect != EAuxEffect::None)
DisableAuxCallback(); DisableAuxCallback();
auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio(); // auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio();
amuse::Submix& smix = studio->getAuxA(); // amuse::Submix& smix = studio->getAuxA();
//
m_activeEffect = m_nextEffect; // m_activeEffect = m_nextEffect;
switch (m_activeEffect) { // switch (m_activeEffect) {
case EAuxEffect::ReverbHi: // case EAuxEffect::ReverbHi:
s_ReverbHiState = &smix.makeReverbHi(s_ReverbHiQueued); // s_ReverbHiState = &smix.makeReverbHi(s_ReverbHiQueued);
break; // break;
case EAuxEffect::Chorus: // case EAuxEffect::Chorus:
s_ChorusState = &smix.makeChorus(s_ChorusQueued); // s_ChorusState = &smix.makeChorus(s_ChorusQueued);
break; // break;
case EAuxEffect::ReverbStd: // case EAuxEffect::ReverbStd:
s_ReverbStdState = &smix.makeReverbStd(s_ReverbStdQueued); // s_ReverbStdState = &smix.makeReverbStd(s_ReverbStdQueued);
break; // break;
case EAuxEffect::Delay: // case EAuxEffect::Delay:
s_DelayState = &smix.makeDelay(s_DelayQueued); // s_DelayState = &smix.makeDelay(s_DelayQueued);
break; // break;
default: // default:
break; // break;
} // }
m_auxProcessingEnabled = true; m_auxProcessingEnabled = true;
} }
void CSfxManager::PrepareDelayCallback(const amuse::EffectDelayInfo& info) { //void CSfxManager::PrepareDelayCallback(const amuse::EffectDelayInfo& info) {
DisableAuxProcessing(); // DisableAuxProcessing();
s_DelayQueued = info; // s_DelayQueued = info;
m_nextEffect = EAuxEffect::Delay; // m_nextEffect = EAuxEffect::Delay;
if (m_reverbAmount == 0.f) // if (m_reverbAmount == 0.f)
EnableAuxCallback(); // EnableAuxCallback();
} //}
//
void CSfxManager::PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info) { //void CSfxManager::PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info) {
DisableAuxProcessing(); // DisableAuxProcessing();
s_ReverbStdQueued = info; // s_ReverbStdQueued = info;
m_nextEffect = EAuxEffect::ReverbStd; // m_nextEffect = EAuxEffect::ReverbStd;
if (m_reverbAmount == 0.f) // if (m_reverbAmount == 0.f)
EnableAuxCallback(); // EnableAuxCallback();
} //}
//
void CSfxManager::PrepareChorusCallback(const amuse::EffectChorusInfo& info) { //void CSfxManager::PrepareChorusCallback(const amuse::EffectChorusInfo& info) {
DisableAuxProcessing(); // DisableAuxProcessing();
s_ChorusQueued = info; // s_ChorusQueued = info;
m_nextEffect = EAuxEffect::Chorus; // m_nextEffect = EAuxEffect::Chorus;
if (m_reverbAmount == 0.f) // if (m_reverbAmount == 0.f)
EnableAuxCallback(); // EnableAuxCallback();
} //}
//
void CSfxManager::PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info) { //void CSfxManager::PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info) {
DisableAuxProcessing(); // DisableAuxProcessing();
s_ReverbHiQueued = info; // s_ReverbHiQueued = info;
m_nextEffect = EAuxEffect::ReverbHi; // m_nextEffect = EAuxEffect::ReverbHi;
if (m_reverbAmount == 0.f) // if (m_reverbAmount == 0.f)
EnableAuxCallback(); // EnableAuxCallback();
} //}
void CSfxManager::DisableAuxCallback() { void CSfxManager::DisableAuxCallback() {
auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio(); // auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio();
studio->getAuxA().clearEffects(); // studio->getAuxA().clearEffects();
//
switch (m_activeEffect) { // switch (m_activeEffect) {
case EAuxEffect::ReverbHi: // case EAuxEffect::ReverbHi:
s_ReverbHiState = nullptr; // s_ReverbHiState = nullptr;
break; // break;
case EAuxEffect::Chorus: // case EAuxEffect::Chorus:
s_ChorusState = nullptr; // s_ChorusState = nullptr;
break; // break;
case EAuxEffect::ReverbStd: // case EAuxEffect::ReverbStd:
s_ReverbStdState = nullptr; // s_ReverbStdState = nullptr;
break; // break;
case EAuxEffect::Delay: // case EAuxEffect::Delay:
s_DelayState = nullptr; // s_DelayState = nullptr;
break; // break;
default: // default:
break; // break;
} // }
//
m_activeEffect = EAuxEffect::None; // m_activeEffect = EAuxEffect::None;
} }
void CSfxManager::DisableAuxProcessing() { void CSfxManager::DisableAuxProcessing() {

View File

@ -90,7 +90,7 @@ public:
virtual void Stop() = 0; virtual void Stop() = 0;
virtual bool Ready() = 0; virtual bool Ready() = 0;
virtual ESfxAudibility GetAudible(const zeus::CVector3f&) = 0; virtual ESfxAudibility GetAudible(const zeus::CVector3f&) = 0;
virtual amuse::ObjToken<amuse::Voice> GetVoice() const = 0; //virtual amuse::ObjToken<amuse::Voice> GetVoice() const = 0;
virtual u16 GetSfxId() const = 0; virtual u16 GetSfxId() const = 0;
virtual void UpdateEmitterSilent() = 0; virtual void UpdateEmitterSilent() = 0;
virtual void UpdateEmitter() = 0; virtual void UpdateEmitter() = 0;
@ -116,7 +116,7 @@ public:
class CSfxEmitterWrapper : public CBaseSfxWrapper { class CSfxEmitterWrapper : public CBaseSfxWrapper {
float x1a_reverb = 0.0f; float x1a_reverb = 0.0f;
CAudioSys::C3DEmitterParmData x24_parmData; CAudioSys::C3DEmitterParmData x24_parmData;
amuse::ObjToken<amuse::Emitter> x50_emitterHandle; //amuse::ObjToken<amuse::Emitter> x50_emitterHandle;
bool x54_ready = true; bool x54_ready = true;
float x55_cachedMaxVol = 0.0f; float x55_cachedMaxVol = 0.0f;
@ -126,14 +126,14 @@ public:
void Stop() override; void Stop() override;
bool Ready() override; bool Ready() override;
ESfxAudibility GetAudible(const zeus::CVector3f&) override; ESfxAudibility GetAudible(const zeus::CVector3f&) override;
amuse::ObjToken<amuse::Voice> GetVoice() const override { return x50_emitterHandle->getVoice(); } //amuse::ObjToken<amuse::Voice> GetVoice() const override { return x50_emitterHandle->getVoice(); }
u16 GetSfxId() const override; u16 GetSfxId() const override;
void UpdateEmitterSilent() override; void UpdateEmitterSilent() override;
void UpdateEmitter() override; void UpdateEmitter() override;
void SetReverb(float rev) override; void SetReverb(float rev) override;
CAudioSys::C3DEmitterParmData& GetEmitterData() { return x24_parmData; } CAudioSys::C3DEmitterParmData& GetEmitterData() { return x24_parmData; }
amuse::ObjToken<amuse::Emitter> GetHandle() const { return x50_emitterHandle; } //amuse::ObjToken<amuse::Emitter> GetHandle() const { return x50_emitterHandle; }
CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data, CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data,
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area) /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
@ -144,7 +144,7 @@ public:
class CSfxWrapper : public CBaseSfxWrapper { class CSfxWrapper : public CBaseSfxWrapper {
u16 x18_sfxId; u16 x18_sfxId;
amuse::ObjToken<amuse::Voice> x1c_voiceHandle; //amuse::ObjToken<amuse::Voice> x1c_voiceHandle;
float x20_vol; float x20_vol;
float x22_pan; float x22_pan;
bool x24_ready = true; bool x24_ready = true;
@ -155,7 +155,7 @@ public:
void Stop() override; void Stop() override;
bool Ready() override; bool Ready() override;
ESfxAudibility GetAudible(const zeus::CVector3f&) override { return ESfxAudibility::Aud3; } ESfxAudibility GetAudible(const zeus::CVector3f&) override { return ESfxAudibility::Aud3; }
amuse::ObjToken<amuse::Voice> GetVoice() const override { return x1c_voiceHandle; } // amuse::ObjToken<amuse::Voice> GetVoice() const override { return x1c_voiceHandle; }
u16 GetSfxId() const override; u16 GetSfxId() const override;
void UpdateEmitterSilent() override; void UpdateEmitterSilent() override;
void UpdateEmitter() override; void UpdateEmitter() override;
@ -178,7 +178,7 @@ public:
static float m_reverbAmount; static float m_reverbAmount;
static EAuxEffect m_activeEffect; static EAuxEffect m_activeEffect;
static EAuxEffect m_nextEffect; static EAuxEffect m_nextEffect;
static amuse::ObjToken<amuse::Listener> m_listener; //static amuse::ObjToken<amuse::Listener> m_listener;
static u16 kMaxPriority; static u16 kMaxPriority;
static u16 kMedPriority; static u16 kMedPriority;
@ -222,10 +222,10 @@ public:
static void StopAndRemoveAllEmitters(); static void StopAndRemoveAllEmitters();
static void DisableAuxCallback(); static void DisableAuxCallback();
static void EnableAuxCallback(); static void EnableAuxCallback();
static void PrepareDelayCallback(const amuse::EffectDelayInfo& info); // static void PrepareDelayCallback(const amuse::EffectDelayInfo& info);
static void PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info); // static void PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info);
static void PrepareChorusCallback(const amuse::EffectChorusInfo& info); // static void PrepareChorusCallback(const amuse::EffectChorusInfo& info);
static void PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info); // static void PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info);
static void DisableAuxProcessing(); static void DisableAuxProcessing();
static void SetActiveAreas(const rstl::reserved_vector<TAreaId, 10>& areas); static void SetActiveAreas(const rstl::reserved_vector<TAreaId, 10>& areas);

View File

@ -7,37 +7,37 @@ namespace metaforce {
#define RSF_BUFFER_SIZE 0x20000 #define RSF_BUFFER_SIZE 0x20000
CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart, //CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart,
int loopEnd) // int loopEnd)
: x0_path(path) //: x0_path(path)
, x1c_loopStartSamp(loopStart & 0xfffffffe) //, x1c_loopStartSamp(loopStart & 0xfffffffe)
, x20_loopEndSamp(loopEnd & 0xfffffffe) //, x20_loopEndSamp(loopEnd & 0xfffffffe)
, m_voiceCallback(*this) //, m_voiceCallback(*this)
, m_voice(engine.allocateNewStereoVoice(32000, &m_voiceCallback)) { //, m_voice(engine.allocateNewStereoVoice(32000, &m_voiceCallback)) {
// These are mixed directly into boo voice engine instead // // These are mixed directly into boo voice engine instead
// x28_dmaLeft.reset(new u8[640]); // // x28_dmaLeft.reset(new u8[640]);
// x30_dmaRight.reset(new u8[640]); // // x30_dmaRight.reset(new u8[640]);
//
CDvdFile file(path); // CDvdFile file(path);
x10_rsfRem = file.Length(); // x10_rsfRem = file.Length();
x14_rsfLength = x10_rsfRem; // x14_rsfLength = x10_rsfRem;
//
u32 bufCount = (x10_rsfRem + RSF_BUFFER_SIZE - 1) / RSF_BUFFER_SIZE; // u32 bufCount = (x10_rsfRem + RSF_BUFFER_SIZE - 1) / RSF_BUFFER_SIZE;
x48_buffers.reserve(bufCount); // x48_buffers.reserve(bufCount);
x38_dvdRequests.reserve(bufCount); // x38_dvdRequests.reserve(bufCount);
//
for (int remBytes = x10_rsfRem; remBytes > 0; remBytes -= RSF_BUFFER_SIZE) { // for (int remBytes = x10_rsfRem; remBytes > 0; remBytes -= RSF_BUFFER_SIZE) {
u32 thisSz = RSF_BUFFER_SIZE; // u32 thisSz = RSF_BUFFER_SIZE;
if (remBytes < RSF_BUFFER_SIZE) // if (remBytes < RSF_BUFFER_SIZE)
thisSz = ROUND_UP_32(remBytes); // thisSz = ROUND_UP_32(remBytes);
//
x48_buffers.emplace_back(new u8[thisSz]); // x48_buffers.emplace_back(new u8[thisSz]);
x38_dvdRequests.push_back(file.AsyncRead(x48_buffers.back().get(), thisSz)); // x38_dvdRequests.push_back(file.AsyncRead(x48_buffers.back().get(), thisSz));
} // }
//
g72x_init_state(&x58_leftState); // g72x_init_state(&x58_leftState);
g72x_init_state(&x8c_rightState); // g72x_init_state(&x8c_rightState);
} //}
bool CStaticAudioPlayer::IsReady() { bool CStaticAudioPlayer::IsReady() {
if (x38_dvdRequests.size()) if (x38_dvdRequests.size())

View File

@ -10,8 +10,8 @@
#include "g721.h" #include "g721.h"
#include <boo/audiodev/IAudioVoice.hpp> //#include <boo/audiodev/IAudioVoice.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp> //#include <boo/audiodev/IAudioVoiceEngine.hpp>
namespace metaforce { namespace metaforce {
class IDvdRequest; class IDvdRequest;
@ -41,8 +41,8 @@ class CStaticAudioPlayer {
val = 32767; val = 32767;
return val; return val;
} }
/*
struct AudioVoiceCallback : boo::IAudioVoiceCallback { struct AudioVoiceCallback {
CStaticAudioPlayer& m_parent; CStaticAudioPlayer& m_parent;
void preSupplyAudio(boo::IAudioVoice&, double) override {} void preSupplyAudio(boo::IAudioVoice&, double) override {}
size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) override { size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) override {
@ -56,20 +56,20 @@ class CStaticAudioPlayer {
explicit AudioVoiceCallback(CStaticAudioPlayer& p) : m_parent(p) {} explicit AudioVoiceCallback(CStaticAudioPlayer& p) : m_parent(p) {}
} m_voiceCallback; } m_voiceCallback;
boo::ObjToken<boo::IAudioVoice> m_voice; boo::ObjToken<boo::IAudioVoice> m_voice;
*/
public: public:
CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart, int loopEnd); // CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart, int loopEnd);
CStaticAudioPlayer(std::string_view path, int loopStart, int loopEnd) // CStaticAudioPlayer(std::string_view path, int loopStart, int loopEnd)
: CStaticAudioPlayer(*CAudioSys::GetVoiceEngine(), path, loopStart, loopEnd) {} // : CStaticAudioPlayer(*CAudioSys::GetVoiceEngine(), path, loopStart, loopEnd) {}
bool IsReady(); bool IsReady();
void DecodeMonoAndMix(s16* bufOut, u32 numSamples, u32 cur, u32 loopEndCur, u32 loopStartCur, int vol, void DecodeMonoAndMix(s16* bufOut, u32 numSamples, u32 cur, u32 loopEndCur, u32 loopStartCur, int vol,
g72x_state& state, std::optional<g72x_state>& loopState) const; g72x_state& state, std::optional<g72x_state>& loopState) const;
void Decode(s16* bufOut, u32 numSamples); void Decode(s16* bufOut, u32 numSamples);
void SetVolume(float vol) { xc0_volume = zeus::clamp(0.f, vol, 1.f) * 32768.f; } void SetVolume(float vol) { xc0_volume = zeus::clamp(0.f, vol, 1.f) * 32768.f; }
//
void StartMixing() { m_voice->start(); } // void StartMixing() { m_voice->start(); }
void StopMixing() { m_voice->stop(); } // void StopMixing() { m_voice->stop(); }
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -11,7 +11,7 @@
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <amuse/DSPCodec.hpp> //#include <amuse/DSPCodec.hpp>
namespace metaforce { namespace metaforce {
class CDSPStreamManager; class CDSPStreamManager;
@ -54,7 +54,7 @@ struct SDSPStreamInfo {
explicit SDSPStreamInfo(const CDSPStreamManager& stream); explicit SDSPStreamInfo(const CDSPStreamManager& stream);
}; };
struct SDSPStream : boo::IAudioVoiceCallback { struct SDSPStream {
bool x0_active; bool x0_active;
bool x1_oneshot; bool x1_oneshot;
s32 x4_ownerId; s32 x4_ownerId;
@ -155,91 +155,91 @@ struct SDSPStream : boo::IAudioVoiceCallback {
s16 m_prev1 = 0; s16 m_prev1 = 0;
s16 m_prev2 = 0; s16 m_prev2 = 0;
void preSupplyAudio(boo::IAudioVoice&, double) override {} // void preSupplyAudio(boo::IAudioVoice&, double) override {}
unsigned decompressChunk(unsigned readToSample, int16_t*& data) { // unsigned decompressChunk(unsigned readToSample, int16_t*& data) {
unsigned startSamp = m_curSample; // unsigned startSamp = m_curSample;
//
// auto sampDiv = std::div(int(m_curSample), int(14));
// if (sampDiv.rem) {
// unsigned samps = DSPDecompressFrameRanged(data, xd4_ringBuffer.get() + sampDiv.quot * 8, x10_info.x1c_coef,
// &m_prev1, &m_prev2, unsigned(sampDiv.rem), readToSample - m_curSample);
// m_curSample += samps;
// data += samps;
// ++sampDiv.quot;
// }
//
// while (m_curSample < readToSample) {
// unsigned samps = DSPDecompressFrame(data, xd4_ringBuffer.get() + sampDiv.quot * 8, x10_info.x1c_coef, &m_prev1,
// &m_prev2, readToSample - m_curSample);
// m_curSample += samps;
// data += samps;
// ++sampDiv.quot;
// }
//
// return m_curSample - startSamp;
// }
auto sampDiv = std::div(int(m_curSample), int(14)); // size_t supplyAudio(boo::IAudioVoice&, size_t frames, int16_t* data) override {
if (sampDiv.rem) { // if (!x0_active) {
unsigned samps = DSPDecompressFrameRanged(data, xd4_ringBuffer.get() + sampDiv.quot * 8, x10_info.x1c_coef, // memset(data, 0, frames * 2);
&m_prev1, &m_prev2, unsigned(sampDiv.rem), readToSample - m_curSample); // return frames;
m_curSample += samps; // }
data += samps; //
++sampDiv.quot; // if (xe8_silent) {
} // StopStream();
// memset(data, 0, frames * 2);
while (m_curSample < readToSample) { // return frames;
unsigned samps = DSPDecompressFrame(data, xd4_ringBuffer.get() + sampDiv.quot * 8, x10_info.x1c_coef, &m_prev1, // }
&m_prev2, readToSample - m_curSample); //
m_curSample += samps; // unsigned halfRingSamples = xdc_ringSamples / 2;
data += samps; //
++sampDiv.quot; // size_t remFrames = frames;
} // while (remFrames) {
// if (xec_readState != 2 || (xe0_curBuffer == 0 && m_curSample >= halfRingSamples)) {
return m_curSample - startSamp; // if (!BufferStream()) {
} // memset(data, 0, remFrames * 2);
// return frames;
size_t supplyAudio(boo::IAudioVoice&, size_t frames, int16_t* data) override { // }
if (!x0_active) { // }
memset(data, 0, frames * 2); //
return frames; // unsigned readToSample =
} // std::min(m_curSample + unsigned(remFrames), (m_curSample / halfRingSamples + 1) * halfRingSamples);
//
if (xe8_silent) { // if (!x10_info.x10_loopFlag) {
StopStream(); // m_totalSamples += remFrames;
memset(data, 0, frames * 2); // size_t fileSamples = x10_info.xc_adpcmBytes * 14 / 8;
return frames; // if (m_totalSamples >= fileSamples) {
} // size_t leftover = m_totalSamples - fileSamples;
// readToSample -= leftover;
unsigned halfRingSamples = xdc_ringSamples / 2; // remFrames -= leftover;
// memset(data + remFrames, 0, leftover * 2);
size_t remFrames = frames; // StopStream();
while (remFrames) { // }
if (xec_readState != 2 || (xe0_curBuffer == 0 && m_curSample >= halfRingSamples)) { // }
if (!BufferStream()) { //
memset(data, 0, remFrames * 2); // unsigned leftoverSamples = 0;
return frames; // if (readToSample > xdc_ringSamples) {
} // leftoverSamples = readToSample - xdc_ringSamples;
} // readToSample = xdc_ringSamples;
// }
unsigned readToSample = //
std::min(m_curSample + unsigned(remFrames), (m_curSample / halfRingSamples + 1) * halfRingSamples); // remFrames -= decompressChunk(readToSample, data);
//
if (!x10_info.x10_loopFlag) { // if (leftoverSamples) {
m_totalSamples += remFrames; // BufferStream();
size_t fileSamples = x10_info.xc_adpcmBytes * 14 / 8; // m_curSample = 0;
if (m_totalSamples >= fileSamples) { // remFrames -= decompressChunk(leftoverSamples, data);
size_t leftover = m_totalSamples - fileSamples; // }
readToSample -= leftover; // }
remFrames -= leftover; //
memset(data + remFrames, 0, leftover * 2); // return frames;
StopStream(); // }
} // boo::ObjToken<boo::IAudioVoice> m_booVoice;
}
unsigned leftoverSamples = 0;
if (readToSample > xdc_ringSamples) {
leftoverSamples = readToSample - xdc_ringSamples;
readToSample = xdc_ringSamples;
}
remFrames -= decompressChunk(readToSample, data);
if (leftoverSamples) {
BufferStream();
m_curSample = 0;
remFrames -= decompressChunk(leftoverSamples, data);
}
}
return frames;
}
boo::ObjToken<boo::IAudioVoice> m_booVoice;
void DoAllocateStream() { void DoAllocateStream() {
xd4_ringBuffer.reset(new u8[0x11DC0]); xd4_ringBuffer.reset(new u8[0x11DC0]);
m_booVoice = CAudioSys::GetVoiceEngine()->allocateNewMonoVoice(32000.0, this); //m_booVoice = CAudioSys::GetVoiceEngine()->allocateNewMonoVoice(32000.0, this);
} }
static void Initialize() { static void Initialize() {
@ -259,18 +259,18 @@ struct SDSPStream : boo::IAudioVoiceCallback {
} }
static void FreeAllStreams() { static void FreeAllStreams() {
for (auto& stream : g_Streams) { // for (auto& stream : g_Streams) {
stream.m_booVoice.reset(); // stream.m_booVoice.reset();
stream.x0_active = false; // stream.x0_active = false;
for (auto& request : stream.m_readReqs) { // for (auto& request : stream.m_readReqs) {
if (request) { // if (request) {
request->PostCancelRequest(); // request->PostCancelRequest();
request.reset(); // request.reset();
} // }
} // }
stream.xd4_ringBuffer.reset(); // stream.xd4_ringBuffer.reset();
stream.m_file = std::nullopt; // stream.m_file = std::nullopt;
} // }
} }
static s32 PickFreeStream(SDSPStream*& streamOut, bool oneshot) { static s32 PickFreeStream(SDSPStream*& streamOut, bool oneshot) {
@ -302,27 +302,27 @@ struct SDSPStream : boo::IAudioVoiceCallback {
} }
void UpdateStreamVolume(float vol) { void UpdateStreamVolume(float vol) {
x4c_vol = vol; // x4c_vol = vol;
if (!x0_active || xe8_silent) { // if (!x0_active || xe8_silent) {
return; // return;
} // }
std::array<float, 8> coefs{}; // std::array<float, 8> coefs{};
coefs[size_t(boo::AudioChannel::FrontLeft)] = m_leftgain * vol; // coefs[size_t(boo::AudioChannel::FrontLeft)] = m_leftgain * vol;
coefs[size_t(boo::AudioChannel::FrontRight)] = m_rightgain * vol; // coefs[size_t(boo::AudioChannel::FrontRight)] = m_rightgain * vol;
m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true); // m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true);
} }
static void UpdateVolume(s32 id, float vol) { static void UpdateVolume(s32 id, float vol) {
s32 idx = FindStreamIdx(id); // s32 idx = FindStreamIdx(id);
if (idx == -1) // if (idx == -1)
return; // return;
//
SDSPStream& stream = g_Streams[idx]; // SDSPStream& stream = g_Streams[idx];
stream.UpdateStreamVolume(vol); // stream.UpdateStreamVolume(vol);
if (SDSPStream* left = stream.x8_stereoLeft) // if (SDSPStream* left = stream.x8_stereoLeft)
left->UpdateStreamVolume(vol); // left->UpdateStreamVolume(vol);
if (SDSPStream* right = stream.xc_companionRight) // if (SDSPStream* right = stream.xc_companionRight)
right->UpdateStreamVolume(vol); // right->UpdateStreamVolume(vol);
} }
void SilenceStream() { void SilenceStream() {
@ -330,7 +330,7 @@ struct SDSPStream : boo::IAudioVoiceCallback {
return; return;
} }
constexpr std::array<float, 8> coefs{}; constexpr std::array<float, 8> coefs{};
m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true); //m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true);
xe8_silent = true; xe8_silent = true;
x0_active = false; x0_active = false;
} }
@ -350,7 +350,7 @@ struct SDSPStream : boo::IAudioVoiceCallback {
void StopStream() { void StopStream() {
x0_active = false; x0_active = false;
m_booVoice->stop(); //m_booVoice->stop();
m_file = std::nullopt; m_file = std::nullopt;
} }
@ -427,8 +427,8 @@ struct SDSPStream : boo::IAudioVoiceCallback {
m_prev1 = 0; m_prev1 = 0;
m_prev2 = 0; m_prev2 = 0;
memset(xd4_ringBuffer.get(), 0, 0x11DC0); memset(xd4_ringBuffer.get(), 0, 0x11DC0);
m_booVoice->resetSampleRate(info.x4_sampleRate); //m_booVoice->resetSampleRate(info.x4_sampleRate);
m_booVoice->start(); //m_booVoice->start();
UpdateStreamVolume(vol); UpdateStreamVolume(vol);
} }

View File

@ -9,7 +9,7 @@
#include "Runtime/ConsoleVariables/FileStoreManager.hpp" #include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include "Runtime/ConsoleVariables/CVarManager.hpp" #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include "Runtime/CInfiniteLoopDetector.hpp" #include "Runtime/CInfiniteLoopDetector.hpp"
#include "amuse/BooBackend.hpp" //#include "amuse/BooBackend.hpp"
#include "logvisor/logvisor.hpp" #include "logvisor/logvisor.hpp"
@ -160,8 +160,8 @@ private:
std::string m_deferredProject; std::string m_deferredProject;
bool m_projectInitialized = false; bool m_projectInitialized = false;
std::optional<amuse::BooBackendVoiceAllocator> m_amuseAllocWrapper; //std::optional<amuse::BooBackendVoiceAllocator> m_amuseAllocWrapper;
std::unique_ptr<boo::IAudioVoiceEngine> m_voiceEngine; //std::unique_ptr<boo::IAudioVoiceEngine> m_voiceEngine;
Limiter m_limiter{}; Limiter m_limiter{};
@ -190,9 +190,9 @@ public:
VISetWindowTitle( VISetWindowTitle(
fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend_name(info.backend)).c_str()); fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend_name(info.backend)).c_str());
m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce"); // m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce");
m_voiceEngine->setVolume(0.7f); // m_voiceEngine->setVolume(0.7f);
m_amuseAllocWrapper.emplace(*m_voiceEngine); // m_amuseAllocWrapper.emplace(*m_voiceEngine);
#if TARGET_OS_IOS || TARGET_OS_TV #if TARGET_OS_IOS || TARGET_OS_TV
m_deferredProject = std::string{m_fileMgr.getStoreRoot()} + "game.iso"; m_deferredProject = std::string{m_fileMgr.getStoreRoot()} + "game.iso";
@ -202,12 +202,13 @@ public:
std::string arg = m_argv[i]; std::string arg = m_argv[i];
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+') && CBasics::IsDir(arg.c_str())) if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+') && CBasics::IsDir(arg.c_str()))
m_deferredProject = arg; m_deferredProject = arg;
else if (arg == "--no-sound") else if (arg == "--no-sound") {
m_voiceEngine->setVolume(0.f); // m_voiceEngine->setVolume(0.f);
}
} }
#endif #endif
m_voiceEngine->startPump(); //m_voiceEngine->startPump();
} }
void initialize() { void initialize() {
@ -292,7 +293,7 @@ public:
if (!g_mainMP1 && m_projectInitialized) { if (!g_mainMP1 && m_projectInitialized) {
g_mainMP1.emplace(nullptr, nullptr); g_mainMP1.emplace(nullptr, nullptr);
auto result = auto result =
g_mainMP1->Init(m_argc, m_argv, m_fileMgr, &m_cvarManager, m_voiceEngine.get(), *m_amuseAllocWrapper); g_mainMP1->Init(m_argc, m_argv, m_fileMgr, &m_cvarManager);
if (!result.empty()) { if (!result.empty()) {
Log.report(logvisor::Error, FMT_STRING("{}"), result); Log.report(logvisor::Error, FMT_STRING("{}"), result);
m_imGuiConsole.m_errorString = result; m_imGuiConsole.m_errorString = result;
@ -310,15 +311,15 @@ public:
m_imGuiConsole.PreUpdate(); m_imGuiConsole.PreUpdate();
if (g_mainMP1) { if (g_mainMP1) {
if (m_voiceEngine) { // if (m_voiceEngine) {
m_voiceEngine->lockPump(); // m_voiceEngine->lockPump();
} // }
if (g_mainMP1->Proc(dt)) { if (g_mainMP1->Proc(dt)) {
return false; return false;
} }
if (m_voiceEngine) { // if (m_voiceEngine) {
m_voiceEngine->unlockPump(); // m_voiceEngine->unlockPump();
} // }
} }
m_imGuiConsole.PostUpdate(); m_imGuiConsole.PostUpdate();
if (!g_mainMP1 && m_imGuiConsole.m_gameDiscSelected) { if (!g_mainMP1 && m_imGuiConsole.m_gameDiscSelected) {
@ -350,9 +351,9 @@ public:
void onAppPostDraw() noexcept { void onAppPostDraw() noexcept {
OPTICK_EVENT("PostDraw"); OPTICK_EVENT("PostDraw");
if (m_voiceEngine) { // if (m_voiceEngine) {
m_voiceEngine->pumpAndMixVoices(); // m_voiceEngine->pumpAndMixVoices();
} // }
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
CDvdFile::DoWork(); CDvdFile::DoWork();
#endif #endif
@ -372,17 +373,17 @@ public:
void onAppExiting() noexcept { void onAppExiting() noexcept {
m_imGuiConsole.Shutdown(); m_imGuiConsole.Shutdown();
if (m_voiceEngine) { // if (m_voiceEngine) {
m_voiceEngine->unlockPump(); // m_voiceEngine->unlockPump();
m_voiceEngine->stopPump(); // m_voiceEngine->stopPump();
} // }
if (g_mainMP1) { if (g_mainMP1) {
g_mainMP1->Shutdown(); g_mainMP1->Shutdown();
} }
g_mainMP1.reset(); g_mainMP1.reset();
m_cvarManager.serialize(); m_cvarManager.serialize();
m_amuseAllocWrapper.reset(); // m_amuseAllocWrapper.reset();
m_voiceEngine.reset(); // m_voiceEngine.reset();
CDvdFile::Shutdown(); CDvdFile::Shutdown();
} }

View File

@ -153,9 +153,8 @@ set(DISCORD_RPC_LIBRARY "")
if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS) if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS)
set(DISCORD_RPC_LIBRARY "discord-rpc") set(DISCORD_RPC_LIBRARY "discord-rpc")
endif() endif()
set(RUNTIME_LIBRARIES amuse zeus nod NESEmulator libjpeg-turbo jbus kabufuda logvisor OptickCore set(RUNTIME_LIBRARIES zeus nod NESEmulator libjpeg-turbo jbus kabufuda logvisor OptickCore
imgui_support aurora::aurora imgui_support aurora::aurora
boo # TODO move audiodev
${DISCORD_RPC_LIBRARY} ${DISCORD_RPC_LIBRARY}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
) )

View File

@ -7,7 +7,7 @@
#include "Graphics/CGX.hpp" #include "Graphics/CGX.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include <amuse/DSPCodec.hpp> //#include <amuse/DSPCodec.hpp>
#include <turbojpeg.h> #include <turbojpeg.h>
namespace metaforce { namespace metaforce {
@ -212,34 +212,34 @@ void CMoviePlayer::THPAudioFrameHeader::swapBig() {
/* Slightly modified from THPAudioDecode present in SDK; always interleaves */ /* Slightly modified from THPAudioDecode present in SDK; always interleaves */
u32 CMoviePlayer::THPAudioDecode(s16* buffer, const u8* audioFrame, bool stereo) { u32 CMoviePlayer::THPAudioDecode(s16* buffer, const u8* audioFrame, bool stereo) {
THPAudioFrameHeader header = *((const THPAudioFrameHeader*)audioFrame); THPAudioFrameHeader header = *((const THPAudioFrameHeader*)audioFrame);
header.swapBig(); // header.swapBig();
audioFrame += sizeof(THPAudioFrameHeader); // audioFrame += sizeof(THPAudioFrameHeader);
//
if (stereo) { // if (stereo) {
for (int i = 0; i < 2; ++i) { // for (int i = 0; i < 2; ++i) {
unsigned samples = header.numSamples; // unsigned samples = header.numSamples;
s16* bufferCur = buffer + i; // s16* bufferCur = buffer + i;
int16_t prev1 = header.channelPrevs[i][0]; // int16_t prev1 = header.channelPrevs[i][0];
int16_t prev2 = header.channelPrevs[i][1]; // int16_t prev2 = header.channelPrevs[i][1];
for (u32 f = 0; f < (header.numSamples + 13) / 14; ++f) { // for (u32 f = 0; f < (header.numSamples + 13) / 14; ++f) {
DSPDecompressFrameStereoStride(bufferCur, audioFrame, header.channelCoefs[i], &prev1, &prev2, samples); // DSPDecompressFrameStereoStride(bufferCur, audioFrame, header.channelCoefs[i], &prev1, &prev2, samples);
samples -= 14; // samples -= 14;
bufferCur += 28; // bufferCur += 28;
audioFrame += 8; // audioFrame += 8;
} // }
} // }
} else { // } else {
unsigned samples = header.numSamples; // unsigned samples = header.numSamples;
s16* bufferCur = buffer; // s16* bufferCur = buffer;
int16_t prev1 = header.channelPrevs[0][0]; // int16_t prev1 = header.channelPrevs[0][0];
int16_t prev2 = header.channelPrevs[0][1]; // int16_t prev2 = header.channelPrevs[0][1];
for (u32 f = 0; f < (header.numSamples + 13) / 14; ++f) { // for (u32 f = 0; f < (header.numSamples + 13) / 14; ++f) {
DSPDecompressFrameStereoDupe(bufferCur, audioFrame, header.channelCoefs[0], &prev1, &prev2, samples); // DSPDecompressFrameStereoDupe(bufferCur, audioFrame, header.channelCoefs[0], &prev1, &prev2, samples);
samples -= 14; // samples -= 14;
bufferCur += 28; // bufferCur += 28;
audioFrame += 8; // audioFrame += 8;
} // }
} // }
return header.numSamples; return header.numSamples;
} }
@ -358,99 +358,99 @@ void CMoviePlayer::SetSfxVolume(u8 volume) { SfxVolume = std::min(volume, u8(127
void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples) { void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples) {
/* No audio frames ready */ /* No audio frames ready */
if (xd4_audioSlot == UINT32_MAX) { // if (xd4_audioSlot == UINT32_MAX) {
if (in) // if (in)
memmove(out, in, samples * 4); // memmove(out, in, samples * 4);
else // else
memset(out, 0, samples * 4); // memset(out, 0, samples * 4);
return; // return;
} // }
//
while (samples) { // while (samples) {
CTHPTextureSet* tex = &x80_textures[xd4_audioSlot]; // CTHPTextureSet* tex = &x80_textures[xd4_audioSlot];
u32 thisSamples = std::min(tex->audioSamples - tex->playedSamples, samples); // u32 thisSamples = std::min(tex->audioSamples - tex->playedSamples, samples);
if (!thisSamples) { // if (!thisSamples) {
/* Advance frame */ // /* Advance frame */
++xd4_audioSlot; // ++xd4_audioSlot;
if (xd4_audioSlot >= x80_textures.size()) // if (xd4_audioSlot >= x80_textures.size())
xd4_audioSlot = 0; // xd4_audioSlot = 0;
tex = &x80_textures[xd4_audioSlot]; // tex = &x80_textures[xd4_audioSlot];
thisSamples = std::min(tex->audioSamples - tex->playedSamples, samples); // thisSamples = std::min(tex->audioSamples - tex->playedSamples, samples);
} // }
//
if (thisSamples) { // if (thisSamples) {
/* mix samples with `in` or no mix */ // /* mix samples with `in` or no mix */
if (in) { // if (in) {
for (u32 i = 0; i < thisSamples; ++i, out += 2, in += 2) { // for (u32 i = 0; i < thisSamples; ++i, out += 2, in += 2) {
out[0] = DSPSampClamp(in[0] + s32(tex->audioBuf[(i + tex->playedSamples) * 2]) * 0x50F4 / 0x8000 * SfxVolume); // out[0] = DSPSampClamp(in[0] + s32(tex->audioBuf[(i + tex->playedSamples) * 2]) * 0x50F4 / 0x8000 * SfxVolume);
out[1] = // out[1] =
DSPSampClamp(in[1] + s32(tex->audioBuf[(i + tex->playedSamples) * 2 + 1]) * 0x50F4 / 0x8000 * SfxVolume); // DSPSampClamp(in[1] + s32(tex->audioBuf[(i + tex->playedSamples) * 2 + 1]) * 0x50F4 / 0x8000 * SfxVolume);
} // }
} else { // } else {
for (u32 i = 0; i < thisSamples; ++i, out += 2) { // for (u32 i = 0; i < thisSamples; ++i, out += 2) {
out[0] = DSPSampClamp(s32(tex->audioBuf[(i + tex->playedSamples) * 2]) * 0x50F4 / 0x8000 * SfxVolume); // out[0] = DSPSampClamp(s32(tex->audioBuf[(i + tex->playedSamples) * 2]) * 0x50F4 / 0x8000 * SfxVolume);
out[1] = DSPSampClamp(s32(tex->audioBuf[(i + tex->playedSamples) * 2 + 1]) * 0x50F4 / 0x8000 * SfxVolume); // out[1] = DSPSampClamp(s32(tex->audioBuf[(i + tex->playedSamples) * 2 + 1]) * 0x50F4 / 0x8000 * SfxVolume);
} // }
} // }
tex->playedSamples += thisSamples; // tex->playedSamples += thisSamples;
samples -= thisSamples; // samples -= thisSamples;
} else { // } else {
/* metaforce addition: failsafe for buffer overrun */ // /* metaforce addition: failsafe for buffer overrun */
if (in) // if (in)
memmove(out, in, samples * 4); // memmove(out, in, samples * 4);
else // else
memset(out, 0, samples * 4); // memset(out, 0, samples * 4);
// fprintf(stderr, "dropped %d samples\n", samples); // // fprintf(stderr, "dropped %d samples\n", samples);
return; // return;
} // }
} // }
} }
void CMoviePlayer::MixStaticAudio(s16* out, const s16* in, u32 samples) { void CMoviePlayer::MixStaticAudio(s16* out, const s16* in, u32 samples) {
if (!StaticAudio) // if (!StaticAudio)
return; // return;
while (samples) { // while (samples) {
u32 thisSamples = std::min(StaticLoopEnd - StaticAudioOffset, samples); // u32 thisSamples = std::min(StaticLoopEnd - StaticAudioOffset, samples);
const u8* thisOffsetLeft = &StaticAudio[StaticAudioOffset / 2]; // const u8* thisOffsetLeft = &StaticAudio[StaticAudioOffset / 2];
const u8* thisOffsetRight = &StaticAudio[StaticAudioSize / 2 + StaticAudioOffset / 2]; // const u8* thisOffsetRight = &StaticAudio[StaticAudioSize / 2 + StaticAudioOffset / 2];
//
/* metaforce addition: mix samples with `in` or no mix */ // /* metaforce addition: mix samples with `in` or no mix */
if (in) { // if (in) {
for (u32 i = 0; i < thisSamples; i += 2) { // for (u32 i = 0; i < thisSamples; i += 2) {
out[0] = DSPSampClamp( // out[0] = DSPSampClamp(
in[0] + s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)); // in[0] + s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
out[1] = DSPSampClamp( // out[1] = DSPSampClamp(
in[1] + s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)); // in[1] + s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
out[2] = DSPSampClamp( // out[2] = DSPSampClamp(
in[2] + s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)); // in[2] + s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
out[3] = DSPSampClamp( // out[3] = DSPSampClamp(
in[3] + s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)); // in[3] + s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
thisOffsetLeft += 1; // thisOffsetLeft += 1;
thisOffsetRight += 1; // thisOffsetRight += 1;
out += 4; // out += 4;
in += 4; // in += 4;
} // }
} else { // } else {
for (u32 i = 0; i < thisSamples; i += 2) { // for (u32 i = 0; i < thisSamples; i += 2) {
out[0] = // out[0] =
DSPSampClamp(s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)); // DSPSampClamp(s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
out[1] = // out[1] =
DSPSampClamp(s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)); // DSPSampClamp(s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
out[2] = DSPSampClamp( // out[2] = DSPSampClamp(
s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)); // s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
out[3] = DSPSampClamp( // out[3] = DSPSampClamp(
s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)); // s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
thisOffsetLeft += 1; // thisOffsetLeft += 1;
thisOffsetRight += 1; // thisOffsetRight += 1;
out += 4; // out += 4;
} // }
} // }
//
StaticAudioOffset += thisSamples; // StaticAudioOffset += thisSamples;
if (StaticAudioOffset == StaticLoopEnd) // if (StaticAudioOffset == StaticLoopEnd)
StaticAudioOffset = StaticLoopBegin; // StaticAudioOffset = StaticLoopBegin;
samples -= thisSamples; // samples -= thisSamples;
} // }
} }
void CMoviePlayer::Rewind() { void CMoviePlayer::Rewind() {

View File

@ -4,8 +4,8 @@
#include "Runtime/CMainFlowBase.hpp" #include "Runtime/CMainFlowBase.hpp"
#include "Runtime/ConsoleVariables/FileStoreManager.hpp" #include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include <amuse/amuse.hpp> //#include <amuse/amuse.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp> //#include <boo/audiodev/IAudioVoiceEngine.hpp>
namespace metaforce { namespace metaforce {
class Console; class Console;
@ -37,8 +37,7 @@ enum class EGameplayResult { None, Win, Lose, Playing };
class IMain { class IMain {
public: public:
virtual ~IMain() = default; virtual ~IMain() = default;
virtual std::string Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarMgr, virtual std::string Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarMgr) = 0;
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) = 0;
virtual void Draw() = 0; virtual void Draw() = 0;
virtual bool Proc(float dt) = 0; virtual bool Proc(float dt) = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;

View File

@ -2,6 +2,7 @@
#include <set> #include <set>
#include <string_view> #include <string_view>
#include <deque>
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CActor.hpp" #include "Runtime/World/CActor.hpp"

View File

@ -163,6 +163,8 @@
#include "imgui.h" #include "imgui.h"
#include "magic_enum.hpp" #include "magic_enum.hpp"
#include <cinttypes>
#define IMGUI_ENTITY_INSPECT(CLS, PARENT, NAME, ...) \ #define IMGUI_ENTITY_INSPECT(CLS, PARENT, NAME, ...) \
std::string_view CLS::ImGuiType() { return #NAME; } \ std::string_view CLS::ImGuiType() { return #NAME; } \
void CLS::ImGuiInspect() { \ void CLS::ImGuiInspect() { \

View File

@ -109,20 +109,20 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
} }
case 1: { case 1: {
if (!x28_) { if (!x28_) {
x28_ = std::make_unique<CMoviePlayer>("Video/creditBG.thp", 0.f, true, true); //x28_ = std::make_unique<CMoviePlayer>("Video/creditBG.thp", 0.f, true, true);
} }
x14_ = 2; x14_ = 2;
break; break;
} }
case 2: { case 2: {
if (!x2c_) { if (!x2c_) {
x2c_ = std::make_unique<CStaticAudioPlayer>("Audio/ending3.rsf", 0, 0x5d7c00); //x2c_ = std::make_unique<CStaticAudioPlayer>("Audio/ending3.rsf", 0, 0x5d7c00);
} }
if (!x2c_->IsReady()) { if (!x2c_->IsReady()) {
return EMessageReturn::Exit; return EMessageReturn::Exit;
} }
x2c_->SetVolume(1.f); x2c_->SetVolume(1.f);
x2c_->StartMixing(); //x2c_->StartMixing();
x14_ = 3; x14_ = 3;
} }
[[fallthrough]]; [[fallthrough]];

View File

@ -1643,12 +1643,12 @@ CFrontEndUI::CFrontEndUI() : CIOWin("FrontEndUI") {
CFrontEndUI::~CFrontEndUI() { CFrontEndUI::~CFrontEndUI() {
if (x14_phase >= EPhase::DisplayFrontEnd) { if (x14_phase >= EPhase::DisplayFrontEnd) {
CAudioSys::RemoveAudioGroup(x44_frontendAudioGrp->GetAudioGroupData()); //CAudioSys::RemoveAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
} }
} }
void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue) { void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue) {
xf4_curAudio->StopMixing(); //xf4_curAudio->StopMixing();
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CSlideShow>())); queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CSlideShow>()));
} }
@ -1771,9 +1771,9 @@ void CFrontEndUI::CompleteStateTransition() {
case EScreen::FileSelect: case EScreen::FileSelect:
SetCurrentMovie(EMenuMovie::FileSelectLoop); SetCurrentMovie(EMenuMovie::FileSelectLoop);
if (oldScreen == EScreen::Title) { if (oldScreen == EScreen::Title) {
xf4_curAudio->StopMixing(); //xf4_curAudio->StopMixing();
xf4_curAudio = xd8_audio2.get(); //xf4_curAudio = xd8_audio2.get();
xf4_curAudio->StartMixing(); //xf4_curAudio->StartMixing();
} }
if (xdc_saveUI) if (xdc_saveUI)
xdc_saveUI->ResetCardDriver(); xdc_saveUI->ResetCardDriver();
@ -2046,7 +2046,7 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue&
StartStateTransition(EScreen::FileSelect); StartStateTransition(EScreen::FileSelect);
return; return;
case SFusionBonusFrame::EAction::PlayNESMetroid: case SFusionBonusFrame::EAction::PlayNESMetroid:
xf4_curAudio->StopMixing(); //xf4_curAudio->StopMixing();
xec_emuFrme = std::make_unique<SNesEmulatorFrame>(); xec_emuFrme = std::make_unique<SNesEmulatorFrame>();
if (xdc_saveUI) if (xdc_saveUI)
xdc_saveUI->SetInGame(true); xdc_saveUI->SetInGame(true);
@ -2119,9 +2119,9 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
} }
xe8_frontendNoCardFrme = std::make_unique<SFrontEndFrame>(x1c_rndB); xe8_frontendNoCardFrme = std::make_unique<SFrontEndFrame>(x1c_rndB);
x38_pressStart.GetObj(); x38_pressStart.GetObj();
CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData()); //CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664); // xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664);
xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980); // xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980);
x14_phase = EPhase::LoadFrames; x14_phase = EPhase::LoadFrames;
} }
if (x14_phase == EPhase::LoadDeps) if (x14_phase == EPhase::LoadDeps)
@ -2136,8 +2136,8 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
if (!xd4_audio1->IsReady() || !xd8_audio2->IsReady() || !xe0_frontendCardFrme->PumpLoad() || if (!xd4_audio1->IsReady() || !xd8_audio2->IsReady() || !xe0_frontendCardFrme->PumpLoad() ||
!xe8_frontendNoCardFrme->PumpLoad() || !xdc_saveUI->PumpLoad()) !xe8_frontendNoCardFrme->PumpLoad() || !xdc_saveUI->PumpLoad())
return EMessageReturn::Exit; return EMessageReturn::Exit;
xf4_curAudio = xd4_audio1.get(); // xf4_curAudio = xd4_audio1.get();
xf4_curAudio->StartMixing(); // xf4_curAudio->StartMixing();
x14_phase = EPhase::LoadMovies; x14_phase = EPhase::LoadMovies;
[[fallthrough]]; [[fallthrough]];
@ -2178,7 +2178,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
xec_emuFrme.reset(); xec_emuFrme.reset();
if (xdc_saveUI) if (xdc_saveUI)
xdc_saveUI->SetInGame(false); xdc_saveUI->SetInGame(false);
xf4_curAudio->StartMixing(); //xf4_curAudio->StartMixing();
} }
break; break;
} }
@ -2186,7 +2186,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
if (xd2_deferSlideShow) { if (xd2_deferSlideShow) {
/* Start mixing slideshow music */ /* Start mixing slideshow music */
xd2_deferSlideShow = false; xd2_deferSlideShow = false;
xf4_curAudio->StartMixing(); //xf4_curAudio->StartMixing();
if (xdc_saveUI) if (xdc_saveUI)
xdc_saveUI->ResetCardDriver(); xdc_saveUI->ResetCardDriver();
} }

View File

@ -90,10 +90,9 @@ constexpr std::array<AudioGroupInfo, 5> StaticAudioGroups{{
}}; }};
} // Anonymous namespace } // Anonymous namespace
CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent)
amuse::IBackendVoiceAllocator& backend)
: m_parent(parent) : m_parent(parent)
, x0_audioSys(voiceEngine, backend, 0, 0, 0, 0, 0) , x0_audioSys(0, 0, 0, 0, 0)
, x30_inputGenerator(/*osCtx, */ g_tweakPlayer->GetLeftLogicalThreshold(), g_tweakPlayer->GetRightLogicalThreshold()) , x30_inputGenerator(/*osCtx, */ g_tweakPlayer->GetLeftLogicalThreshold(), g_tweakPlayer->GetRightLogicalThreshold())
, x44_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) { , x44_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) {
auto* m = static_cast<CMain*>(g_Main); auto* m = static_cast<CMain*>(g_Main);
@ -506,8 +505,7 @@ void CMain::HandleDiscordErrored(int errorCode, const char* message) {
DiscordLog.report(logvisor::Error, FMT_STRING("Discord Error: {}"), message); DiscordLog.report(logvisor::Error, FMT_STRING("Discord Error: {}"), message);
} }
std::string CMain::Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarMgr, std::string CMain::Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarMgr) {
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) {
m_cvarMgr = cvarMgr; m_cvarMgr = cvarMgr;
{ {
@ -642,7 +640,7 @@ std::string CMain::Init(int argc, char** argv, const FileStoreManager& storeMgr,
} }
FillInAssetIDs(); FillInAssetIDs();
x164_archSupport = std::make_unique<CGameArchitectureSupport>(*this, voiceEngine, backend); x164_archSupport = std::make_unique<CGameArchitectureSupport>(*this);
g_archSupport = x164_archSupport.get(); g_archSupport = x164_archSupport.get();
x164_archSupport->PreloadAudio(); x164_archSupport->PreloadAudio();
std::srand(static_cast<u32>(CBasics::GetTime())); std::srand(static_cast<u32>(CBasics::GetTime()));

View File

@ -128,7 +128,7 @@ class CGameArchitectureSupport {
void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); } void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); }
public: public:
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend); CGameArchitectureSupport(CMain& parent);
~CGameArchitectureSupport(); ~CGameArchitectureSupport();
void PreloadAudio(); void PreloadAudio();
@ -213,8 +213,7 @@ public:
// int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& // int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator&
// backend); // backend);
std::string Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarManager, std::string Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarManager) override;
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override;
bool Proc(float dt) override; bool Proc(float dt) override;
void Draw() override; void Draw() override;
void Shutdown() override; void Shutdown() override;

View File

@ -16,6 +16,8 @@
#include "Runtime/World/IGameArea.hpp" #include "Runtime/World/IGameArea.hpp"
#include "Runtime/Character/CModelData.hpp" #include "Runtime/Character/CModelData.hpp"
#include <list>
#include <zeus/CAABox.hpp> #include <zeus/CAABox.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CTransform.hpp> #include <zeus/CTransform.hpp>

View File

@ -18,16 +18,17 @@ CScriptRoomAcoustics::CScriptRoomAcoustics(TUniqueId uid, std::string_view name,
u32 feedbackS, u32 outputL, u32 outputR, u32 outputS) u32 feedbackS, u32 outputL, u32 outputR, u32 outputS)
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
, x34_volumeScale(volScale) , x34_volumeScale(volScale)
, x38_revHi(revHi) //, x38_revHi(revHi)
, x39_revHiDis(revHiDis) //, x39_revHiDis(revHiDis)
, x3c_revHiInfo(revHiColoration, revHiMix, revHiTime, revHiDamping, revHiPreDelay, revHiCrosstalk) //, x3c_revHiInfo(revHiColoration, revHiMix, revHiTime, revHiDamping, revHiPreDelay, revHiCrosstalk)
, x54_chorus(chorus) //, x54_chorus(chorus)
, x58_chorusInfo(baseDelay, variation, period) //, x58_chorusInfo(baseDelay, variation, period)
, x64_revStd(revStd) //, x64_revStd(revStd)
, x65_revStdDis(revStdDis) //, x65_revStdDis(revStdDis)
, x68_revStdInfo(revStdColoration, revStdMix, revStdTime, revStdDamping, revStdPreDelay) //, x68_revStdInfo(revStdColoration, revStdMix, revStdTime, revStdDamping, revStdPreDelay)
, x7c_delay(delay) //, x7c_delay(delay)
, x80_delayInfo(delayL, delayR, delayS, feedbackL, feedbackR, feedbackS, outputL, outputR, outputS) {} //, x80_delayInfo(delayL, delayR, delayS, feedbackL, feedbackR, feedbackS, outputL, outputR, outputS)
{}
void CScriptRoomAcoustics::DisableAuxCallbacks() { void CScriptRoomAcoustics::DisableAuxCallbacks() {
CSfxManager::DisableAuxProcessing(); CSfxManager::DisableAuxProcessing();
@ -41,17 +42,17 @@ void CScriptRoomAcoustics::EnableAuxCallbacks() {
} }
bool applied = true; bool applied = true;
if (x38_revHi) { // if (x38_revHi) {
CSfxManager::PrepareReverbHiCallback(x3c_revHiInfo); // CSfxManager::PrepareReverbHiCallback(x3c_revHiInfo);
} else if (x54_chorus) { // } else if (x54_chorus) {
CSfxManager::PrepareChorusCallback(x58_chorusInfo); // CSfxManager::PrepareChorusCallback(x58_chorusInfo);
} else if (x64_revStd) { // } else if (x64_revStd) {
CSfxManager::PrepareReverbStdCallback(x68_revStdInfo); // CSfxManager::PrepareReverbStdCallback(x68_revStdInfo);
} else if (x7c_delay) { // } else if (x7c_delay) {
CSfxManager::PrepareDelayCallback(x80_delayInfo); // CSfxManager::PrepareDelayCallback(x80_delayInfo);
} else { // } else {
applied = false; // applied = false;
} // }
if (applied) { if (applied) {
CAudioSys::SetVolumeScale(x34_volumeScale); CAudioSys::SetVolumeScale(x34_volumeScale);

View File

@ -5,26 +5,26 @@
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CEntity.hpp" #include "Runtime/World/CEntity.hpp"
#include <amuse/EffectChorus.hpp> //#include <amuse/EffectChorus.hpp>
#include <amuse/EffectDelay.hpp> //#include <amuse/EffectDelay.hpp>
#include <amuse/EffectReverb.hpp> //#include <amuse/EffectReverb.hpp>
namespace metaforce { namespace metaforce {
class CScriptRoomAcoustics : public CEntity { class CScriptRoomAcoustics : public CEntity {
u32 x34_volumeScale; u32 x34_volumeScale;
bool x38_revHi, x39_revHiDis; // bool x38_revHi, x39_revHiDis;
amuse::EffectReverbHiInfo x3c_revHiInfo; // amuse::EffectReverbHiInfo x3c_revHiInfo;
//
bool x54_chorus; // bool x54_chorus;
amuse::EffectChorusInfo x58_chorusInfo; // amuse::EffectChorusInfo x58_chorusInfo;
//
bool x64_revStd, x65_revStdDis; // bool x64_revStd, x65_revStdDis;
amuse::EffectReverbStdInfo x68_revStdInfo; // amuse::EffectReverbStdInfo x68_revStdInfo;
//
bool x7c_delay; // bool x7c_delay;
amuse::EffectDelayInfo x80_delayInfo; // amuse::EffectDelayInfo x80_delayInfo;
public: public:
DEFINE_ENTITY DEFINE_ENTITY

View File

@ -25,7 +25,7 @@ CScriptSound::CScriptSound(TUniqueId uid, std::string_view name, const CEntityIn
, x10e_vol(vol / 127.f) , x10e_vol(vol / 127.f)
, x110_(w3) , x110_(w3)
, x112_prio(s16(prio)) , x112_prio(s16(prio))
, x114_pan(amuse::convertMusyXPanToAmusePan(pan)) //, x114_pan(amuse::convertMusyXPanToAmusePan(pan))
, x116_(w6) , x116_(w6)
, x118_pitch(pitch / 8192.f) , x118_pitch(pitch / 8192.f)
, x11c_25_looped(looped) , x11c_25_looped(looped)

View File

@ -320,7 +320,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
} }
case ESpecialFunction::EndGame: { case ESpecialFunction::EndGame: {
if (msg == EScriptObjectMessage::Action) { if (msg == EScriptObjectMessage::Action) {
switch (GetSpecialEnding(mgr)) { switch (ClassifyEnding(mgr)) {
case 0: case 0:
g_Main->SetFlowState(EClientFlowStates::WinBad); g_Main->SetFlowState(EClientFlowStates::WinBad);
break; break;
@ -492,7 +492,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
break; break;
} }
case ESpecialFunction::Ending: { case ESpecialFunction::Ending: {
if (msg == EScriptObjectMessage::Action && GetSpecialEnding(mgr) == u32(xfc_float1)) { if (msg == EScriptObjectMessage::Action && ClassifyEnding(mgr) == u32(xfc_float1)) {
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None); SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
} }
break; break;
@ -1006,7 +1006,7 @@ void CScriptSpecialFunction::DeleteEmitter(CSfxHandle& handle) {
handle = CSfxHandle(); handle = CSfxHandle();
} }
u32 CScriptSpecialFunction::GetSpecialEnding(const CStateManager& mgr) const { u32 CScriptSpecialFunction::ClassifyEnding(const CStateManager& mgr) const {
const int rate = (mgr.GetPlayerState()->CalculateItemCollectionRate() * 100) / mgr.GetPlayerState()->GetPickupTotal(); const int rate = (mgr.GetPlayerState()->CalculateItemCollectionRate() * 100) / mgr.GetPlayerState()->GetPickupTotal();
int result; int result;
if (rate < 75) { if (rate < 75) {

View File

@ -147,7 +147,7 @@ public:
bool ShouldSkipCinematic(CStateManager& stateMgr) const; bool ShouldSkipCinematic(CStateManager& stateMgr) const;
void DeleteEmitter(CSfxHandle& handle); void DeleteEmitter(CSfxHandle& handle);
u32 GetSpecialEnding(const CStateManager&) const; u32 ClassifyEnding(const CStateManager& mgr) const;
void AddOrUpdateEmitter(float pitch, CSfxHandle& handle, u16 id, const zeus::CVector3f& pos, float vol); void AddOrUpdateEmitter(float pitch, CSfxHandle& handle, u16 id, const zeus::CVector3f& pos, float vol);
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -46,10 +46,7 @@ set(AURORA_NATIVE_MATRIX ON CACHE BOOL "Assume OpenGL-layout matrices, disables
add_subdirectory(aurora) add_subdirectory(aurora)
# boo must come after SDL2 # boo must come after SDL2
add_subdirectory(boo EXCLUDE_FROM_ALL)
add_subdirectory(nod EXCLUDE_FROM_ALL) add_subdirectory(nod EXCLUDE_FROM_ALL)
# amuse must come after athena/atdna, boo and nod
add_subdirectory(amuse EXCLUDE_FROM_ALL)
if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS) if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc) set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)

1
extern/amuse vendored

@ -1 +0,0 @@
Subproject commit bc1e04b116b9f0fbaa7c88ad9d781a0e16a818da

2
extern/aurora vendored

@ -1 +1 @@
Subproject commit ca822a7679bd0589ce8243f0138054085e3cabd6 Subproject commit 104f089cd0a89af1cbbaafd789223de38f8e7658