JAudio2 debug (#2996)

This commit is contained in:
Jcw87
2025-12-26 13:20:53 -08:00
committed by GitHub
parent 67b576ad9a
commit bae6d9da2d
34 changed files with 337 additions and 201 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ class JAISeMgr;
* @ingroup jsystem-jaudio
*
*/
class JAISe : public JSULink<JAISe>, public JASPoolAllocObject<JAISe>, public JAISound {
class JAISe : public JSULink<JAISe>, public JAISound, public JASPoolAllocObject<JAISe> {
public:
class TInner {
public:
+5 -2
View File
@@ -69,6 +69,7 @@ public:
return mMaxActiveSe + mMaxInactiveSe;
}
int getMaxInactiveSe() const { return mMaxInactiveSe; }
int getMaxActiveSe() const { return mMaxActiveSe; }
void setMaxActiveSe(int num) { mMaxActiveSe = num; }
void setMaxInactiveSe(int num) { mMaxInactiveSe = num; }
@@ -88,11 +89,11 @@ public:
*
*/
class JAISeMgr : public JASGlobalInstance<JAISeMgr>,
public JAISeqDataUser,
public JAISoundActivity {
public JAISeqDataUser {
public:
JAISeMgr(bool setInstance);
void setCategoryArrangement(const JAISeCategoryArrangement& arrangement);
void getCategoryArrangement(JAISeCategoryArrangement*);
void stop();
void stopSoundID(JAISoundID id);
void initParams();
@@ -105,6 +106,8 @@ public:
bool startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr);
int getNumActiveSe() const;
/* 0x004 */ JAISoundActivity mSoundActivity;
virtual bool isUsingSeqData(const JAISeqDataRegion& seqDataRegion);
virtual int releaseSeqData(const JAISeqDataRegion& seqDataRegion);
+1 -1
View File
@@ -52,7 +52,7 @@ public:
void mixOut_(const JASSoundParams& params, JAISoundActivity activity);
void JAISeqMgr_mixOut_(const JASSoundParams& params, JAISoundActivity activity);
JAISeqData& getSeqData() { return inner_.mSeqData; }
const JAISeqData& getSeqData() const { return inner_.mSeqData; }
/* 0x0A8 */ TInner inner_;
/* 0x3A8 */ JAISoundStrategyMgr__unknown<JAISeq>* field_0x3a8;
+2 -1
View File
@@ -29,6 +29,8 @@ public:
JAISeq* beginStartSeq_();
bool endStartSeq_(JAISeq* seq, JAISoundHandle* handle);
/* 0x04 */ JAISoundActivity mActivity;
virtual ~JAISeqMgr() {}
virtual bool isUsingSeqData(const JAISeqDataRegion& seqDataRegion);
virtual int releaseSeqData(const JAISeqDataRegion& seqDataRegion);
@@ -59,7 +61,6 @@ public:
void pause(bool paused) { mActivity.field_0x0.flags.flag2 = paused; }
private:
/* 0x04 */ JAISoundActivity mActivity;
/* 0x08 */ JAIAudience* mAudience;
/* 0x0C */ JAISeqDataMgr* seqDataMgr_;
/* 0x10 */ JAISoundStrategyMgr<JAISeq>* field_0x10;
+2 -2
View File
@@ -18,7 +18,7 @@ namespace JASBNKParser {
namespace Ver1 {
struct TOsc {
/* 0x00 */ u8 _00[4];
/* 0x00 */ u32 id;
/* 0x04 */ u8 mTarget;
/* 0x08 */ f32 _08;
/* 0x0C */ u32 mTableOffset;
@@ -50,7 +50,7 @@ namespace JASBNKParser {
};
struct TListChunk : TChunk {
/* 0x8 */ u32 mCount;
/* 0x8 */ u32 count;
/* 0xC */ u32 mOffsets[0];
};
+2
View File
@@ -17,6 +17,8 @@ namespace JASDsp {
*/
class JASBank {
public:
static const int PRG_OSC = 240;
JASBank() { mWaveBank = NULL; }
virtual ~JASBank() {};
virtual bool getInstParam(int, int, int, JASInstParam*) const = 0;
+4 -3
View File
@@ -53,6 +53,7 @@ class JASChannel : public JASPoolAllocObject_MultiThreaded<JASChannel> {
public:
typedef void (*Callback)(u32, JASChannel*, JASDsp::TChannel*, void*);
static const int BUSOUT_CPUCH = 6;
static const int OSC_NUM = 2;
enum CallbackType {
/* 0 */ CB_PLAY,
@@ -62,8 +63,8 @@ public:
};
enum Status {
/* 0 */ STATUS_INACTIVE,
/* 1 */ STATUS_ACTIVE,
/* 0 */ STATUS_STOP,
/* 1 */ STATUS_PLAY,
/* 2 */ STATUS_RELEASE,
};
@@ -129,7 +130,7 @@ public:
void setKey(s32 param_0) { mKey = param_0; }
void setVelocity(u32 param_0) { mVelocity = param_0; }
void setSkipSamples(u32 param_0) { mSkipSamples = param_0; }
bool isDolbyMode() { return mMixConfig[0].whole == 0xffff; }
bool isDolbyMode() const { return mMixConfig[0].whole == 0xffff; }
/* 0x00 */ int mStatus;
/* 0x04 */ bool mPauseFlag;
+32 -3
View File
@@ -22,8 +22,8 @@ public:
bool alloc(JASHeap*, u32);
bool allocTail(JASHeap*, u32);
bool free();
u32 getTotalFreeSize();
u32 getFreeSize();
u32 getTotalFreeSize() const;
u32 getFreeSize() const;
void insertChild(JASHeap*, JASHeap*, void*, u32, bool);
JASHeap* getTailHeap();
u32 getTailOffset();
@@ -203,6 +203,7 @@ public:
}
bool createNewChunk() {
bool r27 = 0;
if (field_0x18 != NULL && field_0x18->isEmpty()) {
field_0x18->revive();
return true;
@@ -242,7 +243,7 @@ public:
while (chunk != NULL) {
if (chunk->checkArea(ptr)) {
chunk->free(ptr);
bool r26 = false;
if (chunk != field_0x18 && chunk->isEmpty()) {
MemoryChunk* nextChunk = chunk->getNextChunk();
delete chunk;
@@ -283,38 +284,54 @@ template <typename T>
class JASPoolAllocObject {
public:
static void* operator new(size_t n) {
#if PLATFORM_GCN
JASMemPool<T>& memPool_ = getMemPool_();
#endif
return memPool_.alloc(n);
}
static void* operator new(size_t n, void* ptr) {
return ptr;
}
static void operator delete(void* ptr, size_t n) {
#if PLATFORM_GCN
JASMemPool<T>& memPool_ = getMemPool_();
#endif
memPool_.free(ptr, n);
}
static void newMemPool(int param_0) {
#if PLATFORM_GCN
JASMemPool<T>& memPool_ = getMemPool_();
#endif
memPool_.newMemPool(param_0);
}
static u32 getFreeMemCount() {
#if PLATFORM_GCN
JASMemPool<T>& memPool_ = getMemPool_();
#endif
return memPool_.getFreeMemCount();
}
static u32 getTotalMemCount() {
#if PLATFORM_GCN
JASMemPool<T>& memPool_ = getMemPool_();
#endif
return memPool_.getTotalMemCount();
}
private:
// Fakematch? Is memPool_ both an in-function static and an out-of-function static?
static JASMemPool<T> memPool_;
#if PLATFORM_GCN
static JASMemPool<T>& getMemPool_() {
static JASMemPool<T> memPool_;
return memPool_;
}
#endif
};
#if !PLATFORM_GCN
template <typename T> JASMemPool<T> JASPoolAllocObject<T>::memPool_;
#endif
/**
* @ingroup jsystem-jaudio
*
@@ -346,31 +363,43 @@ template <typename T>
class JASPoolAllocObject_MultiThreaded {
public:
static void* operator new(size_t n) {
#if PLATFORM_GCN
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
#endif
return memPool_.alloc(n);
}
static void* operator new(size_t n, void* ptr) {
return ptr;
}
static void operator delete(void* ptr, size_t n) {
#if PLATFORM_GCN
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
#endif
memPool_.free(ptr, n);
}
static void newMemPool(int n) {
#if PLATFORM_GCN
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
#endif
memPool_.newMemPool(n);
}
private:
// Fakematch? Is memPool_ both an in-function static and an out-of-function static?
static JASMemPool_MultiThreaded<T> memPool_;
#if PLATFORM_GCN
static JASMemPool_MultiThreaded<T>& getMemPool() {
static JASMemPool_MultiThreaded<T> memPool_;
return memPool_;
}
#endif
};
#if !PLATFORM_GCN
template <typename T> JASMemPool_MultiThreaded<T> JASPoolAllocObject_MultiThreaded<T>::memPool_;
#endif
extern JKRSolidHeap* JASDram;
#endif /* JASHEAPCTRL_H */
+4 -4
View File
@@ -64,10 +64,10 @@ struct JASOscillator {
void setDirectRelease(u16 param_0) { mDirectRelease = param_0; }
void stop() { _1C = 0; }
bool isValid() { return mData != NULL; }
bool isStop() { return _1C == 0; }
bool isRelease() { return _1C == 3 || _1C == 4; }
u32 getTarget() { return mData->mTarget; }
bool isValid() const { return mData != NULL; }
bool isStop() const { return _1C == 0; }
bool isRelease() const { return _1C == 3 || _1C == 4; }
u32 getTarget() const { return mData->mTarget; }
/* 0x00 */ const Data* mData;
/* 0x04 */ f32 _04;
+2 -1
View File
@@ -9,6 +9,7 @@
*/
class JASSeqReader {
public:
JASSeqReader() { init(); }
void init();
void init(void*);
bool call(u32);
@@ -25,7 +26,7 @@ public:
field_0x04 = (u8*)param_1;
}
u32 get24(int param_0) const {
u32 get24(u32 param_0) const {
return (*(u32*)(field_0x00 + param_0 - 1)) & 0xffffff;
}
+3 -1
View File
@@ -9,6 +9,8 @@
*/
class JASTrackPort {
public:
static const int MAX_PORTS = 16;
void init();
u16 readImport(u32);
u16 readExport(u32);
@@ -22,7 +24,7 @@ public:
u16 field_0x0;
u16 field_0x2;
u16 field_0x4[16];
u16 field_0x4[MAX_PORTS];
};
#endif /* JASTRACKPORT_H */
+1 -1
View File
@@ -17,7 +17,7 @@ public:
template<class T>
class TOffset {
public:
T* ptr(void const* param_0) {
T* ptr(void const* param_0) const {
return JSUConvertOffsetToPtr<T>(param_0, mOffset);
}
+2 -2
View File
@@ -245,9 +245,9 @@ public:
return *this;
}
T* operator*() const { return this->getObject(); }
T* operator*() const { return mTree->getObject(); }
T* operator->() const { return this->getObject(); }
T* operator->() const { return mTree->getObject(); }
private:
JSUTree<T>* mTree;
+1 -5
View File
@@ -10,11 +10,7 @@
*/
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, uintptr_t offset) {
if (offset == 0) {
return NULL;
} else {
return (T*)((intptr_t)ptr + (intptr_t)offset);
}
return offset == 0 ? NULL : (T*)((intptr_t)ptr + (intptr_t)offset);
}
/**
+21 -9
View File
@@ -6,15 +6,16 @@
#include "JSystem/JAudio2/JASReport.h"
bool JAISeCategoryMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
JSULink<JAISe>* i = mSeList.getFirst();
while (i != NULL) {
JAISe* obj = i->getObject();
if (seqDataRegion.intersects(*obj->getSeqData())) {
return true;
{
JSULink<JAISe>* i = mSeList.getFirst();
while (i != NULL) {
if (seqDataRegion.intersects(*i->getObject()->getSeqData())) {
return true;
}
i = i->getNext();
}
i = i->getNext();
}
return false;
}
@@ -162,7 +163,7 @@ JAISeMgr::JAISeMgr(bool setInstance) : JASGlobalInstance<JAISeMgr>(setInstance)
mSeqDataMgr = NULL;
mStrategyMgr = NULL;
mParams.init();
JAISoundActivity::init();
mSoundActivity.init();
}
bool JAISeMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
@@ -196,6 +197,17 @@ void JAISeMgr::setCategoryArrangement(const JAISeCategoryArrangement& arrangemen
}
}
void JAISeMgr::getCategoryArrangement(JAISeCategoryArrangement* arrangement) {
for (int i = 0; i < 16; i++) {
int active = mCategoryMgrs[i].getMaxActiveSe();
JUT_ASSERT(299, active <= 255);
arrangement->mItems[i].mMaxActiveSe = active;
int inactive = mCategoryMgrs[i].getMaxInactiveSe();
JUT_ASSERT(302, inactive <= 255);
arrangement->mItems[i].mMaxInactiveSe = inactive;
}
}
void JAISeMgr::stop() {
for (int i = 0; i < 16; i++) {
mCategoryMgrs[i].stop();
@@ -268,7 +280,7 @@ void JAISeMgr::calc() {
void JAISeMgr::mixOut() {
for (int i = 0; i < 16; i++) {
mCategoryMgrs[i].JAISeMgr_mixOut_(mParams, *this);
mCategoryMgrs[i].JAISeMgr_mixOut_(mParams, mSoundActivity);
}
}
+8 -6
View File
@@ -6,8 +6,9 @@
#include "JSystem/JAudio2/JAISoundInfo.h"
bool JAISeqMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
for (JSULink<JAISeq>* i = mSeqList.getFirst(); i != NULL; i = i->getNext()) {
if (seqDataRegion.intersects(i->getObject()->getSeqData())) {
JSULink<JAISeq>* link;
for (link = mSeqList.getFirst(); link != NULL; link = link->getNext()) {
if (seqDataRegion.intersects(link->getObject()->getSeqData())) {
return true;
}
}
@@ -16,9 +17,10 @@ bool JAISeqMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
int JAISeqMgr::releaseSeqData(const JAISeqDataRegion& seqDataRegion) {
bool bVar1 = false;
for (JSULink<JAISeq>* i = mSeqList.getFirst(); i != NULL; i = i->getNext()) {
if (seqDataRegion.intersects(i->getObject()->getSeqData())) {
i->getObject()->stop();
JSULink<JAISeq>* link;
for (link = mSeqList.getFirst(); link != NULL; link = link->getNext()) {
if (seqDataRegion.intersects(link->getObject()->getSeqData())) {
link->getObject()->stop();
bVar1 = true;
}
}
@@ -120,7 +122,7 @@ void JAISeqMgr::mixOut() {
JAISeq* JAISeqMgr::beginStartSeq_() {
JAISeq* seq = new JAISeq(this, field_0x10);
if (seq == NULL) {
JUT_WARN(273, "JASPoolAllocObject::<JAISeq>::operator new failed .\n");
JUT_WARN(273, "%s", "JASPoolAllocObject::<JAISeq>::operator new failed .\n");
}
return seq;
}
+3 -2
View File
@@ -689,8 +689,9 @@ void JASAramStream::channelStart() {
void JASAramStream::channelStop(u16 i_directRelease) {
for (int i = 0; i < mChannelNum; i++) {
if (mChannels[i] != NULL) {
mChannels[i]->release(i_directRelease);
JASChannel* channel = mChannels[i];
if (channel != NULL) {
channel->release(i_directRelease);
}
}
}
+54 -36
View File
@@ -62,8 +62,11 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
}
TEnvtChunk* envt_chunk = (TEnvtChunk*)findChunk(stream, 'ENVT');
JUT_ASSERT(139, envt_chunk);
TOscChunk* osc_chunk = (TOscChunk*)findChunk(stream, 'OSCT');
JUT_ASSERT(142, osc_chunk);
TListChunk* list_chunk = (TListChunk*)findChunk(stream, 'LIST');
JUT_ASSERT(145, list_chunk);
u8* envt = new (heap, 2) u8[envt_chunk->mSize];
JASCalc::bcopy(envt_chunk->mData, envt, envt_chunk->mSize);
@@ -72,36 +75,40 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
u32 count = *ptr++;
JASOscillator::Data* osc_data = new (heap, 0) JASOscillator::Data[count];
for (int i = 0; i < count; i++, ptr += sizeof(TOsc) >> 2) {
TOsc* osc = (TOsc*)ptr;
TOsc* op = (TOsc*)ptr;
JUT_ASSERT(155, op->id == 'Osci');
JASOscillator::Data* data = &osc_data[i];
data->mTarget = osc->mTarget;
data->_04 = osc->_08;
data->mScale = osc->mScale;
data->_14 = osc->_18;
data->mTable = (JASOscillator::Point*)(envt + osc->mTableOffset);
data->rel_table = (JASOscillator::Point*)(envt + osc->_10);
data->mTarget = op->mTarget;
data->_04 = op->_08;
data->mScale = op->mScale;
data->_14 = op->_18;
data->mTable = (JASOscillator::Point*)(envt + op->mTableOffset);
data->rel_table = (JASOscillator::Point*)(envt + op->_10);
}
TListChunk* list = list_chunk;
JUT_ASSERT(172, list->count <= JASBank::PRG_OSC);
bank->newInstTable(list_chunk->mCount, heap);
for (int i = 0; i < list_chunk->mCount; i++) {
bank->newInstTable(list_chunk->count, heap);
for (int i = 0; i < list_chunk->count; i++) {
if (list_chunk->mOffsets[i] != 0) {
u32* data = (u32*)((intptr_t)stream + list_chunk->mOffsets[i]);
switch (*data++) {
case 'Inst': {
JASBasicInst* inst = new (heap, 0) JASBasicInst();
JASBasicInst* instp = new (heap, 0) JASBasicInst();
JUT_ASSERT(187, instp != 0);
u32 count = *data++;
for (int j = 0; j < count; j++) {
u32 index = *data++;
inst->setOsc(j, &osc_data[index]);
instp->setOsc(j, &osc_data[index]);
}
count = *data++;
for (int j = 0; j < count; j++) {
data++;
}
count = *data++;
inst->setKeyRegionCount(count, heap);
instp->setKeyRegionCount(count, heap);
for (int j = 0; j < count; j++) {
JASBasicInst::TKeymap* keymap = inst->getKeyRegion(j);
JASBasicInst::TKeymap* keymap = instp->getKeyRegion(j);
keymap->setHighKey(*data >> 0x18);
u32 fVar4 = data[1];
keymap->field_0x4 = JSULoHalf(data[3]);
@@ -112,42 +119,51 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
data += 4;
}
}
inst->setVolume(*(f32*)&data[0]);
inst->setPitch(*(f32*)&data[1]);
bank->setInst(i, inst);
instp->setVolume(*(f32*)&data[0]);
instp->setPitch(*(f32*)&data[1]);
bank->setInst(i, instp);
break;
}
case 'Perc': {
JASDrumSet* drum = new (heap, 0) JASDrumSet();
JASDrumSet* drump = new (heap, 0) JASDrumSet();
JUT_ASSERT(264, drump != 0);
u32 pmap_count = data[1];
JUT_ASSERT(268, pmap_count <= 128);
u32 count = *data++;
drum->newPercArray(count, heap);
drump->newPercArray(count, heap);
for (int j = 0; j < count; j++) {
u32 offset = *data++;
if (offset != 0) {
JASDrumSet::TPerc* perc = new (heap, 0) JASDrumSet::TPerc();
JASDrumSet::TPerc* percp = new (heap, 0) JASDrumSet::TPerc();
JUT_ASSERT(277, percp);
u32 type = data[0];
JUT_ASSERT(282, type == 'Pmap');
u32* ptr = (u32*)((intptr_t)stream + offset);
TPercData* perc_data = (TPercData*)(ptr + 1);
perc->setVolume(perc_data->mVolume);
perc->setPitch(perc_data->mPitch);
perc->setPan((f32)perc_data->mPan / 127.0f);
perc->setRelease(perc_data->mRelease);
percp->setVolume(perc_data->mVolume);
percp->setPitch(perc_data->mPitch);
percp->setPan((f32)perc_data->mPan / 127.0f);
percp->setRelease(perc_data->mRelease);
ptr = (u32*)&perc_data->field_0xc;
u32 count2 = *ptr++;
for (int k = 0; k < count2; k++) {
ptr++;
}
u32 pVar6 = ptr[0];
perc->field_0xe = JSULoHalf(ptr[2]);
perc->field_0x10 = *(f32*)&ptr[3];
perc->field_0x14 = *(f32*)&ptr[4];
percp->field_0xe = JSULoHalf(ptr[2]);
percp->field_0x10 = *(f32*)&ptr[3];
percp->field_0x14 = *(f32*)&ptr[4];
for (int k = 0; k < pVar6; k++) {}
drum->setPerc(j, perc);
drump->setPerc(j, percp);
}
}
bank->setInst(i, drum);
bank->setInst(i, drump);
break;
}
default:
JUT_PANIC(338, "Unexpected Inst Type");
break;
}
}
}
@@ -277,8 +293,7 @@ JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader
TInst* tinst = data->mInstOffset[i].ptr(header);
if (tinst != NULL) {
for (int j = 0; j < 2; j++) {
TOsc* tosc = tinst->mOscOffset[j].ptr(header);
if (tosc == osc) {
if (tinst->mOscOffset[j].ptr(header) == osc) {
JASInst* inst = bank->getInst(i);
if (inst != NULL) {
JASInstParam param;
@@ -295,12 +310,15 @@ JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader
}
JASOscillator::Point const* JASBNKParser::Ver0::getOscTableEndPtr(JASOscillator::Point const* points) {
s16 tmp;
do {
tmp = points->_0;
points++;
} while (tmp <= 10);
return points;
const JASOscillator::Point* ptr = points;
while(true) {
s16 tmp = ptr->_0;
ptr++;
if (tmp > 10) {
break;
}
}
return ptr;
}
// Fakematch? Why is this here?
+4
View File
@@ -10,6 +10,7 @@ JASBasicBank::JASBasicBank() {
void JASBasicBank::newInstTable(u8 num, JKRHeap* heap) {
if (num != 0) {
JUT_ASSERT(31, num <= JASBank::PRG_OSC);
mInstNumMax = num;
mInstTable = new (heap, 0) JASInst*[mInstNumMax];
JASCalc::bzero(mInstTable, mInstNumMax * 4);
@@ -27,6 +28,9 @@ bool JASBasicBank::getInstParam(int prg_no, int param_1, int param_2,
void JASBasicBank::setInst(int prg_no, JASInst* inst) {
if (mInstTable != NULL) {
JUT_ASSERT(50, prg_no < mInstNumMax);
JUT_ASSERT(54, prg_no >= 0);
JUT_ASSERT(56, mInstTable[prg_no] == 0);
mInstTable[prg_no] = inst;
}
}
+2 -1
View File
@@ -21,6 +21,7 @@ JASBasicInst::~JASBasicInst() {
}
bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) const {
UNUSED(param_1);
param_2->field_0x1c = 0;
param_2->field_0x1e = 0;
param_2->field_0x14 = (JASOscillator::Data**)&field_0xc;
@@ -42,7 +43,7 @@ bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) con
param_2->mVolume *= keyMap->field_0x8;
param_2->mPitch *= keyMap->field_0xc;
param_2->field_0x1a = keyMap->field_0x4;
param_2->field_0x1a = u16(keyMap->field_0x4);
return true;
}

Some files were not shown because too many files have changed in this diff Show More