mirror of https://github.com/AxioDL/metaforce.git
Remove amuse, and compile fixes
This commit is contained in:
parent
e9cfa6aff4
commit
137e4c19a3
|
@ -2,10 +2,6 @@
|
|||
path = extern/nod
|
||||
url = ../nod.git
|
||||
branch = master
|
||||
[submodule "extern/amuse"]
|
||||
path = extern/amuse
|
||||
url = ../amuse.git
|
||||
branch = master
|
||||
[submodule "extern/kabufuda"]
|
||||
path = extern/kabufuda
|
||||
url = ../kabufuda.git
|
||||
|
|
|
@ -287,8 +287,8 @@ void CNESEmulator::InitializeEmulator() {
|
|||
|
||||
// double useFreq = 223740;
|
||||
double useFreq = apuGetFrequency();
|
||||
m_booVoice = CAudioSys::GetVoiceEngine()->allocateNewStereoVoice(useFreq, this);
|
||||
m_booVoice->start();
|
||||
//m_booVoice = CAudioSys::GetVoiceEngine()->allocateNewStereoVoice(useFreq, this);
|
||||
//m_booVoice->start();
|
||||
uint32_t apuBufSz = apuGetMaxBufSize();
|
||||
m_audioBufBlock.reset(new u8[apuBufSz * NUM_AUDIO_BUFFERS]);
|
||||
memset(m_audioBufBlock.get(), 0, apuBufSz * NUM_AUDIO_BUFFERS);
|
||||
|
@ -301,8 +301,8 @@ void CNESEmulator::InitializeEmulator() {
|
|||
void CNESEmulator::DeinitializeEmulator() {
|
||||
// printf("\n");
|
||||
emuRenderFrame = false;
|
||||
m_booVoice->stop();
|
||||
m_booVoice.reset();
|
||||
//m_booVoice->stop();
|
||||
//m_booVoice.reset();
|
||||
apuDeinitBufs();
|
||||
if (emuNesROM != NULL) {
|
||||
if (!nesEmuNSFPlayback && (audioExpansion & EXP_FDS)) {
|
||||
|
@ -345,63 +345,63 @@ CNESEmulator::~CNESEmulator() {
|
|||
}
|
||||
|
||||
int CNESEmulator::audioUpdate() {
|
||||
int origProcBufs = m_procBufs;
|
||||
|
||||
uint8_t* data = apuGetBuf();
|
||||
if (data != NULL && m_procBufs) {
|
||||
uint32_t apuBufSz = apuGetMaxBufSize();
|
||||
uint32_t remBytes = apuGetBufSize();
|
||||
while (remBytes != 0) {
|
||||
size_t thisBytes = std::min(remBytes, apuBufSz - m_posInHeadBuf);
|
||||
memmove(m_audioBufs[m_headBuf] + m_posInHeadBuf, data, thisBytes);
|
||||
data += thisBytes;
|
||||
m_posInHeadBuf += thisBytes;
|
||||
if (m_posInHeadBuf == apuBufSz) {
|
||||
m_posInHeadBuf = 0;
|
||||
--m_procBufs;
|
||||
++m_headBuf;
|
||||
if (m_headBuf == NUM_AUDIO_BUFFERS)
|
||||
m_headBuf = 0;
|
||||
// printf("PUSH\n");
|
||||
}
|
||||
remBytes -= thisBytes;
|
||||
}
|
||||
}
|
||||
|
||||
// if (!origProcBufs)
|
||||
// printf("OVERRUN\n");
|
||||
|
||||
return origProcBufs;
|
||||
// int origProcBufs = m_procBufs;
|
||||
//
|
||||
// uint8_t* data = apuGetBuf();
|
||||
// if (data != NULL && m_procBufs) {
|
||||
// uint32_t apuBufSz = apuGetMaxBufSize();
|
||||
// uint32_t remBytes = apuGetBufSize();
|
||||
// while (remBytes != 0) {
|
||||
// size_t thisBytes = std::min(remBytes, apuBufSz - m_posInHeadBuf);
|
||||
// memmove(m_audioBufs[m_headBuf] + m_posInHeadBuf, data, thisBytes);
|
||||
// data += thisBytes;
|
||||
// m_posInHeadBuf += thisBytes;
|
||||
// if (m_posInHeadBuf == apuBufSz) {
|
||||
// m_posInHeadBuf = 0;
|
||||
// --m_procBufs;
|
||||
// ++m_headBuf;
|
||||
// if (m_headBuf == NUM_AUDIO_BUFFERS)
|
||||
// m_headBuf = 0;
|
||||
// // printf("PUSH\n");
|
||||
// }
|
||||
// remBytes -= thisBytes;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // if (!origProcBufs)
|
||||
// // printf("OVERRUN\n");
|
||||
//
|
||||
// return origProcBufs;
|
||||
}
|
||||
|
||||
static constexpr uint32_t AudioFrameSz = 2 * sizeof(int16_t);
|
||||
|
||||
size_t CNESEmulator::supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) {
|
||||
uint32_t remFrames = uint32_t(frames);
|
||||
while (remFrames) {
|
||||
if (m_posInTailBuf == apuGetMaxBufSize()) {
|
||||
++m_tailBuf;
|
||||
if (m_tailBuf == NUM_AUDIO_BUFFERS)
|
||||
m_tailBuf = 0;
|
||||
m_posInTailBuf = 0;
|
||||
++m_procBufs;
|
||||
// printf("POP\n");
|
||||
}
|
||||
|
||||
if (m_procBufs == NUM_AUDIO_BUFFERS) {
|
||||
memset(data, 0, remFrames * AudioFrameSz);
|
||||
// printf("UNDERRUN\n");
|
||||
return frames;
|
||||
}
|
||||
|
||||
size_t copySz = std::min(apuGetMaxBufSize() - m_posInTailBuf, remFrames * AudioFrameSz);
|
||||
memmove(data, m_audioBufs[m_tailBuf] + m_posInTailBuf, copySz);
|
||||
data += copySz / sizeof(int16_t);
|
||||
m_posInTailBuf += copySz;
|
||||
remFrames -= copySz / AudioFrameSz;
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
//size_t CNESEmulator::supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) {
|
||||
// uint32_t remFrames = uint32_t(frames);
|
||||
// while (remFrames) {
|
||||
// if (m_posInTailBuf == apuGetMaxBufSize()) {
|
||||
// ++m_tailBuf;
|
||||
// if (m_tailBuf == NUM_AUDIO_BUFFERS)
|
||||
// m_tailBuf = 0;
|
||||
// m_posInTailBuf = 0;
|
||||
// ++m_procBufs;
|
||||
// // printf("POP\n");
|
||||
// }
|
||||
//
|
||||
// if (m_procBufs == NUM_AUDIO_BUFFERS) {
|
||||
// memset(data, 0, remFrames * AudioFrameSz);
|
||||
// // printf("UNDERRUN\n");
|
||||
// return frames;
|
||||
// }
|
||||
//
|
||||
// size_t copySz = std::min(apuGetMaxBufSize() - m_posInTailBuf, remFrames * AudioFrameSz);
|
||||
// memmove(data, m_audioBufs[m_tailBuf] + m_posInTailBuf, copySz);
|
||||
// data += copySz / sizeof(int16_t);
|
||||
// m_posInTailBuf += copySz;
|
||||
// remFrames -= copySz / AudioFrameSz;
|
||||
// }
|
||||
// return frames;
|
||||
//}
|
||||
|
||||
void CNESEmulator::NesEmuMainLoop(bool forceDraw) {
|
||||
// int start = GetTickCount();
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
//#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "boo/audiodev/IAudioVoice.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
|
@ -15,7 +14,7 @@ namespace MP1 {
|
|||
|
||||
#define NUM_AUDIO_BUFFERS 4
|
||||
|
||||
class CNESEmulator final : public boo::IAudioVoiceCallback {
|
||||
class CNESEmulator final {
|
||||
public:
|
||||
enum class EPasswordEntryState { NotPasswordScreen, NotEntered, Entered };
|
||||
|
||||
|
@ -47,7 +46,7 @@ private:
|
|||
uint32_t m_procBufs = NUM_AUDIO_BUFFERS;
|
||||
uint32_t m_posInHeadBuf = 0;
|
||||
uint32_t m_posInTailBuf = 0;
|
||||
boo::ObjToken<boo::IAudioVoice> m_booVoice;
|
||||
//boo::ObjToken<boo::IAudioVoice> m_booVoice;
|
||||
|
||||
// void* x4_loadBuf;
|
||||
// void* x8_rom;
|
||||
|
@ -82,8 +81,8 @@ public:
|
|||
EPasswordEntryState GetPasswordEntryState() const { return x34_passwordEntryState; }
|
||||
|
||||
int audioUpdate();
|
||||
void preSupplyAudio(boo::IAudioVoice& voice, double dt) {}
|
||||
size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data);
|
||||
//void preSupplyAudio(boo::IAudioVoice& voice, double dt) {}
|
||||
//size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data);
|
||||
};
|
||||
|
||||
} // namespace MP1
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <cstring>
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
/*
|
||||
amuse::AudioGroupData CAudioGroupSet::LoadData() {
|
||||
const auto readU32 = [](const u8* ptr) {
|
||||
uint32_t value;
|
||||
|
@ -30,8 +30,8 @@ amuse::AudioGroupData CAudioGroupSet::LoadData() {
|
|||
|
||||
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,
|
||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Runtime/IObj.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <amuse/AudioGroupData.hpp>
|
||||
//#include <amuse/AudioGroupData.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
|
@ -17,12 +17,12 @@ class CAudioGroupSet {
|
|||
std::unique_ptr<u8[]> m_buffer;
|
||||
std::string x10_baseName;
|
||||
std::string x20_name;
|
||||
amuse::AudioGroupData m_data;
|
||||
amuse::AudioGroupData LoadData();
|
||||
// amuse::AudioGroupData m_data;
|
||||
// amuse::AudioGroupData LoadData();
|
||||
|
||||
public:
|
||||
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; }
|
||||
};
|
||||
|
||||
|
|
|
@ -69,16 +69,12 @@ void CAudioSys::SysUnloadAudioGroupSet(std::string_view name) {
|
|||
bool CAudioSys::SysIsGroupSetLoaded(std::string_view name) { return FindGroupSet(name).operator bool(); }
|
||||
|
||||
void CAudioSys::SysAddGroupIntoAmuse(std::string_view name) {
|
||||
if (auto set = FindGroupSet(name))
|
||||
AddAudioGroup(set->GetAudioGroupData());
|
||||
}
|
||||
|
||||
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) {
|
||||
s_MasterVol = volume / 127.f;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "Runtime/GCNTypes.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <amuse/amuse.hpp>
|
||||
#include <boo/audiodev/IAudioVoiceEngine.hpp>
|
||||
//#include <amuse/amuse.hpp>
|
||||
//#include <boo/audiodev/IAudioVoiceEngine.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
|
@ -21,8 +21,6 @@ public:
|
|||
|
||||
private:
|
||||
static CAudioSys* g_SharedSys;
|
||||
boo::IAudioVoiceEngine* m_voiceEngine;
|
||||
amuse::Engine m_engine;
|
||||
static void _UpdateVolume();
|
||||
|
||||
public:
|
||||
|
@ -38,16 +36,11 @@ public:
|
|||
bool x28_important; // Can't be allocated over, regardless of priority
|
||||
u8 x29_prio;
|
||||
};
|
||||
CAudioSys(boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend, u8, u8, u8, u8, u32)
|
||||
: m_voiceEngine(voiceEngine), m_engine(backend) {
|
||||
CAudioSys(u8, u8, u8, u8, u32) {
|
||||
g_SharedSys = this;
|
||||
}
|
||||
~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 TLockedToken<CAudioGroupSet> FindGroupSet(std::string_view name);
|
||||
static std::string_view SysGetGroupSetName(CAssetId id);
|
||||
|
|
|
@ -12,14 +12,14 @@ void CMidiManager::StopAll() {
|
|||
}
|
||||
|
||||
void CMidiManager::Stop(const CMidiHandle& handle, float fadeTime) {
|
||||
handle->GetAudioSysHandle()->stopSong(fadeTime);
|
||||
m_MidiWrappers.erase(handle);
|
||||
// handle->GetAudioSysHandle()->stopSong(fadeTime);
|
||||
// m_MidiWrappers.erase(handle);
|
||||
}
|
||||
|
||||
std::unordered_set<CMidiHandle>::iterator CMidiManager::Stop(std::unordered_set<CMidiHandle>::iterator handle,
|
||||
float fadeTime) {
|
||||
const CMidiHandle& h = *handle;
|
||||
h->GetAudioSysHandle()->stopSong(fadeTime);
|
||||
// const CMidiHandle& h = *handle;
|
||||
// h->GetAudioSysHandle()->stopSong(fadeTime);
|
||||
return m_MidiWrappers.erase(handle);
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,10 @@ CMidiHandle CMidiManager::Play(const CMidiData& data, float fadeTime, bool stopE
|
|||
it = Stop(it, fadeTime);
|
||||
|
||||
CMidiHandle handle = *m_MidiWrappers.insert(std::make_shared<CMidiWrapper>()).first;
|
||||
handle->SetAudioSysHandle(
|
||||
CAudioSys::GetAmuseEngine().seqPlay(data.GetGroupId(), data.GetSetupId(), data.GetArrData()));
|
||||
handle->GetAudioSysHandle()->setVolume(volume, fadeTime);
|
||||
handle->SetSongId(data.GetSetupId());
|
||||
// handle->SetAudioSysHandle(
|
||||
// CAudioSys::GetAmuseEngine().seqPlay(data.GetGroupId(), data.GetSetupId(), data.GetArrData()));
|
||||
// handle->GetAudioSysHandle()->setVolume(volume, fadeTime);
|
||||
// handle->SetSongId(data.GetSetupId());
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,14 +23,14 @@ public:
|
|||
};
|
||||
|
||||
class CMidiWrapper {
|
||||
amuse::ObjToken<amuse::Sequencer> x0_sequencer;
|
||||
//amuse::ObjToken<amuse::Sequencer> x0_sequencer;
|
||||
// CSfxHandle x4_handle;
|
||||
u16 x8_songId;
|
||||
bool xa_available = true;
|
||||
|
||||
public:
|
||||
amuse::ObjToken<amuse::Sequencer> GetAudioSysHandle() const { return x0_sequencer; }
|
||||
void SetAudioSysHandle(amuse::ObjToken<amuse::Sequencer> sequencer) { x0_sequencer = std::move(sequencer); }
|
||||
//amuse::ObjToken<amuse::Sequencer> GetAudioSysHandle() const { return x0_sequencer; }
|
||||
//void SetAudioSysHandle(amuse::ObjToken<amuse::Sequencer> sequencer) { x0_sequencer = std::move(sequencer); }
|
||||
// const CSfxHandle& GetManagerHandle() const { return x4_handle; }
|
||||
// void SetMidiHandle(const CSfxHandle& handle) { x4_handle = handle; }
|
||||
bool IsAvailable() const { return xa_available; }
|
||||
|
|
|
@ -7,15 +7,15 @@ namespace metaforce {
|
|||
static TLockedToken<std::vector<u16>> mpSfxTranslationTableTok;
|
||||
std::vector<u16>* CSfxManager::mpSfxTranslationTable = nullptr;
|
||||
|
||||
static amuse::EffectReverbHiInfo s_ReverbHiQueued;
|
||||
static amuse::EffectChorusInfo s_ChorusQueued;
|
||||
static amuse::EffectReverbStdInfo s_ReverbStdQueued;
|
||||
static amuse::EffectDelayInfo s_DelayQueued;
|
||||
|
||||
static amuse::EffectReverbHi* s_ReverbHiState = nullptr;
|
||||
static amuse::EffectChorus* s_ChorusState = nullptr;
|
||||
static amuse::EffectReverbStd* s_ReverbStdState = nullptr;
|
||||
static amuse::EffectDelay* s_DelayState = nullptr;
|
||||
//static amuse::EffectReverbHiInfo s_ReverbHiQueued;
|
||||
//static amuse::EffectChorusInfo s_ChorusQueued;
|
||||
//static amuse::EffectReverbStdInfo s_ReverbStdQueued;
|
||||
//static amuse::EffectDelayInfo s_DelayQueued;
|
||||
//
|
||||
//static amuse::EffectReverbHi* s_ReverbHiState = nullptr;
|
||||
//static amuse::EffectChorus* s_ChorusState = nullptr;
|
||||
//static amuse::EffectReverbStd* s_ReverbStdState = nullptr;
|
||||
//static amuse::EffectDelay* s_DelayState = nullptr;
|
||||
|
||||
CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||
CObjectReference* selfRef) {
|
||||
|
@ -36,7 +36,7 @@ bool CSfxManager::m_auxProcessingEnabled = false;
|
|||
float CSfxManager::m_reverbAmount = 1.f;
|
||||
CSfxManager::EAuxEffect CSfxManager::m_activeEffect = 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::kMedPriority;
|
||||
|
@ -54,27 +54,27 @@ bool CSfxManager::LoadTranslationTable(CSimplePool* pool, const SObjectTag* tag)
|
|||
}
|
||||
|
||||
bool CSfxManager::CSfxWrapper::IsPlaying() const {
|
||||
if (CBaseSfxWrapper::IsPlaying() && x1c_voiceHandle)
|
||||
return x1c_voiceHandle->state() == amuse::VoiceState::Playing;
|
||||
// if (CBaseSfxWrapper::IsPlaying() && x1c_voiceHandle)
|
||||
// return x1c_voiceHandle->state() == amuse::VoiceState::Playing;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSfxManager::CSfxWrapper::Play() {
|
||||
x1c_voiceHandle = CAudioSys::GetAmuseEngine().fxStart(x18_sfxId, x20_vol, x22_pan);
|
||||
if (x1c_voiceHandle) {
|
||||
if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics())
|
||||
x1c_voiceHandle->setReverbVol(m_reverbAmount);
|
||||
SetPlaying(true);
|
||||
}
|
||||
// x1c_voiceHandle = CAudioSys::GetAmuseEngine().fxStart(x18_sfxId, x20_vol, x22_pan);
|
||||
// if (x1c_voiceHandle) {
|
||||
// if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics())
|
||||
// x1c_voiceHandle->setReverbVol(m_reverbAmount);
|
||||
// SetPlaying(true);
|
||||
// }
|
||||
x24_ready = false;
|
||||
}
|
||||
|
||||
void CSfxManager::CSfxWrapper::Stop() {
|
||||
if (x1c_voiceHandle) {
|
||||
x1c_voiceHandle->keyOff();
|
||||
SetPlaying(false);
|
||||
x1c_voiceHandle.reset();
|
||||
}
|
||||
// if (x1c_voiceHandle) {
|
||||
// x1c_voiceHandle->keyOff();
|
||||
// SetPlaying(false);
|
||||
// x1c_voiceHandle.reset();
|
||||
// }
|
||||
}
|
||||
|
||||
bool CSfxManager::CSfxWrapper::Ready() {
|
||||
|
@ -86,25 +86,25 @@ bool CSfxManager::CSfxWrapper::Ready() {
|
|||
u16 CSfxManager::CSfxWrapper::GetSfxId() const { return x18_sfxId; }
|
||||
|
||||
void CSfxManager::CSfxWrapper::UpdateEmitterSilent() {
|
||||
if (x1c_voiceHandle)
|
||||
x1c_voiceHandle->setVolume(1.f / 127.f);
|
||||
// if (x1c_voiceHandle)
|
||||
// x1c_voiceHandle->setVolume(1.f / 127.f);
|
||||
}
|
||||
|
||||
void CSfxManager::CSfxWrapper::UpdateEmitter() {
|
||||
if (x1c_voiceHandle)
|
||||
x1c_voiceHandle->setVolume(x20_vol);
|
||||
// if (x1c_voiceHandle)
|
||||
// x1c_voiceHandle->setVolume(x20_vol);
|
||||
}
|
||||
|
||||
void CSfxManager::CSfxWrapper::SetReverb(float rev) {
|
||||
if (x1c_voiceHandle && IsAuxProcessingEnabled() && UseAcoustics())
|
||||
x1c_voiceHandle->setReverbVol(rev);
|
||||
// if (x1c_voiceHandle && IsAuxProcessingEnabled() && UseAcoustics())
|
||||
// x1c_voiceHandle->setReverbVol(rev);
|
||||
}
|
||||
|
||||
bool CSfxManager::CSfxEmitterWrapper::IsPlaying() const {
|
||||
if (IsLooped())
|
||||
return CBaseSfxWrapper::IsPlaying();
|
||||
if (CBaseSfxWrapper::IsPlaying() && x50_emitterHandle)
|
||||
return x50_emitterHandle->getVoice()->state() == amuse::VoiceState::Playing;
|
||||
// if (CBaseSfxWrapper::IsPlaying() && x50_emitterHandle)
|
||||
// return x50_emitterHandle->getVoice()->state() == amuse::VoiceState::Playing;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -114,23 +114,23 @@ void CSfxManager::CSfxEmitterWrapper::Play() {
|
|||
else
|
||||
x1a_reverb = 0.f;
|
||||
|
||||
zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
|
||||
zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
|
||||
x50_emitterHandle = CAudioSys::GetAmuseEngine().addEmitter(
|
||||
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);
|
||||
|
||||
if (x50_emitterHandle)
|
||||
SetPlaying(true);
|
||||
// zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
|
||||
// zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
|
||||
// x50_emitterHandle = CAudioSys::GetAmuseEngine().addEmitter(
|
||||
// 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);
|
||||
//
|
||||
// if (x50_emitterHandle)
|
||||
// SetPlaying(true);
|
||||
x54_ready = false;
|
||||
}
|
||||
|
||||
void CSfxManager::CSfxEmitterWrapper::Stop() {
|
||||
if (x50_emitterHandle) {
|
||||
x50_emitterHandle->getVoice()->keyOff();
|
||||
SetPlaying(false);
|
||||
x50_emitterHandle.reset();
|
||||
}
|
||||
// if (x50_emitterHandle) {
|
||||
// x50_emitterHandle->getVoice()->keyOff();
|
||||
// SetPlaying(false);
|
||||
// x50_emitterHandle.reset();
|
||||
// }
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
void CSfxManager::CSfxEmitterWrapper::UpdateEmitterSilent() {
|
||||
if (x50_emitterHandle) {
|
||||
zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
|
||||
zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
|
||||
x50_emitterHandle->setVectors(pos.data(), dir.data());
|
||||
x50_emitterHandle->setMaxVol(1.f / 127.f);
|
||||
}
|
||||
// if (x50_emitterHandle) {
|
||||
// zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
|
||||
// zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
|
||||
// x50_emitterHandle->setVectors(pos.data(), dir.data());
|
||||
// x50_emitterHandle->setMaxVol(1.f / 127.f);
|
||||
// }
|
||||
x55_cachedMaxVol = x24_parmData.x26_maxVol;
|
||||
}
|
||||
|
||||
void CSfxManager::CSfxEmitterWrapper::UpdateEmitter() {
|
||||
if (x50_emitterHandle) {
|
||||
zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
|
||||
zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
|
||||
x50_emitterHandle->setVectors(pos.data(), dir.data());
|
||||
x50_emitterHandle->setMaxVol(x55_cachedMaxVol);
|
||||
}
|
||||
// if (x50_emitterHandle) {
|
||||
// zeus::simd_floats pos(x24_parmData.x0_pos.mSimd);
|
||||
// zeus::simd_floats dir(x24_parmData.xc_dir.mSimd);
|
||||
// x50_emitterHandle->setVectors(pos.data(), dir.data());
|
||||
// x50_emitterHandle->setMaxVol(x55_cachedMaxVol);
|
||||
// }
|
||||
}
|
||||
|
||||
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,
|
||||
const zeus::CVector3f& heading, const zeus::CVector3f& up, float frontRadius,
|
||||
float surroundRadius, float soundSpeed, u32 flags /* 0x1 for doppler */, float vol) {
|
||||
if (m_listener)
|
||||
CAudioSys::GetAmuseEngine().removeListener(m_listener.get());
|
||||
zeus::simd_floats p(pos.mSimd);
|
||||
zeus::simd_floats d(dir.mSimd);
|
||||
zeus::simd_floats h(heading.mSimd);
|
||||
zeus::simd_floats u(up.mSimd);
|
||||
m_listener = CAudioSys::GetAmuseEngine().addListener(p.data(), d.data(), h.data(), u.data(), frontRadius,
|
||||
surroundRadius, soundSpeed, vol);
|
||||
// if (m_listener)
|
||||
// CAudioSys::GetAmuseEngine().removeListener(m_listener.get());
|
||||
// zeus::simd_floats p(pos.mSimd);
|
||||
// zeus::simd_floats d(dir.mSimd);
|
||||
// zeus::simd_floats h(heading.mSimd);
|
||||
// zeus::simd_floats u(up.mSimd);
|
||||
// m_listener = CAudioSys::GetAmuseEngine().addListener(p.data(), d.data(), h.data(), u.data(), frontRadius,
|
||||
// surroundRadius, soundSpeed, vol);
|
||||
}
|
||||
|
||||
void CSfxManager::UpdateListener(const zeus::CVector3f& pos, const zeus::CVector3f& dir, const zeus::CVector3f& heading,
|
||||
const zeus::CVector3f& up, float vol) {
|
||||
if (m_listener) {
|
||||
zeus::simd_floats p(pos.mSimd);
|
||||
zeus::simd_floats d(dir.mSimd);
|
||||
zeus::simd_floats h(heading.mSimd);
|
||||
zeus::simd_floats u(up.mSimd);
|
||||
m_listener->setVectors(p.data(), d.data(), h.data(), u.data());
|
||||
m_listener->setVolume(vol);
|
||||
}
|
||||
// if (m_listener) {
|
||||
// zeus::simd_floats p(pos.mSimd);
|
||||
// zeus::simd_floats d(dir.mSimd);
|
||||
// zeus::simd_floats h(heading.mSimd);
|
||||
// zeus::simd_floats u(up.mSimd);
|
||||
// m_listener->setVectors(p.data(), d.data(), h.data(), u.data());
|
||||
// m_listener->setVolume(vol);
|
||||
// }
|
||||
}
|
||||
|
||||
s16 CSfxManager::GetRank(CBaseSfxWrapper* sfx) {
|
||||
|
@ -304,10 +304,10 @@ void CSfxManager::PitchBend(const CSfxHandle& handle, float pitch) {
|
|||
return;
|
||||
if (!handle->IsPlaying())
|
||||
CSfxManager::Update(0.f);
|
||||
if (handle->IsPlaying()) {
|
||||
m_doUpdate = true;
|
||||
handle->GetVoice()->setPitchWheel(pitch);
|
||||
}
|
||||
// if (handle->IsPlaying()) {
|
||||
// m_doUpdate = true;
|
||||
// handle->GetVoice()->setPitchWheel(pitch);
|
||||
// }
|
||||
}
|
||||
|
||||
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);
|
||||
wrapper.SetVolume(vol);
|
||||
}
|
||||
if (handle->IsPlaying())
|
||||
handle->GetVoice()->setVolume(vol);
|
||||
// if (handle->IsPlaying())
|
||||
// handle->GetVoice()->setVolume(vol);
|
||||
}
|
||||
|
||||
void CSfxManager::SfxSpan(const CSfxHandle& handle, float span) {
|
||||
if (!handle)
|
||||
return;
|
||||
if (handle->IsPlaying())
|
||||
handle->GetVoice()->setSurroundPan(span);
|
||||
// if (handle->IsPlaying())
|
||||
// handle->GetVoice()->setSurroundPan(span);
|
||||
}
|
||||
|
||||
u16 CSfxManager::TranslateSFXID(u16 id) {
|
||||
|
@ -380,16 +380,16 @@ void CSfxManager::UpdateEmitter(const CSfxHandle& handle, const zeus::CVector3f&
|
|||
float maxVol) {
|
||||
if (!handle || !handle->IsEmitter() || !handle->IsPlaying())
|
||||
return;
|
||||
m_doUpdate = true;
|
||||
CSfxEmitterWrapper& emitter = static_cast<CSfxEmitterWrapper&>(*handle);
|
||||
emitter.GetEmitterData().x0_pos = pos;
|
||||
emitter.GetEmitterData().xc_dir = dir;
|
||||
emitter.GetEmitterData().x26_maxVol = maxVol;
|
||||
amuse::Emitter& h = *emitter.GetHandle();
|
||||
zeus::simd_floats p(pos.mSimd);
|
||||
zeus::simd_floats d(dir.mSimd);
|
||||
h.setVectors(p.data(), d.data());
|
||||
h.setMaxVol(maxVol);
|
||||
// m_doUpdate = true;
|
||||
// CSfxEmitterWrapper& emitter = static_cast<CSfxEmitterWrapper&>(*handle);
|
||||
// emitter.GetEmitterData().x0_pos = pos;
|
||||
// emitter.GetEmitterData().xc_dir = dir;
|
||||
// emitter.GetEmitterData().x26_maxVol = maxVol;
|
||||
// amuse::Emitter& h = *emitter.GetHandle();
|
||||
// zeus::simd_floats p(pos.mSimd);
|
||||
// zeus::simd_floats d(dir.mSimd);
|
||||
// h.setVectors(p.data(), d.data());
|
||||
// h.setMaxVol(maxVol);
|
||||
}
|
||||
|
||||
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)
|
||||
DisableAuxCallback();
|
||||
|
||||
auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio();
|
||||
amuse::Submix& smix = studio->getAuxA();
|
||||
|
||||
m_activeEffect = m_nextEffect;
|
||||
switch (m_activeEffect) {
|
||||
case EAuxEffect::ReverbHi:
|
||||
s_ReverbHiState = &smix.makeReverbHi(s_ReverbHiQueued);
|
||||
break;
|
||||
case EAuxEffect::Chorus:
|
||||
s_ChorusState = &smix.makeChorus(s_ChorusQueued);
|
||||
break;
|
||||
case EAuxEffect::ReverbStd:
|
||||
s_ReverbStdState = &smix.makeReverbStd(s_ReverbStdQueued);
|
||||
break;
|
||||
case EAuxEffect::Delay:
|
||||
s_DelayState = &smix.makeDelay(s_DelayQueued);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio();
|
||||
// amuse::Submix& smix = studio->getAuxA();
|
||||
//
|
||||
// m_activeEffect = m_nextEffect;
|
||||
// switch (m_activeEffect) {
|
||||
// case EAuxEffect::ReverbHi:
|
||||
// s_ReverbHiState = &smix.makeReverbHi(s_ReverbHiQueued);
|
||||
// break;
|
||||
// case EAuxEffect::Chorus:
|
||||
// s_ChorusState = &smix.makeChorus(s_ChorusQueued);
|
||||
// break;
|
||||
// case EAuxEffect::ReverbStd:
|
||||
// s_ReverbStdState = &smix.makeReverbStd(s_ReverbStdQueued);
|
||||
// break;
|
||||
// case EAuxEffect::Delay:
|
||||
// s_DelayState = &smix.makeDelay(s_DelayQueued);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
m_auxProcessingEnabled = true;
|
||||
}
|
||||
|
||||
void CSfxManager::PrepareDelayCallback(const amuse::EffectDelayInfo& info) {
|
||||
DisableAuxProcessing();
|
||||
s_DelayQueued = info;
|
||||
m_nextEffect = EAuxEffect::Delay;
|
||||
if (m_reverbAmount == 0.f)
|
||||
EnableAuxCallback();
|
||||
}
|
||||
|
||||
void CSfxManager::PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info) {
|
||||
DisableAuxProcessing();
|
||||
s_ReverbStdQueued = info;
|
||||
m_nextEffect = EAuxEffect::ReverbStd;
|
||||
if (m_reverbAmount == 0.f)
|
||||
EnableAuxCallback();
|
||||
}
|
||||
|
||||
void CSfxManager::PrepareChorusCallback(const amuse::EffectChorusInfo& info) {
|
||||
DisableAuxProcessing();
|
||||
s_ChorusQueued = info;
|
||||
m_nextEffect = EAuxEffect::Chorus;
|
||||
if (m_reverbAmount == 0.f)
|
||||
EnableAuxCallback();
|
||||
}
|
||||
|
||||
void CSfxManager::PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info) {
|
||||
DisableAuxProcessing();
|
||||
s_ReverbHiQueued = info;
|
||||
m_nextEffect = EAuxEffect::ReverbHi;
|
||||
if (m_reverbAmount == 0.f)
|
||||
EnableAuxCallback();
|
||||
}
|
||||
//void CSfxManager::PrepareDelayCallback(const amuse::EffectDelayInfo& info) {
|
||||
// DisableAuxProcessing();
|
||||
// s_DelayQueued = info;
|
||||
// m_nextEffect = EAuxEffect::Delay;
|
||||
// if (m_reverbAmount == 0.f)
|
||||
// EnableAuxCallback();
|
||||
//}
|
||||
//
|
||||
//void CSfxManager::PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info) {
|
||||
// DisableAuxProcessing();
|
||||
// s_ReverbStdQueued = info;
|
||||
// m_nextEffect = EAuxEffect::ReverbStd;
|
||||
// if (m_reverbAmount == 0.f)
|
||||
// EnableAuxCallback();
|
||||
//}
|
||||
//
|
||||
//void CSfxManager::PrepareChorusCallback(const amuse::EffectChorusInfo& info) {
|
||||
// DisableAuxProcessing();
|
||||
// s_ChorusQueued = info;
|
||||
// m_nextEffect = EAuxEffect::Chorus;
|
||||
// if (m_reverbAmount == 0.f)
|
||||
// EnableAuxCallback();
|
||||
//}
|
||||
//
|
||||
//void CSfxManager::PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info) {
|
||||
// DisableAuxProcessing();
|
||||
// s_ReverbHiQueued = info;
|
||||
// m_nextEffect = EAuxEffect::ReverbHi;
|
||||
// if (m_reverbAmount == 0.f)
|
||||
// EnableAuxCallback();
|
||||
//}
|
||||
|
||||
void CSfxManager::DisableAuxCallback() {
|
||||
auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio();
|
||||
studio->getAuxA().clearEffects();
|
||||
|
||||
switch (m_activeEffect) {
|
||||
case EAuxEffect::ReverbHi:
|
||||
s_ReverbHiState = nullptr;
|
||||
break;
|
||||
case EAuxEffect::Chorus:
|
||||
s_ChorusState = nullptr;
|
||||
break;
|
||||
case EAuxEffect::ReverbStd:
|
||||
s_ReverbStdState = nullptr;
|
||||
break;
|
||||
case EAuxEffect::Delay:
|
||||
s_DelayState = nullptr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_activeEffect = EAuxEffect::None;
|
||||
// auto studio = CAudioSys::GetAmuseEngine().getDefaultStudio();
|
||||
// studio->getAuxA().clearEffects();
|
||||
//
|
||||
// switch (m_activeEffect) {
|
||||
// case EAuxEffect::ReverbHi:
|
||||
// s_ReverbHiState = nullptr;
|
||||
// break;
|
||||
// case EAuxEffect::Chorus:
|
||||
// s_ChorusState = nullptr;
|
||||
// break;
|
||||
// case EAuxEffect::ReverbStd:
|
||||
// s_ReverbStdState = nullptr;
|
||||
// break;
|
||||
// case EAuxEffect::Delay:
|
||||
// s_DelayState = nullptr;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// m_activeEffect = EAuxEffect::None;
|
||||
}
|
||||
|
||||
void CSfxManager::DisableAuxProcessing() {
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
virtual void Stop() = 0;
|
||||
virtual bool Ready() = 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 void UpdateEmitterSilent() = 0;
|
||||
virtual void UpdateEmitter() = 0;
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
class CSfxEmitterWrapper : public CBaseSfxWrapper {
|
||||
float x1a_reverb = 0.0f;
|
||||
CAudioSys::C3DEmitterParmData x24_parmData;
|
||||
amuse::ObjToken<amuse::Emitter> x50_emitterHandle;
|
||||
//amuse::ObjToken<amuse::Emitter> x50_emitterHandle;
|
||||
bool x54_ready = true;
|
||||
float x55_cachedMaxVol = 0.0f;
|
||||
|
||||
|
@ -126,14 +126,14 @@ public:
|
|||
void Stop() override;
|
||||
bool Ready() 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;
|
||||
void UpdateEmitterSilent() override;
|
||||
void UpdateEmitter() override;
|
||||
void SetReverb(float rev) override;
|
||||
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,
|
||||
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
|
||||
|
@ -144,7 +144,7 @@ public:
|
|||
|
||||
class CSfxWrapper : public CBaseSfxWrapper {
|
||||
u16 x18_sfxId;
|
||||
amuse::ObjToken<amuse::Voice> x1c_voiceHandle;
|
||||
//amuse::ObjToken<amuse::Voice> x1c_voiceHandle;
|
||||
float x20_vol;
|
||||
float x22_pan;
|
||||
bool x24_ready = true;
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
void Stop() override;
|
||||
bool Ready() override;
|
||||
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;
|
||||
void UpdateEmitterSilent() override;
|
||||
void UpdateEmitter() override;
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
static float m_reverbAmount;
|
||||
static EAuxEffect m_activeEffect;
|
||||
static EAuxEffect m_nextEffect;
|
||||
static amuse::ObjToken<amuse::Listener> m_listener;
|
||||
//static amuse::ObjToken<amuse::Listener> m_listener;
|
||||
|
||||
static u16 kMaxPriority;
|
||||
static u16 kMedPriority;
|
||||
|
@ -222,10 +222,10 @@ public:
|
|||
static void StopAndRemoveAllEmitters();
|
||||
static void DisableAuxCallback();
|
||||
static void EnableAuxCallback();
|
||||
static void PrepareDelayCallback(const amuse::EffectDelayInfo& info);
|
||||
static void PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info);
|
||||
static void PrepareChorusCallback(const amuse::EffectChorusInfo& info);
|
||||
static void PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info);
|
||||
// static void PrepareDelayCallback(const amuse::EffectDelayInfo& info);
|
||||
// static void PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info);
|
||||
// static void PrepareChorusCallback(const amuse::EffectChorusInfo& info);
|
||||
// static void PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info);
|
||||
static void DisableAuxProcessing();
|
||||
|
||||
static void SetActiveAreas(const rstl::reserved_vector<TAreaId, 10>& areas);
|
||||
|
|
|
@ -7,37 +7,37 @@ namespace metaforce {
|
|||
|
||||
#define RSF_BUFFER_SIZE 0x20000
|
||||
|
||||
CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart,
|
||||
int loopEnd)
|
||||
: x0_path(path)
|
||||
, x1c_loopStartSamp(loopStart & 0xfffffffe)
|
||||
, x20_loopEndSamp(loopEnd & 0xfffffffe)
|
||||
, m_voiceCallback(*this)
|
||||
, m_voice(engine.allocateNewStereoVoice(32000, &m_voiceCallback)) {
|
||||
// These are mixed directly into boo voice engine instead
|
||||
// x28_dmaLeft.reset(new u8[640]);
|
||||
// x30_dmaRight.reset(new u8[640]);
|
||||
|
||||
CDvdFile file(path);
|
||||
x10_rsfRem = file.Length();
|
||||
x14_rsfLength = x10_rsfRem;
|
||||
|
||||
u32 bufCount = (x10_rsfRem + RSF_BUFFER_SIZE - 1) / RSF_BUFFER_SIZE;
|
||||
x48_buffers.reserve(bufCount);
|
||||
x38_dvdRequests.reserve(bufCount);
|
||||
|
||||
for (int remBytes = x10_rsfRem; remBytes > 0; remBytes -= RSF_BUFFER_SIZE) {
|
||||
u32 thisSz = RSF_BUFFER_SIZE;
|
||||
if (remBytes < RSF_BUFFER_SIZE)
|
||||
thisSz = ROUND_UP_32(remBytes);
|
||||
|
||||
x48_buffers.emplace_back(new u8[thisSz]);
|
||||
x38_dvdRequests.push_back(file.AsyncRead(x48_buffers.back().get(), thisSz));
|
||||
}
|
||||
|
||||
g72x_init_state(&x58_leftState);
|
||||
g72x_init_state(&x8c_rightState);
|
||||
}
|
||||
//CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart,
|
||||
// int loopEnd)
|
||||
//: x0_path(path)
|
||||
//, x1c_loopStartSamp(loopStart & 0xfffffffe)
|
||||
//, x20_loopEndSamp(loopEnd & 0xfffffffe)
|
||||
//, m_voiceCallback(*this)
|
||||
//, m_voice(engine.allocateNewStereoVoice(32000, &m_voiceCallback)) {
|
||||
// // These are mixed directly into boo voice engine instead
|
||||
// // x28_dmaLeft.reset(new u8[640]);
|
||||
// // x30_dmaRight.reset(new u8[640]);
|
||||
//
|
||||
// CDvdFile file(path);
|
||||
// x10_rsfRem = file.Length();
|
||||
// x14_rsfLength = x10_rsfRem;
|
||||
//
|
||||
// u32 bufCount = (x10_rsfRem + RSF_BUFFER_SIZE - 1) / RSF_BUFFER_SIZE;
|
||||
// x48_buffers.reserve(bufCount);
|
||||
// x38_dvdRequests.reserve(bufCount);
|
||||
//
|
||||
// for (int remBytes = x10_rsfRem; remBytes > 0; remBytes -= RSF_BUFFER_SIZE) {
|
||||
// u32 thisSz = RSF_BUFFER_SIZE;
|
||||
// if (remBytes < RSF_BUFFER_SIZE)
|
||||
// thisSz = ROUND_UP_32(remBytes);
|
||||
//
|
||||
// x48_buffers.emplace_back(new u8[thisSz]);
|
||||
// x38_dvdRequests.push_back(file.AsyncRead(x48_buffers.back().get(), thisSz));
|
||||
// }
|
||||
//
|
||||
// g72x_init_state(&x58_leftState);
|
||||
// g72x_init_state(&x8c_rightState);
|
||||
//}
|
||||
|
||||
bool CStaticAudioPlayer::IsReady() {
|
||||
if (x38_dvdRequests.size())
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
#include "g721.h"
|
||||
|
||||
#include <boo/audiodev/IAudioVoice.hpp>
|
||||
#include <boo/audiodev/IAudioVoiceEngine.hpp>
|
||||
//#include <boo/audiodev/IAudioVoice.hpp>
|
||||
//#include <boo/audiodev/IAudioVoiceEngine.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
class IDvdRequest;
|
||||
|
@ -41,8 +41,8 @@ class CStaticAudioPlayer {
|
|||
val = 32767;
|
||||
return val;
|
||||
}
|
||||
|
||||
struct AudioVoiceCallback : boo::IAudioVoiceCallback {
|
||||
/*
|
||||
struct AudioVoiceCallback {
|
||||
CStaticAudioPlayer& m_parent;
|
||||
void preSupplyAudio(boo::IAudioVoice&, double) 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) {}
|
||||
} m_voiceCallback;
|
||||
boo::ObjToken<boo::IAudioVoice> m_voice;
|
||||
|
||||
*/
|
||||
public:
|
||||
CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart, int loopEnd);
|
||||
CStaticAudioPlayer(std::string_view path, int loopStart, int loopEnd)
|
||||
: CStaticAudioPlayer(*CAudioSys::GetVoiceEngine(), path, loopStart, loopEnd) {}
|
||||
// CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart, int loopEnd);
|
||||
// CStaticAudioPlayer(std::string_view path, int loopStart, int loopEnd)
|
||||
// : CStaticAudioPlayer(*CAudioSys::GetVoiceEngine(), path, loopStart, loopEnd) {}
|
||||
|
||||
bool IsReady();
|
||||
void DecodeMonoAndMix(s16* bufOut, u32 numSamples, u32 cur, u32 loopEndCur, u32 loopStartCur, int vol,
|
||||
g72x_state& state, std::optional<g72x_state>& loopState) const;
|
||||
void Decode(s16* bufOut, u32 numSamples);
|
||||
void SetVolume(float vol) { xc0_volume = zeus::clamp(0.f, vol, 1.f) * 32768.f; }
|
||||
|
||||
void StartMixing() { m_voice->start(); }
|
||||
void StopMixing() { m_voice->stop(); }
|
||||
//
|
||||
// void StartMixing() { m_voice->start(); }
|
||||
// void StopMixing() { m_voice->stop(); }
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include <amuse/DSPCodec.hpp>
|
||||
//#include <amuse/DSPCodec.hpp>
|
||||
|
||||
namespace metaforce {
|
||||
class CDSPStreamManager;
|
||||
|
@ -54,7 +54,7 @@ struct SDSPStreamInfo {
|
|||
explicit SDSPStreamInfo(const CDSPStreamManager& stream);
|
||||
};
|
||||
|
||||
struct SDSPStream : boo::IAudioVoiceCallback {
|
||||
struct SDSPStream {
|
||||
bool x0_active;
|
||||
bool x1_oneshot;
|
||||
s32 x4_ownerId;
|
||||
|
@ -155,91 +155,91 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
s16 m_prev1 = 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 startSamp = m_curSample;
|
||||
// unsigned decompressChunk(unsigned readToSample, int16_t*& data) {
|
||||
// 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));
|
||||
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;
|
||||
}
|
||||
|
||||
size_t supplyAudio(boo::IAudioVoice&, size_t frames, int16_t* data) override {
|
||||
if (!x0_active) {
|
||||
memset(data, 0, frames * 2);
|
||||
return frames;
|
||||
}
|
||||
|
||||
if (xe8_silent) {
|
||||
StopStream();
|
||||
memset(data, 0, frames * 2);
|
||||
return frames;
|
||||
}
|
||||
|
||||
unsigned halfRingSamples = xdc_ringSamples / 2;
|
||||
|
||||
size_t remFrames = frames;
|
||||
while (remFrames) {
|
||||
if (xec_readState != 2 || (xe0_curBuffer == 0 && m_curSample >= halfRingSamples)) {
|
||||
if (!BufferStream()) {
|
||||
memset(data, 0, remFrames * 2);
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned readToSample =
|
||||
std::min(m_curSample + unsigned(remFrames), (m_curSample / halfRingSamples + 1) * halfRingSamples);
|
||||
|
||||
if (!x10_info.x10_loopFlag) {
|
||||
m_totalSamples += remFrames;
|
||||
size_t fileSamples = x10_info.xc_adpcmBytes * 14 / 8;
|
||||
if (m_totalSamples >= fileSamples) {
|
||||
size_t leftover = m_totalSamples - fileSamples;
|
||||
readToSample -= leftover;
|
||||
remFrames -= leftover;
|
||||
memset(data + remFrames, 0, leftover * 2);
|
||||
StopStream();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
// size_t supplyAudio(boo::IAudioVoice&, size_t frames, int16_t* data) override {
|
||||
// if (!x0_active) {
|
||||
// memset(data, 0, frames * 2);
|
||||
// return frames;
|
||||
// }
|
||||
//
|
||||
// if (xe8_silent) {
|
||||
// StopStream();
|
||||
// memset(data, 0, frames * 2);
|
||||
// return frames;
|
||||
// }
|
||||
//
|
||||
// unsigned halfRingSamples = xdc_ringSamples / 2;
|
||||
//
|
||||
// size_t remFrames = frames;
|
||||
// while (remFrames) {
|
||||
// if (xec_readState != 2 || (xe0_curBuffer == 0 && m_curSample >= halfRingSamples)) {
|
||||
// if (!BufferStream()) {
|
||||
// memset(data, 0, remFrames * 2);
|
||||
// return frames;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// unsigned readToSample =
|
||||
// std::min(m_curSample + unsigned(remFrames), (m_curSample / halfRingSamples + 1) * halfRingSamples);
|
||||
//
|
||||
// if (!x10_info.x10_loopFlag) {
|
||||
// m_totalSamples += remFrames;
|
||||
// size_t fileSamples = x10_info.xc_adpcmBytes * 14 / 8;
|
||||
// if (m_totalSamples >= fileSamples) {
|
||||
// size_t leftover = m_totalSamples - fileSamples;
|
||||
// readToSample -= leftover;
|
||||
// remFrames -= leftover;
|
||||
// memset(data + remFrames, 0, leftover * 2);
|
||||
// StopStream();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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() {
|
||||
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() {
|
||||
|
@ -259,18 +259,18 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
}
|
||||
|
||||
static void FreeAllStreams() {
|
||||
for (auto& stream : g_Streams) {
|
||||
stream.m_booVoice.reset();
|
||||
stream.x0_active = false;
|
||||
for (auto& request : stream.m_readReqs) {
|
||||
if (request) {
|
||||
request->PostCancelRequest();
|
||||
request.reset();
|
||||
}
|
||||
}
|
||||
stream.xd4_ringBuffer.reset();
|
||||
stream.m_file = std::nullopt;
|
||||
}
|
||||
// for (auto& stream : g_Streams) {
|
||||
// stream.m_booVoice.reset();
|
||||
// stream.x0_active = false;
|
||||
// for (auto& request : stream.m_readReqs) {
|
||||
// if (request) {
|
||||
// request->PostCancelRequest();
|
||||
// request.reset();
|
||||
// }
|
||||
// }
|
||||
// stream.xd4_ringBuffer.reset();
|
||||
// stream.m_file = std::nullopt;
|
||||
// }
|
||||
}
|
||||
|
||||
static s32 PickFreeStream(SDSPStream*& streamOut, bool oneshot) {
|
||||
|
@ -302,27 +302,27 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
}
|
||||
|
||||
void UpdateStreamVolume(float vol) {
|
||||
x4c_vol = vol;
|
||||
if (!x0_active || xe8_silent) {
|
||||
return;
|
||||
}
|
||||
std::array<float, 8> coefs{};
|
||||
coefs[size_t(boo::AudioChannel::FrontLeft)] = m_leftgain * vol;
|
||||
coefs[size_t(boo::AudioChannel::FrontRight)] = m_rightgain * vol;
|
||||
m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true);
|
||||
// x4c_vol = vol;
|
||||
// if (!x0_active || xe8_silent) {
|
||||
// return;
|
||||