Skip to content

Commit

Permalink
JASOscillator (#675)
Browse files Browse the repository at this point in the history
* JASOscillator work

* JASOscillator matching

* JASOscillator code cleanup

* JASOscillator minor tweak

* Fixed build

* Update src/JSystem/JAudio/JASOscillator.cpp

Co-authored-by: LagoLunatic <[email protected]>

---------

Co-authored-by: LagoLunatic <[email protected]>
  • Loading branch information
DanTGL and LagoLunatic authored Aug 22, 2024
1 parent ce9dde8 commit fb2a2e9
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 54 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def JSystemLib(lib_name, objects):
Object(Matching, "JSystem/JAudio/JASChAllocQueue.cpp"),
Object(NonMatching, "JSystem/JAudio/JASChannel.cpp"),
Object(NonMatching, "JSystem/JAudio/JASChannelMgr.cpp"),
Object(NonMatching, "JSystem/JAudio/JASOscillator.cpp"),
Object(Matching, "JSystem/JAudio/JASOscillator.cpp"),
Object(Matching, "JSystem/JAudio/JASDriverTables.cpp"),
Object(Matching, "JSystem/JAudio/dspproc.c", extra_cflags="-lang c++ -O4 -func_align 32"),
Object(Matching, "JSystem/JAudio/dsptask.c", extra_cflags="-lang c++ -O4 -func_align 32"),
Expand Down
37 changes: 25 additions & 12 deletions include/JSystem/JAudio/JASOscillator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace JASystem {
struct Osc_ {
/* 0x00 */ u8 field_0x0;
/* 0x04 */ f32 field_0x4;
/* 0x08 */ void* table;
/* 0x0C */ void* rel_table;
/* 0x08 */ s16* table;
/* 0x0C */ s16* rel_table;
/* 0x10 */ f32 field_0x10;
/* 0x14 */ f32 field_0x14;
};
Expand All @@ -22,18 +22,31 @@ namespace JASystem {
f32 getOffset();
bool forceStop();
bool release();
void calc(s16*);
f32 calc(s16*);

/* 0x00 */ const Osc_* field_0x0;
/* 0x04 */ u8 field_0x4;
const Osc_* getOsc() const { return mOsc; }
void setOsc(const Osc_* osc) { mOsc = osc; }
BOOL isOsc() { return mOsc != NULL ? TRUE : FALSE; }
void releaseDirect(u16 param_0) { mDirectRelease = param_0; }
void bankOscToOfs() {}
void getEffectorKind() const {}
void getOscMode() const {}

static s16 oscTableForceStop[6];
static const f32 relTableSampleCell[17];
static const f32 relTableSqRoot[17];
static const f32 relTableSquare[17];

/* 0x00 */ const Osc_* mOsc;
/* 0x04 */ u8 mState;
/* 0x05 */ u8 field_0x5;
/* 0x06 */ short field_0x6;
/* 0x08 */ f32 field_0x8;
/* 0x0C */ f32 field_0xc;
/* 0x10 */ f32 field_0x10;
/* 0x14 */ f32 field_0x14;
/* 0x18 */ u16 field_0x18;
/* 0x1C */ f32 field_0x1c;
/* 0x06 */ u16 field_0x6;
/* 0x08 */ f32 mReleaseRate;
/* 0x0C */ f32 mPhase;
/* 0x10 */ f32 mTargetPhase;
/* 0x14 */ f32 mPhaseChangeRate;
/* 0x18 */ u16 mDirectRelease;
/* 0x1C */ f32 mInitialReleaseRate;
};
}

Expand Down
19 changes: 10 additions & 9 deletions src/JSystem/JAudio/JASChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void JASystem::TChannel::init() {
}
for (u32 i = 0; i < 4; i++) {
JUT_ASSERT(155, osc[i]);
osc[i]->field_0x0 = NULL;
osc[i]->setOsc(NULL);
osc[i]->init();
}
mPauseFlag = 0;
Expand All @@ -67,35 +67,36 @@ void JASystem::TChannel::setOscillator(u32 oscnum, TOscillator* param_2) {
/* 8028B620-8028B6A8 .text setOscInit__Q28JASystem8TChannelFUlPCQ38JASystem11TOscillator4Osc_ */
void JASystem::TChannel::setOscInit(u32 oscnum, const TOscillator::Osc_* param_2) {
JUT_ASSERT(183, oscnum < (4));
osc[oscnum]->field_0x0 = param_2;
osc[oscnum]->setOsc(param_2);
osc[oscnum]->initStart();
}

/* 8028B6A8-8028B73C .text forceStopOsc__Q28JASystem8TChannelFUl */
bool JASystem::TChannel::forceStopOsc(u32 numosc) {
/* Nonmatching */
JUT_ASSERT(195, numosc < (4));
return osc[numosc]->field_0x0 != NULL ? osc[numosc]->forceStop() : false;
return osc[numosc]->isOsc() ? osc[numosc]->forceStop() : false;
}

/* 8028B73C-8028B7D0 .text releaseOsc__Q28JASystem8TChannelFUl */
bool JASystem::TChannel::releaseOsc(u32 numosc) {
/* Nonmatching */
JUT_ASSERT(209, numosc < (4));
return osc[numosc]->field_0x0 ? osc[numosc]->release() : false;
return osc[numosc]->isOsc() ? osc[numosc]->release() : false;
}

/* 8028B7D0-8028B850 .text directReleaseOsc__Q28JASystem8TChannelFUlUs */
void JASystem::TChannel::directReleaseOsc(u32 oscnum, u16 param_2) {
JUT_ASSERT(224, oscnum < (4));
osc[oscnum]->field_0x18 = param_2;
osc[oscnum]->releaseDirect(param_2);
}

/* 8028B850-8028B8E4 .text bankOscToOfs__Q28JASystem8TChannelFUl */
f32 JASystem::TChannel::bankOscToOfs(u32 oscnum) {
/* Nonmatching */
JUT_ASSERT(234, oscnum < (4));
return osc[oscnum]->field_0x0 ? osc[oscnum]->getOffset() : 1.0f;
// Probably uses inline JASystem::TOscillator::bankOscToOfs
return osc[oscnum]->isOsc() ? osc[oscnum]->getOffset() : 1.0f;
}

/* 8028B8E4-8028BA98 .text effectOsc__Q28JASystem8TChannelFUlf */
Expand All @@ -107,22 +108,22 @@ void JASystem::TChannel::effectOsc(u32 oscnum, f32 param_2) {
int JASystem::TChannel::getOscState(u32 oscnum) const {
/* Nonmatching */
JUT_ASSERT(274, oscnum < (4));
return osc[oscnum]->field_0x4;
return osc[oscnum]->mState;
}

/* 8028BB14-8028BB98 .text isOsc__Q28JASystem8TChannelFUl */
BOOL JASystem::TChannel::isOsc(u32 oscnum) {
/* Nonmatching */
JUT_ASSERT(284, oscnum < (4));
return osc[oscnum]->field_0x0 != 0;
return osc[oscnum]->isOsc();
}

/* 8028BB98-8028BC78 .text copyOsc__Q28JASystem8TChannelFUlPQ38JASystem11TOscillator4Osc_ */
void JASystem::TChannel::copyOsc(u32 oscnum, TOscillator::Osc_* param_2) {
/* Nonmatching */
JUT_ASSERT(295, oscnum < (4));
if (isOsc(oscnum)) {
*param_2 = *osc[oscnum]->field_0x0;
*param_2 = *osc[oscnum]->getOsc();
} else {
OSReport("osc[%d] is NULL\n", oscnum);
}
Expand Down
Loading

0 comments on commit fb2a2e9

Please sign in to comment.