JAudio2 debug (#2990)

This commit is contained in:
Jcw87
2025-12-23 10:23:09 -08:00
committed by GitHub
parent c9d0c58ffe
commit 6ef13c620a
21 changed files with 464 additions and 229 deletions
+6 -1
View File
@@ -6,6 +6,8 @@
struct JKRHeap;
const int OSC_MAX = 2;
/**
* @ingroup jsystem-jaudio
*
@@ -46,6 +48,7 @@ struct JASBasicInst : public JASInst {
struct TKeymap {
~TKeymap();
TKeymap() { mHighKey = -1; }
s32 getHighKey() const { return mHighKey; }
void setHighKey(int key) { mHighKey = key; }
/* 0x0 */ s32 mHighKey;
@@ -59,6 +62,7 @@ struct JASBasicInst : public JASInst {
void setKeyRegionCount(u32, JKRHeap*);
void setOsc(int, JASOscillator::Data const*);
TKeymap* getKeyRegion(int);
TKeymap* getKeyRegion(int) const;
virtual ~JASBasicInst();
virtual bool getParam(int, int, JASInstParam*) const;
@@ -66,10 +70,11 @@ struct JASBasicInst : public JASInst {
void setVolume(f32 volume) { mVolume = volume; }
void setPitch(f32 pitch) { mPitch = pitch; }
u32 getKeyRegionCount() const { return mKeymapCount; }
/* 0x04 */ f32 mVolume;
/* 0x08 */ f32 mPitch;
/* 0x0C */ JASOscillator::Data const* field_0xc[2];
/* 0x0C */ JASOscillator::Data const* field_0xc[OSC_MAX];
/* 0x10 */ u32 mKeymapCount;
/* 0x14 */ TKeymap* mKeymap;
};
+2 -1
View File
@@ -52,6 +52,7 @@ public:
class JASChannel : public JASPoolAllocObject_MultiThreaded<JASChannel> {
public:
typedef void (*Callback)(u32, JASChannel*, JASDsp::TChannel*, void*);
static const int BUSOUT_CPUCH = 6;
enum CallbackType {
/* 0 */ CB_PLAY,
@@ -140,7 +141,7 @@ public:
/* 0x1C */ JASOscillator mOscillators[2];
/* 0x5C */ JASLfo mVibrate;
/* 0x74 */ JASLfo mTremolo;
/* 0x8C */ MixConfig mMixConfig[6];
/* 0x8C */ MixConfig mMixConfig[BUSOUT_CPUCH];
/* 0x98 */ u16 mPriority;
/* 0x9C */ JASChannelParams mParams;
/* 0xB4 */ JASSoundParams mSoundParams;
+7 -2
View File
@@ -42,10 +42,15 @@ struct JASPortCmd : JSULink<JASPortCmd> {
void execCommandStay();
};
bool addPortCmdOnce();
bool setPortCmd(Command func, JASPortArgs*);
static void execAllCommand();
Command _10;
JASPortArgs* _14;
Command getFunc() { return mFunc; }
JASPortArgs* getArgs() { return mArgs; }
Command mFunc;
JASPortArgs* mArgs;
static TPortHead sCommandListOnce;
static TPortHead sCommandListStay;
+4 -2
View File
@@ -32,10 +32,12 @@ struct JASDrumSet : public JASInst {
void newPercArray(u8, JKRHeap*);
virtual bool getParam(int, int, JASInstParam*) const;
void setPerc(int, JASDrumSet::TPerc*);
JASDrumSet::TPerc* getPerc(int);
JASDrumSet::TPerc* getPerc(int) const;
virtual u32 getType() const;
/* 0x4 */ TPerc** field_0x4;
/* 0x8 */ u8 field_0x8;
/* 0x4 */ TPerc** mPercArray;
/* 0x8 */ u8 mPercNumMax;
};
#endif /* JASDRUMSET_H */
+21 -22
View File
@@ -22,13 +22,15 @@ public:
bool alloc(JASHeap*, u32);
bool allocTail(JASHeap*, u32);
bool free();
u32 getTotalFreeSize();
u32 getFreeSize();
void insertChild(JASHeap*, JASHeap*, void*, u32, bool);
JASHeap* getTailHeap();
u32 getTailOffset();
u32 getCurOffset();
void* getBase() { return mBase; }
bool isAllocated() { return mBase; }
bool isAllocated() const { return mBase; }
u32 getSize() const { return mSize; }
/* 0x00 */ JSUTree<JASHeap> mTree;
@@ -180,7 +182,7 @@ class JASMemChunkPool : public T<JASMemChunkPool<ChunkSize, T> >::ObjectLevelLoc
mNextChunk = chunk;
}
u32 getFreeSize() {
u32 getFreeSize() const {
return ChunkSize - mUsedSize;
}
@@ -201,27 +203,22 @@ public:
}
bool createNewChunk() {
bool uVar2;
if (field_0x18 != NULL && field_0x18->isEmpty()) {
field_0x18->revive();
uVar2 = 1;
} else {
MemoryChunk* pMVar4 = field_0x18;
field_0x18 = new (JASKernel::getSystemHeap(), 0) MemoryChunk(pMVar4);
if (field_0x18 != NULL) {
uVar2 = 1;
} else {
JUT_WARN(428, "%s", "Not enough JASSystemHeap");
field_0x18 = new (JKRHeap::getSystemHeap(), 0) MemoryChunk(pMVar4);
if (field_0x18 != NULL) {
uVar2 = 1;
} else {
field_0x18 = pMVar4;
uVar2 = 0;
}
}
return true;
}
return uVar2;
MemoryChunk* pMVar4 = field_0x18;
field_0x18 = new (JASKernel::getSystemHeap(), 0) MemoryChunk(pMVar4);
if (field_0x18 != NULL) {
return true;
}
JUT_WARN(428, "%s", "Not enough JASSystemHeap");
field_0x18 = new (JKRHeap::getSystemHeap(), 0) MemoryChunk(pMVar4);
if (field_0x18 != NULL) {
return true;
}
field_0x18 = pMVar4;
return false;
}
void* alloc(u32 size) {
@@ -269,6 +266,8 @@ namespace JASKernel {
JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* getCommandHeap();
void setupAramHeap(u32, u32);
JASHeap* getAramHeap();
u32 getAramFreeSize();
u32 getAramSize();
extern JASHeap audioAramHeap;
extern u32 sAramBase;
@@ -348,14 +347,14 @@ class JASPoolAllocObject_MultiThreaded {
public:
static void* operator new(size_t n) {
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
return memPool_.alloc(sizeof(T));
return memPool_.alloc(n);
}
static void* operator new(size_t n, void* ptr) {
return ptr;
}
static void operator delete(void* ptr, size_t n) {
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
memPool_.free(ptr, sizeof(T));
memPool_.free(ptr, n);
}
static void newMemPool(int n) {
+1 -1
View File
@@ -38,7 +38,7 @@ struct JASOscillator {
/* 0x00 */ u32 mTarget;
/* 0x04 */ f32 _04;
/* 0x08 */ const Point* mTable;
/* 0x0C */ const Point* _0C;
/* 0x0C */ const Point* rel_table;
/* 0x10 */ f32 mScale;
/* 0x14 */ f32 _14;
};
+24 -22
View File
@@ -9,37 +9,39 @@ namespace JASResArcLoader {
size_t getResMaxSize(JKRArchive const*);
static void loadResourceCallback(void*);
int loadResourceAsync(JKRArchive*, u16, u8*, u32, void (*)(u32, u32), u32);
// from pikmin2
typedef void (*LoadCallback)(u32, u32);
struct TLoadResInfo {
inline TLoadResInfo(JKRArchive* archive, u16 id, void* buf, u32 size)
: mArchive(archive)
, mID(id)
, mBuffer(buf)
, mBufferSize(size)
, mCallback(0)
, mCallbackArg(0)
, mQueue(0)
{
}
JKRArchive* mArchive; // _00
u16 mID; // _04
void* mBuffer; // _08
u32 mBufferSize; // _0C
LoadCallback mCallback; // _10
u32 mCallbackArg; // _14, arg to pass to mCallback along with readResource result
OSMessageQueue* mQueue; // _18
};
};
class JKRArchive;
// from pikmin2
typedef void (*LoadCallback)(u32, u32);
enum ResArcMessage {
RESARCMSG_Error = -1,
RESARCMSG_Success = 0,
};
struct CallbackArgs {
inline CallbackArgs(u16 id, u8* buf, u32 size, JKRArchive* archive)
: mArchive(archive)
, mID(id)
, mBuffer(buf)
, mBufferSize(size)
, mCallback(0)
, mCallbackArg(0)
, mQueue(0)
{
}
JKRArchive* mArchive; // _00
u16 mID; // _04
u8* mBuffer; // _08
u32 mBufferSize; // _0C
LoadCallback mCallback; // _10
u32 mCallbackArg; // _14, arg to pass to mCallback along with readResource result
OSMessageQueue* mQueue; // _18
};
#endif /* JASRESARCLOADER_H */
+16 -6
View File
@@ -22,10 +22,14 @@ namespace JASDsp {
*
*/
struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
static const int CHANNEL_MGR_MAX = 4;
static const int TIMED_PARAMS = 6;
static const int OSC_NUM = 2;
enum Status {
STATUS_FREE,
STATUS_RUN,
STATUS_STOP,
STATUS_STOPPED,
};
struct TChannelMgr : public JASPoolAllocObject_MultiThreaded<TChannelMgr> {
@@ -82,6 +86,11 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
void closeChild(u32);
JASTrack* openChild(u32);
void connectBus(int, int);
f32 getVolume() const;
f32 getPitch() const;
f32 getPan() const;
f32 getFxmix() const;
f32 getDolby() const;
void setLatestKey(u8);
JASChannel* channelStart(JASTrack::TChannelMgr*, u32, u32, u32);
int noteOn(u32, u32, u32);
@@ -115,6 +124,7 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
void setTimebase(u16);
void updateChannel(JASChannel*, JASDsp::TChannel*);
JASTrack* getRootTrack();
int getChannelCount() const;
int tickProc();
int seqMain();
@@ -191,7 +201,7 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
MoveParam_ dolby;
MoveParam_ distFilter;
} params;
MoveParam_ array[6];
MoveParam_ array[TIMED_PARAMS];
} mMoveParam;
#else
/* 0x09C */ union MoveParam_u {
@@ -203,17 +213,17 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
MoveParam_ dolby;
MoveParam_ distFilter;
} params;
MoveParam_ array[6];
MoveParam_ array[TIMED_PARAMS];
MoveParam_u() {}
} mMoveParam;
#endif
/* 0x0e4 */ JASOscillator::Data mOscParam[2];
/* 0x0e4 */ JASOscillator::Data mOscParam[OSC_NUM];
/* 0x114 */ JASOscillator::Point mOscPoint[4];
/* 0x12C */ JASTrack* mParent;
/* 0x130 */ JASTrack* mChildren[MAX_CHILDREN];
/* 0x170 */ TChannelMgr* mChannelMgrs[4];
/* 0x170 */ TChannelMgr* mChannelMgrs[CHANNEL_MGR_MAX];
/* 0x180 */ TChannelMgr mDefaultChannelMgr;
/* 0x1D0 */ int mChannelMgrCount;
/* 0x1D0 */ u32 mChannelMgrCount;
/* 0x1D4 */ const JASDefaultBankTable* mBankTable;
/* 0x1D8 */ f32 field_0x1d8;
/* 0x1DC */ f32 field_0x1dc;
+2 -2
View File
@@ -230,7 +230,7 @@ public:
T* getObject() const { return this->mTree->getObject(); }
bool operator==(JSUTree<T>* other) { return this->mTree == other; }
bool operator==(const JSUTree<T>* other) const { return this->mTree == other; }
bool operator!=(const JSUTree<T>* other) const { return this->mTree != other; }
@@ -245,7 +245,7 @@ public:
return *this;
}
T* operator*() { return this->getObject(); }
T* operator*() const { return this->getObject(); }
T* operator->() const { return this->getObject(); }